{"id":49099016,"url":"https://github.com/crguezl/hello-jison","last_synced_at":"2026-04-20T22:14:53.822Z","repository":{"id":142444809,"uuid":"459592884","full_name":"crguezl/hello-jison","owner":"crguezl","description":"An intro to compilers: Simple examples","archived":false,"fork":false,"pushed_at":"2024-02-06T13:01:32.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-02-06T14:45:18.025Z","etag":null,"topics":["escodegen","espree","jison","language-processing","lexical-analysis","parsing","ull"],"latest_commit_sha":null,"homepage":"https://ull-esit-gradoii-pl.github.io/temas/introduccion-a-pl/esprima.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crguezl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-02-15T13:34:56.000Z","updated_at":"2022-02-17T11:00:12.000Z","dependencies_parsed_at":"2023-03-21T20:32:58.728Z","dependency_job_id":null,"html_url":"https://github.com/crguezl/hello-jison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/crguezl/hello-jison","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crguezl%2Fhello-jison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crguezl%2Fhello-jison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crguezl%2Fhello-jison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crguezl%2Fhello-jison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crguezl","download_url":"https://codeload.github.com/crguezl/hello-jison/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crguezl%2Fhello-jison/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32067881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T21:26:33.338Z","status":"ssl_error","status_checked_at":"2026-04-20T21:26:22.081Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["escodegen","espree","jison","language-processing","lexical-analysis","parsing","ull"],"created_at":"2026-04-20T22:14:53.159Z","updated_at":"2026-04-20T22:14:53.813Z","avatar_url":"https://github.com/crguezl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compiler Basics\n\nThis repo contains four examples:\n\n## minus folder\n\n* The first one in folder `minus` is a simple interpreter for infix arithmetic expressions with the minus operator only\n  * See files `minus.jison`, `minus.l` and  `use_minus.js`\n\n## location folder\n\n* The example in folder `location`  shows how to access to the location of tokens, how to pass information from outside to an action, how to deal with lexical errors and a few tricks to improve error messages\n  * See files `minus-error-management.jison`, `minus-error-management.l` and  `main.js`\n  * The `err.js` file contains the error message function\n\n\n```\n➜  ast git:(master) ✗ npx jison minus-ast.jison  minus-ast.l -o minus.js\n```\n\nThe file `use-minus.js` outputs the AST in JSON format:\n\n```js\n➜  ast git:(master) ✗ cat use_minus.js \n#!/usr/bin/env node\nconst p = require(\"./minus\").parser;\n\nconst t = p.parse(process.argv[2] || \"2-1-1\");\nconsole.log(JSON.stringify(t, null, 2));\n```\n\nHere is an execution example:\n\n```\n➜  ast git:(master) ✗ ./use_minus.js \u003e ast.json; cat ast.json     \n{\n  \"type\": \"Program\",\n  \"body\": [\n    {\n      \"type\": \"ExpressionStatement\",\n      \"expression\": {\n        \"type\": \"CallExpression\",\n        \"callee\": {\n          \"type\": \"MemberExpression\",\n          \"object\": {\n            \"type\": \"Identifier\",\n            \"name\": \"console\"\n          },\n          \"property\": {\n            \"type\": \"Identifier\",\n            \"name\": \"log\"\n          },\n          \"computed\": false\n        },\n        \"arguments\": [\n          {\n            \"type\": \"BinaryExpression\",\n            \"left\": {\n              \"type\": \"BinaryExpression\",\n              \"left\": {\n                \"type\": \"Literal\",\n                \"value\": 2,\n                \"raw\": \"2\"\n              },\n              \"operator\": \"-\",\n              \"right\": {\n                \"type\": \"Literal\",\n                \"value\": 1,\n                \"raw\": \"1\"\n              }\n            },\n            \"operator\": \"-\",\n            \"right\": {\n              \"type\": \"Literal\",\n              \"value\": 1,\n              \"raw\": \"1\"\n            }\n          }\n        ]\n      }\n    }\n  ],\n  \"sourceType\": \"script\"\n}\n```\n\n## ast folder\n\n* The example in folder `ast` is a translator from infix arithmetic expressions to JavaScript\n  * `minus-ast.jison` builds a Espree compatible AST using `minus.l` and the helpers in `ast-build.js`\n  * Check \u003ca href=\"https://astexplorer.net/\" target=\"_blank\"\u003eastexplorer.net demo\u003c/a\u003e to explore the shape of the ASTs\n  * The lexical analyzer `minus.l` is used by both examples\n* The `ast.json` filescontain examples of Espree ASTs for `console.log(2-1-1)`\n\nMore details in [ast/README.md](ast/README.md)\n\n## prec folder\n\n* The example in folder `prec` illustrates the use of the `%prec` directive to resolve conflicts\n  * See files `prec.jison`, `prec.l` and  `use_prec.js`\n  * The `prec-*.json` files contain examples of Espree ASTs\n  \n## package.json scripts to run the examples\n\n```\nhello-jison git:(master) npm run\nLifecycle scripts included in hello-jison@1.0.0:\n  test\n    npm run tojs; node ast/salida.js\n\navailable via `npm run-script`:\n  test-simple\n    npm run build; ./minus/use_minus.js\n  tojs\n    npm run build-ast; ./ast/ast2js.js | tee ast/salida.js\n  build-ast\n    npm run compile-ast; ./ast/use_minus.js \u003e ast/ast.json; cat ast/ast.json\n  build\n    jison minus/minus.jison minus/minus.l -o minus/minus.js\n  loc\n    jison location/minus-error-management.jison location/minus-error-management.l -o location/minus.js\n  debug\n    jison minus/minus.jison minus/minus.l -o minus/minus.js --debug\n  dfa\n    bison -v minus.jison; rm -f minus.tab.jison\n  prec\n    jison prec/uminus.jison prec/minus.l -o prec/uminus.js; prec/use-prec.js\n  compile-ast\n    jison ast/minus-ast.jison ast/minus-ast.l -o ast/minus.js\n  clean\n    rm -f ast/ast.json ast/salida.js ast/minus.js location/minus.js\n```\n\n## Install the dependencies:\n\n```\nnpm i\n```\n\n## Branches\n\nThe landing branch:\n\n- master\n\nOne branch per class `yearmonthday`:\n\n- 20230213\n- 20230214\n  \nStart to work from branch \n\n- initial\n\n\n## References\n\n* [Repo ULL-ESIT-GRADOII-PL/esprima-pegjs-jsconfeu-talk](https://github.com/ULL-ESIT-GRADOII-PL/esprima-pegjs-jsconfeu-talk)\n* [crguezl/hello-jison](https://github.com/crguezl/hello-jison)\n* [Espree](https://github.com/eslint/espree)\n  * [Options for parse and tokenize methods](https://github.com/eslint/espree#options)\n* \u003ca href=\"https://astexplorer.net/\" target=\"_blank\"\u003eastexplorer.net demo\u003c/a\u003e\n* \u003ca href=\"https://nolanlawson.github.io/jison-debugger/\" target=\"_blank\"\u003eJison Playground\u003c/a\u003e\n* [idgrep.js](https://github.com/ULL-ESIT-GRADOII-PL/esprima-pegjs-jsconfeu-talk/blob/master/idgrep.js)\n* [Introducción a los Compiladores](https://ull-esit-gradoii-pl.github.io/temas/introduccion-a-pl/esprima.html) con Jison y Espree\n* Google Slides [Intro to Compilers](https://docs.google.com/presentation/d/1N8h99dXzud9HzH8XY6QCZSmATCAWXtZebuqRTiy8qMU/edit?usp=sharing) by Casiano","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrguezl%2Fhello-jison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrguezl%2Fhello-jison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrguezl%2Fhello-jison/lists"}