Sample grammar:
tokens {
""; # Each instance of a quoted string automatically becomes one unique token
number; # A custom token
}
entry expression; # Entry symbol
expression: term (("+" | "-") term)*; # An expression is a term, possibly added/subtracted by other terms
term: factor (("*" | "/") factor)*; # A term is a factor, possibly multiplied/divided by other factors
factor:
number # Most basic unit: number (a token)
| "(" expression ")" # An expression in parentheses is a single factor
| "sin" "(" expression ")" # We can add sin() function too
| "sin" number # We can allow omitting parentheses when a number follows too
;
Try to mess around with the grammar and see how the program detects a problem in the grammar (e.g. undeclared name). Of course, in the near future the parser generator will be complete and it will be able to start generating parsers for your custom grammar!
Input grammar:
Output:
Grammar check result will be displayed here.
In the future, this will be replaced by a custom input box and a visualization of the generated parse tree.