Grammar Use Stories
Development
e.g. of a grammar for a shell/CLI
- program = list of (statement '\n')
- enhance grammar to allow multiple statements on one line:
program = list of line
line = list of statement, separated by ';', followed by '\n'
- refactor grammar:
program = list of statement, separated by ';' or '\n'
Left Factorisation
- X = (A B)* C | A B A D
- expand:
X = C | A B (A B)* C | A B A D
- factorise:
X = C | A B ( (A B)* C | A D )
- expand:
X = C | A B ( C | A B (A B)* C | A D )
- factorise:
X = C | A B ( C | A (B (A B)* C | D ) )
"unroll" means (A)* B -> (A A)* A? B
"expand" means A (B)* C -> A C | A (B)+ C or A C | A B (B)* C
This page is maintained by and copyright ©
Pete Jinks
[last modified 21/April/2004]
suggestions, corrections etc. welcome.
You are welcome to make educational, not-for-profit use
(else what would be the point!) but please give due credit.