objmagic / LR

explore different techniques to generate LR(k) parsing code
MIT License
14 stars 1 forks source link
lr1 parsing

LR

explore different techniques to generate LR(k) parsing code

m41.ml -- hand-rolled parsers for ASU grammar 4.1 and 4.55. These parsers serve as references for how generated code should look like.

lr_parser.ml -- a type-safe LR(1) automata building engine. The idea is to build automata and interpret it to generate code (or we can generate on-the-fly).

genf1.ml -- some crazy code by Drup. It can be useful.

Methods

How-to

Take a canonical example, Grammar 4.1 in Aho.

  1. manually go over all algorithms on paper, get very familar with LR(1) parsing process. How optimization works?

  2. write naive LR(1) parser on computer

  3. try different black technologies