{"_id":"@alu0100946499/egg","_rev":"1-2f69ab511a54a24a4f41458a2651cd6f","name":"@alu0100946499/egg","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@alu0100946499/egg","version":"1.0.0","description":"[![Build Status](https://travis-ci.org/ULL-ESIT-PL-1617/egg.svg?branch=master)](https://travis-ci.org/ULL-ESIT-PL-1617/egg)\r [![npm version](https://badge.fury.io/js/%40crguezl%2Feloquentjsegg.svg)](https://badge.fury.io/js/%40crguezl%2Feloquentjsegg)","main":"lib/eggvm.js","scripts":{"test":"mocha","start":"node ./bin/egg.js examples/apply-string.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-1617/egg.git"},"keywords":["parsing","lisp"],"author":{"name":"alu0100946499"},"license":"ISC","devDependencies":{"gulp-shell":"*","mocha":"*","should":"*"},"dependencies":{"colors":"^1.3.3","readline":"^1.3.0","source":"0.0.3","util":"^0.11.1","xregexp":"^4.2.4"},"gitHead":"e0c53ebad17069b8ce031116a7024982f8e977eb","bugs":{"url":"https://github.com/ULL-ESIT-PL-1617/egg/issues"},"homepage":"https://github.com/ULL-ESIT-PL-1617/egg#readme","_id":"@alu0100946499/egg@1.0.0","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-OOhhFNzJd8Kl/cR9hnckkuegLVL0KLnNPo4Ns3nOsmhsx5tggR+ZO4RP68LR0dOtJMvNC3esM2oLlYF4SDEaqA==","shasum":"4cb2e2c2004e100e2909240c96b0731ff64ab2f5","tarball":"https://registry.npmjs.org/@alu0100946499/egg/-/egg-1.0.0.tgz","fileCount":50,"unpackedSize":36749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfXndICRA9TVsSAnZWagAAxmYQAI1U9kyimDO9FU6avyD5\nB/xNjp2IRaWGPBzXmd43dgZVjP3m3JJ1HZNiSuU0X5q/yqr/+eCFPOyA6Umn\nJwDAMyqI2iufVROsSbxVZjx5Z+Q0rTCmmPOJ9C3+diL6J6Pg8oDczSIDUlqv\nhNvEvvMiG8nQBSV0/r8J950UE5fZj2poDfUmv+c97zEbyiGv7BIpDM+7YIK1\nXZNllu99mWpwIZ8Xmg53+g3DCM9RSyP3b7+W2fUGiCrMe1x4xQcxqyhl3PNm\nvL2dJX00FjpD8QKar++Oj85FKy+mdumJMZs/H+xBsG+Oik6CRqNGU9rLgTWJ\nQdBHrLonckqFhLBTHb45mKHE69S/b9mQdtRXVjwfbyqF/fFCogrdBgvOmG5p\nCoTUFNXEuba8MfCm/Xy9y822wZNAFXJ0AIomeOGCnih38brIAilGKnxuCSUl\nyEJZWQwY/dMmIYQWTKk8CJEQjo6IOOUj9UMQYj7nqhHeOEzVcoLYeqh7vL2o\nUD3auxcXs4BlDxjeihdXQizs9KFDc/rWqguOtPFwW2PBjMJg4QQsgRN9ERXe\nv2i6k76JfoAfmijFndh9A43vDL7/ePAukpcaW4eiyLzfpDC3b3kS+w5DX36t\nrtnmTxa9FUnpZ/t07jXbmh30vt+Iat22v0k0+gf4TJS+49plh+hvJCe9Snmm\nzrpN\r\n=Qomn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDpfEk5uPzh99WL9kvmNrS1twsluyYWFpgYdheRdeOQjgIgDrBoVuX/5Q+VfWKykGic6TQ3udtv6IANN338jYde71U="}]},"maintainers":[{"name":"alu0100946499","email":"alu0100946499@ull.edu.es"}],"_npmUser":{"name":"alu0100946499","email":"alu0100946499@ull.edu.es"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg_1.0.0_1600026440402_0.5047363078577511"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-13T19:47:20.364Z","1.0.0":"2020-09-13T19:47:20.535Z","modified":"2022-04-04T13:40:54.413Z"},"maintainers":[{"name":"alu0100946499","email":"alu0100946499@ull.edu.es"}],"description":"[![Build Status](https://travis-ci.org/ULL-ESIT-PL-1617/egg.svg?branch=master)](https://travis-ci.org/ULL-ESIT-PL-1617/egg)\r [![npm version](https://badge.fury.io/js/%40crguezl%2Feloquentjsegg.svg)](https://badge.fury.io/js/%40crguezl%2Feloquentjsegg)","homepage":"https://github.com/ULL-ESIT-PL-1617/egg#readme","keywords":["parsing","lisp"],"repository":{"type":"git","url":"git+https://github.com/ULL-ESIT-PL-1617/egg.git"},"author":{"name":"alu0100946499"},"bugs":{"url":"https://github.com/ULL-ESIT-PL-1617/egg/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"}