-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Using a custom parser for menhir grammars and applying it to ott/blob/master/src/grammar_parser.mly and manually adding the tokens from ott/blob/master/src/grammar_lexer.mll we can see a railroad diagram for the grammar in catala/blob/master/compiler/surface/parser.mly copy and paste the EBNF shown bellow on https://www.bottlecaps.de/rr/ui in the tab Edit Grammar then switching to the tab View Diagram.
main ::= items
items ::= item items
| EOF
item ::= metavardefn
| RULES rules
| DEFNCLASS defnclass
| FUNDEFNCLASS fundefnclass
| SUBRULES subrules
| CONTEXTRULES contextrules
| SUBSTITUTIONS substitutions
| FREEVARS freevars
| EMBED embed
| PARSING parsing_annotations
| HOMS hom_section
| COQSECTIONBEGIN coq_section_begin
| COQSECTIONEND coq_section_end
| COQVARIABLE coq_variable
metavardefn ::= metavardefn_int
| indexvardefn_int
metavardefn_int ::= METAVAR ne_ident_hom_desc_list CCE metavarrep
indexvardefn_int ::= INDEXVAR ne_ident_hom_desc_list CCE metavarrep
metavarrep ::= homomorphism_list
homomorphism_list ::= /* empty */
| homomorphism homomorphism_list
homomorphism ::= DOUBLELEFTBRACE hom_name hom_spec_el_list DOUBLERIGHTBRACE
hom_name ::= STRING BLANKS
| BLANKS STRING BLANKS
hom_spec_el_list ::= /* empty */
| hom_spec_el hom_spec_el_list
hom_spec_el ::= DOUBLELEFTBRACKET hom_inner DOUBLERIGHTBRACKET
| STRING
| BLANKS
| DOTDOT
| DOTDOTDOT
| DOTDOTDOTDOT
hom_inner ::= ident_and_blanks_list
| ident_and_blanks_list dots ident_and_blanks_list
| COMP_LEFT ident_and_blanks_list COMP_MIDDLE comp_bound COMP_RIGHT blanks_list
embedmorphism_list ::= /* empty */
| embedmorphism embedmorphism_list
embedmorphism ::= DOUBLELEFTBRACE hom_name embed_spec_el_list DOUBLERIGHTBRACE
embed_spec_el_list ::= /* empty */
| embed_spec_el embed_spec_el_list
embed_spec_el ::= DOUBLELEFTBRACKET embed_inner DOUBLERIGHTBRACKET
| STRING
| BLANKS
| DOTDOT
| DOTDOTDOT
| DOTDOTDOTDOT
embed_inner ::= /* empty */
| STRING embed_inner
| BLANKS embed_inner
bindspec ::= BIND mse IN ident
| ident EQ mse
| NAMES LPAREN mse RPAREN EQ NAMES LPAREN mse RPAREN
| NAMES LPAREN mse RPAREN HASH NAMES LPAREN mse RPAREN
| DISTINCTNAMES LPAREN mse RPAREN
bindspeclist ::= /* empty */
| bindspec bindspeclist
mse ::= ident
| ident dots ident
| COMP_LEFT ident COMP_MIDDLE comp_bound COMP_RIGHT
| ident LPAREN ident RPAREN
| ident LPAREN ident dots ident RPAREN
| ident LPAREN COMP_LEFT ident COMP_MIDDLE comp_bound COMP_RIGHT RPAREN
| ident COMP_LEFT ident COMP_MIDDLE comp_bound COMP_RIGHT
| mse UNION mse
| EMPTY
bindspeclistlist ::= /* empty */
| BIND_LEFT_DELIM bindspeclist BIND_RIGHT_DELIM bindspeclistlist
bindspecall ::= bindspeclistlist
dots ::= DOTDOT
| DOTDOTDOT
| DOTDOTDOTDOT
element ::= ident
| dots
| COMP_LEFT element_list COMP_MIDDLE comp_bound COMP_RIGHT
| COMP_LEFT element_list COMP_MIDDLE ident COMP_MIDDLE comp_bound COMP_RIGHT
comp_bound ::= ident
| ident COMP_IN ident
| ident COMP_IN ident dots ident
element_list ::= /* empty */
| element element_list
rules ::= rule_list
rule_list ::= /* empty */
| rule rule_list
rule ::= ne_ident_hom_desc_list COLONCOLON STRING CCE homomorphism_list prodlist
prod ::= flavour element_list COLONCOLON ident_list COLONCOLON STRING bindspecall homomorphism_list
prodlist ::= /* empty */
| prod prodlist
flavour ::= BAR
ident_desc ::= STRING
ne_ident_hom_desc_list ::= ident_desc homomorphism_list
| ident_desc homomorphism_list COMMA ne_ident_hom_desc_list
ident_desc_list ::= /* empty */
| ident_desc COMMA ident_desc_list
ident ::= STRING
blanks ::= BLANKS
ident_list ::= /* empty */
| ident ident_list
| BLANKS ident_list
ident_and_blanks_list ::= /* empty */
| ident ident_and_blanks_list
| blanks ident_and_blanks_list
blanks_list ::= /* empty */
| BLANKS blanks_list
defnclass ::= STRING COLONCOLON STRING CCE homomorphism_list defn_list
defn_list ::= /* empty */
| defn defn_list
defn ::= DEFN element_list COLONCOLON ident_list COLONCOLON STRING COLONCOLON STRING homomorphism_list BY semiraw_rule_list
drule_line_annot ::= ident_list COLONCOLON STRING homomorphism_list EOF
fundefnclass ::= STRING CCE homomorphism_list fundefn_list
fundefn_list ::= /* empty */
| fundefn fundefn_list
fundefn ::= FUNDEFN element_list COLONCOLON ident COLONCOLON STRING homomorphism_list BY BLANKLINE anylinelist
anylinelist ::= /* empty */
| line anylinelist
| COMMENTLINE anylinelist
| BLANKLINE anylinelist
line ::= LINE
lineline ::= LINELINE
linelist ::= /* empty */
| line linelist
| COMMENTLINE linelist
nelinelist ::= line linelist
| COMMENTLINE linelist
semiraw_rule ::= linelist lineline linelist
| nelinelist
blanklinelist ::= /* empty */
| BLANKLINE blanklinelist
neblanklinelist ::= BLANKLINE
| BLANKLINE neblanklinelist
defncom ::= DEFNCOM embed_spec_el_list DOUBLERIGHTBRACE
semiraw_rule_list ::= blanklinelist
| neblanklinelist semiraw_rule semiraw_rule_list
| neblanklinelist defncom semiraw_rule_list
subrules ::= subrules_body
subrules_body ::= /* empty */
| subrule subrules_body
subrule ::= ident_desc LTCOLONCOLON ident_desc homomorphism_list
contextrules ::= contextrules_body
contextrules_body ::= /* empty */
| contextrule contextrules_body
contextrule ::= ident_desc UNDERSCORECOLONCOLON ident_desc COLONCOLON ident_desc
substitutions ::= substitutions_body
substitutions_body ::= /* empty */
| substitution substitutions_body
substitution ::= substitution_kind ident_desc ident_desc COLONCOLON ident_desc homomorphism_list
substitution_kind ::= SINGLE
| MULTIPLE
freevars ::= freevars_body
freevars_body ::= /* empty */
| freevar freevars_body
freevar ::= ident_desc ident_desc COLONCOLON ident_desc homomorphism_list
embed ::= embedmorphism_list
parsing_annotation_type ::= LTEQ
| LEFT
| RIGHT
| NON
parsing_annotations ::= parsing_annotations_body
parsing_annotations_body ::= /* empty */
| parsing_annotation parsing_annotations_body
parsing_annotation ::= ident_desc parsing_annotation_type ident_desc
hom_section_item ::= COLONCOLON STRING bindspecall homomorphism_list
hom_section_item_list ::= /* empty */
| hom_section_item hom_section_item_list
hom_section ::= STRING hom_section_item_list
coq_section_begin ::= STRING
coq_section_end ::= STRING
coq_variable ::= STRING
unfiltered_spec_el_list ::= /* empty */
| unfiltered_spec_el unfiltered_spec_el_list
unfiltered_spec_el ::= DOUBLELEFTBRACKET unfiltered_inner DOUBLERIGHTBRACKET
| STRING
| BLANKS
unfiltered_inner ::= /* empty */
| STRING unfiltered_inner
| BLANKS unfiltered_inner
// Tokens
//| \(\S+\)\s+-> Tok_kw \("[^"]+"\)
EMBED ::= "embed"
HOMS ::= "homs"
METAVAR ::= "metavar"
INDEXVAR ::= "indexvar"
RULES ::= "grammar"
SUBRULES ::= "subrules"
CONTEXTRULES ::= "contextrules"
SUBSTITUTIONS ::= "substitutions"
SINGLE ::= "single"
MULTIPLE ::= "multiple"
FREEVARS ::= "freevars"
DEFNCLASS ::= "defns"
DEFN ::= "defn"
FUNDEFNCLASS ::= "funs"
FUNDEFN ::= "fun"
BY ::= "by"
BIND ::= "bind"
IN ::= "in"
NAMES ::= "names"
DISTINCTNAMES ::= "distinctnames"
UNION ::= "union"
COMP_IN ::= "IN"
PARSING ::= "parsing"
LEFT ::= "left"
RIGHT ::= "right"
NON ::= "non"
COQSECTIONBEGIN ::= "begincoqsection"
COQSECTIONEND ::= "endcoqsection"
COQVARIABLE ::= "coqvariable"
//| \(\S+\)\s+-> Tok_sym (\("[^"]+"\).+
LTEQ ::= "<="
BIND_LEFT_DELIM ::= "(+"
DOTDOT ::= ".."
DOTDOTDOT ::= "..."
DOTDOTDOTDOT ::= "...."
COMP_LEFT ::= "</"
COMP_MIDDLE ::= "//"
COMP_RIGHT ::= "/>"
DOUBLELEFTBRACKET ::= "[["
DOUBLERIGHTBRACKET ::= "]]"
COMMA ::= ","
CCE ::= "::="
BAR ::= "|"
DOUBLELEFTBRACE ::= "{{"
DOUBLERIGHTBRACE ::= "}}"
COLONCOLON ::= "::"
LTCOLONCOLON ::= "<::"
UNDERSCORECOLONCOLON ::= "_::"
BIND_RIGHT_DELIM ::= "+)"
DEFNCOM ::= "{{com"
EQ ::= "="
HASH ::= "#"
LPAREN ::= "("
RPAREN ::= ")"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels