Skip to content

Instantly share code, notes, and snippets.

@athanclark
Created August 10, 2014 01:02
Show Gist options
  • Save athanclark/733588ba735506eb455f to your computer and use it in GitHub Desktop.
Save athanclark/733588ba735506eb455f to your computer and use it in GitHub Desktop.
BNF in LBNF
--| I kinda made lists explicit, here: I was able to implement
--| Kleene plusses and stars with the inductive lists. I haven't
--| found much material on properly making list productions in
--| BNFC (*prays to shrine for more material*), but would gladly
--| take in suggestions!
token NonTerminal ('<' (letter | digit | '_' | '-')* '>') ;
SyntaxNil . Syntax ::= ;
SyntaxCons . Syntax ::= Rule Syntax ;
Rule . Rule ::= NonTerminal "::=" Expression ;
--Expression captures optionality
ExpressionList . Expression ::= List ;
ExpressionOpt . Expression ::= List "|" Expression ;
--Kleene Plus lists are concatenation
ListOne . List ::= Term ;
ListCons . List ::= Term List ;
Literal . Term ::= String ;
NonTerm . Term ::= NonTerminal ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment