How to build a Parser
First Steps on Building a Parser with Jison
See the examples in the repo ull-esit-pl/hello-jison
This repo contains two examples:
- The first one is a simple interpreter for infix arithmetic expressions with the minus operator only
- See files
minus.jison
,minus.l
anduse_minus.js
- The prec folder contains a more advanced example of how to extend the former example with unary minus
- See files
- The second is a translator from infix arithmetic expressions to JavaScript
minus-ast.jison
builds a Espree compatible AST usingminus.l
and the helpers inast-build.js
- The lexical analyzer
minus.l
is reused - The ast-*.json files contain examples of Espree ASTs
- The test folder illustrates how to make tests using mocha
See the section LR Parsing for more information on LR parsing and how to deal with Jison conflicts.
Videos
11 de Febrero de 2025. Conflictos. Prioridades. Asociatividad. %prec. Arith2js
10 de Febrero de 2025. Análisis LR y bottom-up. Conflictos. Prioridades. Asociatividad. %prec
5 de febrero de 2025. No se ve la pizarra al estar el fondo activado.
Este vĂdeo del 14 de Febrero de 2024 explica como hacer parte de la práctica arith2js:
TambiĂ©n puede ver los vĂdeos del 14, 15 y 22 de febrero de 2023, que contienen explicaciones para la práctica arith2js:
PEG.js example from the talk “Parsing, Compiling, and Static Metaprogramming”
altjs.js is the code for the “AltJS language in 5 minutes” section presented in the second half of the talk Parsing, Compiling, and Static Metaprogramming by Patrick Dubroy
References
- crguezl/hello-jison and ull-esit-pl/hello-jison
- Repo ULL-ESIT-GRADOII-PL/esprima-pegjs-jsconfeu-talk
- Espree
- Options for parse and tokenize methods
- Espree API documentation at ull-esit-pl.github.io/espree
- ECMA-262, 14th edition, June 2023. ECMAScript® 2023 Language Specification
- Simple examples of AST traversal and transformation crguezl/ast-traversal
- crguezl/hello-jison
- astexplorer.net demo
- idgrep.js
- Estraverse Usage
- Master the Art of the AST
- Awesome AST A repo like
- ESQuery is a library for querying the AST output by Esprima for patterns of syntax using a CSS style selector system.