Skip to content
Olivier Duhart edited this page Jun 28, 2022 · 5 revisions

lexer

IDENTIFIER : an id is a sequence of letters
COLON : ":"
ZEROORMORE : "*"
ONEORMORE : "+"
OPTION : "?"
DISCARD : "[d]"
LPAREN :"("
RPAREN : ")"
STRING : "'.*?'"

parser

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