-
Notifications
You must be signed in to change notification settings - Fork 35
EBNF rules grammar
Olivier Duhart edited this page Jun 28, 2022
·
5 revisions
IDENTIFIER : an id is a sequence of letters
COLON : ":"
ZEROORMORE : "*"
ONEORMORE : "+"
OPTION : "?"
DISCARD : "[d]"
LPAREN :"("
RPAREN : ")"
STRING : "'.*?'"
rule : IDENTIFIER COLON clauses
clauses : clause clauses
clauses : clause
# clause
clause : IDENTIFIER ZEROORMORE
clause : IDENTIFIER ONEORMORE
clause : IDENTIFIER OPTION
clause : IDENTIFIER DISCARD
clause : IDENTIFIER
clause : choiceclause
clause : choiceclause DISCARD
## explicit tokens
clause : STRING DISCARD
clause : STRING
# alternate choice
choiceclause : LCROG choices RCROG
choices : IDENTIFIER
choices : STRING
choices : IDENTIFIER OR choices
choices : STRING OR choices
# group
clause : LPAREN groupclauses RPAREN
clause : LPAREN groupclauses RPAREN ONEORMORE
clause : LPAREN groupclauses RPAREN ZEROORMORE
clause : LPAREN groupclauses RPAREN OPTION
groupclauses : groupclause groupclauses
groupclauses : groupclause
groupclause : IDENTIFIER
groupclause : IDENTIFIER DISCARD