The parser will convert the tokens into an abstract syntax tree (AST). The AST represents the hierarchical structure of the regular expression.
We will define the grammar for the parser as
terminal :: CHAR := Any printable ASCII character except the terminals below.
terminal :: OR := |
terminal :: STAR := *
terminal :: PLUS := +
terminal :: QUESTION := ?
terminal :: LPAREN := (
terminal :: RPAREN := )
non terminal :: op -> STAR | PLUS | QUESTION | epsilon (ε)
non terminal :: expr -> term | term OR term
non terminal :: term -> factor factor
non terminal :: factor -> base op | epsilon (ε)
non terminal :: base -> CHAR | LPAREN expr RPAREN
The parser will convert the tokens into an abstract syntax tree (AST). The AST represents the hierarchical structure of the regular expression.
We will define the grammar for the parser as