All Projects → objmagic → LR

objmagic / LR

Licence: MIT License
explore different techniques to generate LR(k) parsing code

Programming Languages

ocaml
1615 projects
Makefile
30231 projects
Standard ML
205 projects

Projects that are alternatives of or similar to LR

bracer
Java library for parsing and evaluating math expressions
Stars: ✭ 18 (+38.46%)
Mutual labels:  parsing
racket-bitsyntax
Erlang-style binaries/bitstrings for Racket
Stars: ✭ 29 (+123.08%)
Mutual labels:  parsing
CYK-Parser
A CYK parser written in Python 3.
Stars: ✭ 24 (+84.62%)
Mutual labels:  parsing
JuCC
JuCC - Jadavpur University Compiler Compiler
Stars: ✭ 34 (+161.54%)
Mutual labels:  parsing
lua-luaepnf
Extended PEG Notation Format (easy grammars for LPeg)
Stars: ✭ 21 (+61.54%)
Mutual labels:  parsing
loquat
Monadic parser combinators for JavaScript / TypeScript
Stars: ✭ 47 (+261.54%)
Mutual labels:  parsing
http-accept
Parse Accept and Accept-Language HTTP headers in Ruby.
Stars: ✭ 69 (+430.77%)
Mutual labels:  parsing
YaccConstructor
Platform for parser generators and other grammarware research and development. GLL, RNGLR, graph parsing algorithms, and many others are included.
Stars: ✭ 36 (+176.92%)
Mutual labels:  parsing
Ohm-S
A Squeak/Smalltalk implementation of the metaprogramming framework Ohm.
Stars: ✭ 18 (+38.46%)
Mutual labels:  parsing
statham-schema
Statham is a Python Model Parsing Library for JSON Schema.
Stars: ✭ 21 (+61.54%)
Mutual labels:  parsing
octet
A library that makes working with bytebuffers painless.
Stars: ✭ 79 (+507.69%)
Mutual labels:  parsing
tangle-rs
a collection of tools to do tangle in rust
Stars: ✭ 23 (+76.92%)
Mutual labels:  parsing
copper
An integrated context-aware scanner and parser generator
Stars: ✭ 14 (+7.69%)
Mutual labels:  parsing
PSStringScanner
Provides lexical scanning operations on a String
Stars: ✭ 45 (+246.15%)
Mutual labels:  parsing
Jsonify
♨️A delightful JSON parsing framework.
Stars: ✭ 42 (+223.08%)
Mutual labels:  parsing
attach-juxtapose-parser
Code for the paper "Strongly Incremental Constituency Parsing with Graph Neural Networks"
Stars: ✭ 25 (+92.31%)
Mutual labels:  parsing
php-binary
A PHP library for parsing structured binary streams.
Stars: ✭ 30 (+130.77%)
Mutual labels:  parsing
structures
Declarative binary data builder and parser: simple, fast, extensible
Stars: ✭ 29 (+123.08%)
Mutual labels:  parsing
ruby-marshal
Haskell library to parse a subset of Ruby objects serialised with Marshal.dump
Stars: ✭ 30 (+130.77%)
Mutual labels:  parsing
kolasu
Kotlin Language Support – AST Library
Stars: ✭ 45 (+246.15%)
Mutual labels:  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

  • Normal approach

    • very naive LR(1) parsing algorithm. use hardcoded lr(1) parsing code to interpret array-based table
  • Automata simulated by GADT

    • Hardcoded GADT

    • Hardcoded optimized GADT

    • token information --> optional intermediate data structure like a GADT? --> use typed refunctionalization to generate mutually recursive functionals (optimized)

    • Generate optimized GADT using MetaOCaml (techinically impossible now)

  • Stackless LR(1) parser

    • An improvement to Derivation of a Typed Functional LR Parser
      Stack is implicitly represented as continuation function (CPS). Since no explicit stack data structure is present, it is possible to use MetaOCaml to generate parser.

      Jeremy, Runhang (01/18/16):
      maybe can use direct style, which is much easier for us to generate code. But if one state has two different reduce production rules, we can't turn CPS to direct style. Frederic showed one state can have to different reduction rules, so we can't have direct style :(

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].