TopicsIntroduction to Programming LanguagesIntroduction to Parsers

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 and use_minus.js
    • The prec folder contains a more advanced example of how to extend the former example with unary minus
  • The second is a translator from infix arithmetic expressions to JavaScript
    • minus-ast.jison builds a Espree compatible AST using minus.l and the helpers in ast-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