Grammar
# Type a grammar into this area # and select the grammar language # and parser algorithm below -- # or load one of the predefined # examples. # You can resize each area # by moving the grey bands.
Load a predefined example...
Representing a BNF grammar
Describing a grammar
A language for grammars
What's in this grammar object?
Tokenizer
The implementation
Ambiguous grammars
Initial grammar checks [1/3]
Initial grammar checks [2/3]
Initial grammar checks [3/3]
Representing an EBNF grammar
Another selfie
What's in that grammar object?
Initial EBNF grammar checks
The idea
Definitions [1/3]
Definitions [2/3]
Definitions [3/3]
Testing for LL(1) [BNF 1/2]
Testing for LL(1) [BNF 2/2]
Testing for LL(1) [EBNF]
Dealing with ambiguity [1/2]
Dealing with ambiguity [2/2]
Input [1/2]
Input [2/2]
Error recovery
Comparison
Tracing
Collecting values
Semantic actions [1/3]
Semantic actions [2/3]
Semantic actions [3/3]
Interpreting arithmetic expressions
Representing arithmetic expressions [1/2]
Representing arithmetic expressions [2/2 ]
Compiling arithmetic expressions
Adding memory
Euclid's algorithm
Representing BNF
Representing EBNF
Wirth Syntax Notation
BNF is all you need
The idea
A shift/reduce conflict
A reduce/reduce conflict
Arithmetic
Arithmetic [precedence]
Hiding conflicts
EBNF and precedence
Recognition
Collecting values
Semantic actions
“error”
“error” in iterations
EBNFP
Translating EBNF
The idea
Definitions [1/3]
Definitions [2/3]
Definitions [3/3]
Testing for LL(1) [BNF 1/2]
Testing for LL(1) [BNF 2/2]
Testing for LL(1) [EBNF]
Dealing with ambiguity [1/2]
Dealing with ambiguity [2/2]
represent arithmetic expressions (BNF)
represent arithmetic expressions (EBNF)
bootstrap demonstration (EBNF in BNF)
addition [BNF LR]
evaluate arithmetic expressions [BNF LR]
represent arithmetic expressions [BNF LR]
complete error recovery [BNF LR]
if/fi [BNF]
if [BNF LR]
calculations [EBNF LR]
evaluate arithmetic expressions (EBNF)
represent arithmetic expressions (EBNF)
complete error recovery [EBNF LR]
lang?
BNF
EBNF
alg?
LL(1)
SLR(1)
do?
check
describe
pattern
Actions
// Execute JavaScript code in the context of page: // Initialize a global variable 'actions' in this area // with an object with function properties // corresponding to the grammar's non-terminals. actions = { }; // Optionally, initialize a global variable 'env' // which is sent as first argument // to each function call.
execute
Input
Type a program in the new language in this area.
do?
tokenize
parse
trace
Output
See a grammar description or output from parsing the input or output from executing JavaScript in this area. You can elect to trace recognition, i.e., to see what messages are sent and what the actions (if any) return.