|
|
Ocamlyacc |
||||
|
Handled grammar |
LALR(1) |
LR(1) |
ContextFree (GLR) |
ContextFree (GLR) |
LL(k) (k not well defined) |
|
Reentrant |
??? |
Yes |
Yes |
??? |
Yes |
|
Grammars in multiple files |
No |
Yes |
No |
??? |
Yes |
|
Extensible (an action can change the grammar) |
No |
No |
Yes (moreover, the extension is « scoped ») |
No |
Yes |
|
Parametrized non terminal |
No |
Yes (parametrized by other symbols, terminal or not) |
No (except for priority) |
No |
No (except for levels and OPT or LIST0|1 construct) |
|
Nested or local non terminal definition |
No |
No |
No |
No |
Yes |
|
Splitting the definition of a non terminal (this is really useful when the grammar can be splitted in many files) |
No |
Yes |
Yes |
Yes |
Yes |
|
Grammars parametrized by Ocaml modules |
No |
Yes |
No |
No |
Yes |
|
Rule guarded by semantical value for terminal (allowing to use something like KWD('+') as a terminal) |
No |
No |
Yes |
No |
Yes |
|
Pattern matching on semantical value for terminal and non terminal (allowing a terminal like « expr_list([x]) » to mean an expressions list of size one in a rule) |
No |
No |
Yes |
No |
Yes |
|
Naming of semantical value in rules (to avoid the $1,$2, ... which are hard to maintain) |
No |
Yes |
Yes |
Yes |
Yes |
|
Partial action (action code in the middle of a rule) |
No |
No |
Yes |
No |
Yes (with a hack) |
|
Ambiguous grammars (this means you can get all parse-trees and usually implies that you can parse all context-free grammars) |
No |
No |
Yes |
Yes |
No |
|
Exception to reject a rule |
Meaningless for deterministic parsing |
Meaningless for deterministic parsing |
Yes |
No ??? |
No |
|
Priority |
Like yacc |
Like yacc |
Using arbitrary relations |
Using the order relation on integer + associativity direction |
Using levels (= a total and extensible order as a relation) + associativity direction |
|
Debugging grammar conflicts |
Hard |
Easy: conflict explicited in terms of the grammar |
Average (by printing the possible parse trees when many) |
Average (by printing the possible parse trees when many) |
Hard |
|
The language used to write the parser generator |
C |
Ocaml |
Ocaml |
C++ |
Ocaml |
|
Calculator example |
%token LPAREN RPAREN |
Identical to ocamlyacc, menhir is mostly compatible with ocamlyacc. |
Lexer included |
|
let expr = |
Page created by Christophe Raffalli