{"_id":"@alu0101040288/eloquentjsegg","_rev":"1-3141736caf8309a24415077d0c952c27","name":"@alu0101040288/eloquentjsegg","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.1":{"name":"@alu0101040288/eloquentjsegg","version":"1.2.1","description":"Parser y VM para el lenguaje Egg","main":"lib/eggvm.js","scripts":{"test":"mocha","test:watch":"mocha --watch --reporter min","start":"./bin/egg.js ./examples/two.egg","compile":"./bin/eggc.js examples/two.egg && ./bin/evm.js examples/two.egg.evm"},"bin":{"egg":"./bin/egg.js","eggc":"./bin/eggc.js","evm":"./bin/evm.js"},"repository":{"type":"git","url":"git+https://github.com/ULL-ESIT-PL-1819/p5-t1-egg-0-cruzelante098.git"},"keywords":["parsing","lisp"],"author":"","license":"ISC","homepage":"https://github.com/ULL-ESIT-PL-1819/p5-t1-egg-0-cruzelante098","devDependencies":{"chai":"^4.2.0","gulp-shell":"^0.7.0","mocha":"^5.2.0","should":"^13.2.3"},"dependencies":{"readline-sync":"^1.4.9","xregexp":"^4.2.4"},"gitHead":"e263e2573c092e21fd01d6857099e57e8c1761d5","bugs":{"url":"https://github.com/ULL-ESIT-PL-1819/p5-t1-egg-0-cruzelante098/issues"},"_id":"@alu0101040288/eloquentjsegg@1.2.1","_npmVersion":"6.5.0","_nodeVersion":"11.9.0","_npmUser":{"name":"alu0101040288","email":"alu0101040288@ull.edu.es"},"dist":{"integrity":"sha512-ykX3dIWkrQLl4LUvkaI4lpQKJHzT+1eFhJZXWMekXZsd3omSyJBlx4ndNqUQCkN+hYBMx8BQvrsvTWOL4QeSwQ==","shasum":"0ac8c68b6ce7fa59dffa3f306367aeefd4594526","tarball":"https://registry.npmjs.org/@alu0101040288/eloquentjsegg/-/eloquentjsegg-1.2.1.tgz","fileCount":25,"unpackedSize":24053,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcn85yCRA9TVsSAnZWagAAWC0P/0dLrkB/v+nvgbM5lARC\nqS4vYPmtoc0xyxehpwafG3IjYfQEpqiwP1HPI2IwqVPxMzV8QwswAerC8Qd0\n5Zf1dvWyswoCMw7hjigbe2JRn/F9BcQfU6odd1cXELUrfTo3yqum8SKxrpBf\n+1ZBSC2hoSTdeXoUIG4mXocJp3DMYOtYtRXIBzfsIYHqHXj6Iw0GYJMYarCB\nr5ha9Yb2GCCM9Cg/gN1zRow6ODDAIUue7fOtlib8RqbMEEO20hCFt6OaepI8\nS5/lq66JckmFBJEnjktRSkHSLD5yn9Wtbtk3SDmMrJ+ilqXCfBTIZqQK43bZ\nRh1x59pfMh40/SX+Lf+UMLZUYMJACsUz3XrA2pToNdfPsQPgDzZkSh9lx/MX\nQFYgO/kzCa/2T0lNjnEg+qCqtznWJ4xJN60LJ98yifc5rGQpeDFlir6rCe4/\nSm07nicsjcY6AJQD8uNRxltbnXdqViwprC3ZnD/GTXKlNKKjWRdbQfg+LoIo\n+Ej9iIZtyqP/kCAlNpPty7eZaYdAqYee4wNMdodersffPQ/l4j/xGSx/SRjU\nz4YqmOVTCONqlXIi8eQ5IBDKTD392qsCqfRmnq1by7TOs66dMHTF69STO8ej\nUXzpMirnDvUqnGUcgjmfrOrgbHHBJA9rmY9513qCtD90awR/+slzreNQOviT\nlZgg\r\n=4cRI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFRDyU52bbxNKuAOXMt/2GzxoJNHuSOhLepC/BpFBaF9AiEAtIJqWzuw4fLzTTVxYeHMgflYVkXDREQ6Gt/QI+dqzBc="}]},"maintainers":[{"name":"alu0101040288","email":"alu0101040288@ull.edu.es"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eloquentjsegg_1.2.1_1553976945970_0.19699126556000457"},"_hasShrinkwrap":false}},"time":{"created":"2019-03-30T20:15:45.785Z","1.2.1":"2019-03-30T20:15:46.122Z","modified":"2022-04-04T13:40:59.129Z"},"maintainers":[{"name":"alu0101040288","email":"alu0101040288@ull.edu.es"}],"description":"Parser y VM para el lenguaje Egg","homepage":"https://github.com/ULL-ESIT-PL-1819/p5-t1-egg-0-cruzelante098","keywords":["parsing","lisp"],"repository":{"type":"git","url":"git+https://github.com/ULL-ESIT-PL-1819/p5-t1-egg-0-cruzelante098.git"},"bugs":{"url":"https://github.com/ULL-ESIT-PL-1819/p5-t1-egg-0-cruzelante098/issues"},"license":"ISC","readme":"[![Build Status](https://travis-ci.org/ULL-ESIT-PL-1617/egg.svg?branch=master)](https://travis-ci.org/ULL-ESIT-PL-1617/egg)\r\n[![npm version](https://badge.fury.io/js/%40crguezl%2Feloquentjsegg.svg)](https://badge.fury.io/js/%40crguezl%2Feloquentjsegg)\r\n\r\n### Code from Eloquent JS. Chapter 11. Project: A Programming Language\r\n\r\n* [Eloquent JS. Chapter 11. Project: A Programming Language](http://eloquentjavascript.net/11_language.html)\r\n* [As an npm module](https://www.npmjs.com/package/@crguezl/eloquentjsegg)\r\n* [gist to check the npm module](https://gist.github.com/crguezl/8dfcaa01a0377dead374bc35c462c29d)\r\n\r\n### Grammar\r\n\r\n```Yacc\r\n\r\nexpression: STRING\r\n          | NUMBER\r\n          | WORD apply \r\n\r\napply: /* vacio */\r\n     | '(' (expression ',')* expression? ')' apply\r\n\r\n\r\nWHITES = /^(\\s|[#;].*|\\/\\*(.|\\n)*?\\*\\/)*/;\r\nSTRING = /^\"((?:[^\"\\\\]|\\\\.)*)\"/;\r\nNUMBER = /^([-+]?\\d*\\.?\\d+([eE][-+]?\\d+)?)/;\r\nWORD   = /^([^\\s(),\"]+)/;\r\n```\r\n\r\n### AST\r\n\r\n* Expressions of type \"VALUE\" represent literal strings or numbers. \r\nTheir `value` property contains the string or number value that they represent.\r\n\r\n* Expressions of type \"WORD\" are used for identifiers (names). Such objects have a `name` property that holds the identifier’s name as a string. \r\n* Finally, \"APPLY\" expressions represent applications. They have an `operator` property that refers to the expression that is being applied, and an `args` property that holds an array of argument expressions.\r\n\r\n```\r\nast: VALUE{value: String | Number}\r\n   | WORD{name: String}\r\n   | APPLY{operator: ast, args: [ ast ...]}\r\n```\r\n\r\nThe `>(x, 5)` would be represented like this:\r\n\r\n```bash\r\n$ cat greater-x-5.egg \r\n>(x,5)\r\n$ ./eggc.js greater-x-5.egg \r\n$ cat greater-x-5.egg.evm \r\n{\r\n  \"type\": \"apply\",\r\n  \"operator\": {\r\n    \"type\": \"word\",\r\n    \"name\": \">\"\r\n  },\r\n  \"args\": [\r\n    {\r\n      \"type\": \"word\",\r\n      \"name\": \"x\"\r\n    },\r\n    {\r\n      \"type\": \"value\",\r\n      \"value\": 5\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n### Examples\r\n\r\n* [Directory with examples](https://github.com/ULL-ESIT-PL-1617/egg/tree/master/examples)\r\n\r\n### Instalation\r\n\r\n```\r\n$ npm i -g @crguezl/eloquentjsegg\r\n...\r\n```\r\n\r\n### Executables\r\n\r\n* `egg` \r\n    - Runs an egg program: `egg examples/two.egg` compiles the source onto the AST and interprets the AST\r\n\r\n```\r\n$ cat one.egg\r\ndo(\r\n  define(x, 4),\r\n  define(setx, fun(val, \r\n      set(x, val)\r\n    )\r\n  ),\r\n  setx(50),\r\n  print(x)\r\n)\r\n$ egg one.egg\r\n50\r\n```\r\n\r\n* `eggc`\r\n    - Compiles the input program to produce a JSON containing the tree: `eggc examples/two.egg` produces the JSON file `examples/two.egg.evm`\r\n* `evm` \r\n    - Egg Virtual Machine. Runs the tree: `evm examples/two.egg.evm`\r\n```\r\n$ eggc one.egg\r\n$ ls -ltr | tail -1\r\n-rw-r--r--  1 casiano  wheel  1656 19 mar 08:05 one.egg.evm\r\n$ evm one.egg.evm \r\n50\r\n```\r\n\r\nHere is the tree in JSON format for the former `one.egg` program:\r\n\r\n```\r\n$ cat one.egg.evm\r\n{\r\n  \"type\": \"apply\",\r\n  \"operator\": {\r\n    \"type\": \"word\",\r\n    \"name\": \"do\"\r\n  },\r\n  \"args\": [\r\n    {\r\n      \"type\": \"apply\",\r\n      \"operator\": {\r\n        \"type\": \"word\",\r\n        \"name\": \"define\"\r\n      },\r\n      \"args\": [\r\n        {\r\n          \"type\": \"word\",\r\n          \"name\": \"x\"\r\n        },\r\n        {\r\n          \"type\": \"value\",\r\n          \"value\": 4\r\n        }\r\n      ]\r\n    },\r\n    {\r\n      \"type\": \"apply\",\r\n      \"operator\": {\r\n        \"type\": \"word\",\r\n        \"name\": \"define\"\r\n      },\r\n      \"args\": [\r\n        {\r\n          \"type\": \"word\",\r\n          \"name\": \"setx\"\r\n        },\r\n        {\r\n          \"type\": \"apply\",\r\n          \"operator\": {\r\n            \"type\": \"word\",\r\n            \"name\": \"fun\"\r\n          },\r\n          \"args\": [\r\n            {\r\n              \"type\": \"word\",\r\n              \"name\": \"val\"\r\n            },\r\n            {\r\n              \"type\": \"apply\",\r\n              \"operator\": {\r\n                \"type\": \"word\",\r\n                \"name\": \"set\"\r\n              },\r\n              \"args\": [\r\n                {\r\n                  \"type\": \"word\",\r\n                  \"name\": \"x\"\r\n                },\r\n                {\r\n                  \"type\": \"word\",\r\n                  \"name\": \"val\"\r\n                }\r\n              ]\r\n            }\r\n          ]\r\n        }\r\n      ]\r\n    },\r\n    {\r\n      \"type\": \"apply\",\r\n      \"operator\": {\r\n        \"type\": \"word\",\r\n        \"name\": \"setx\"\r\n      },\r\n      \"args\": [\r\n        {\r\n          \"type\": \"value\",\r\n          \"value\": 50\r\n        }\r\n      ]\r\n    },\r\n    {\r\n      \"type\": \"apply\",\r\n      \"operator\": {\r\n        \"type\": \"word\",\r\n        \"name\": \"print\"\r\n      },\r\n      \"args\": [\r\n        {\r\n          \"type\": \"word\",\r\n          \"name\": \"x\"\r\n        }\r\n      ]\r\n    }\r\n  ]\r\n}\r\n```\r\n### Using it as a library\r\n\r\n```js\r\n> egg = require('@crguezl/eloquentjsegg')\r\n{ run: [Function: run],\r\n  runFromFile: [Function: runFromFile],\r\n  runFromEVM: [Function: runFromEVM],\r\n  parser: \r\n   { getProgram: [Function: getProgram],\r\n     lex: [Function: lex],\r\n     parse: [Function: parse],\r\n     parseApply: [Function: parseApply],\r\n     parseExpression: [Function: parseExpression],\r\n     parseFromFile: [Function: parseFromFile],\r\n     setProgram: [Function: setProgram] } }\r\n> parser = egg.parser\r\n> parser.parse('def(x,4)')\r\n{ type: 'apply',\r\n  operator: { type: 'word', name: 'def' },\r\n  args: [ { type: 'word', name: 'x' }, { type: 'value', value: 4 } ] }\r\n```\r\n","readmeFilename":"README.md"}