lisp-inference
lisp-inference copied to clipboard
Refactor string parser and lexer: mainly for webapp usage
- It should tokenize tokens first based on operations, supporting concatenated (without whitespaces) exps like this:
p^q
. - It should use a LL(1) parser
- It should supports parenthesis without any problem
- It should fail early instead of trying be clever.
Example:
In: "p^q=>r"
Out: (=> (^ p q) r)
Well, you could use an LL(1) parser to read the expression precedence and give you a polish notation expression. Try using this website to test this grammar:
D' -> v C D'
D' -> ''
C -> I C'
C' -> ^ I C'
C' -> ''
I -> E I'
I' -> => E I'
I' -> ''
E -> N E'
E' -> <=> N E'
E' -> ''
N -> ~ A
N -> A
A -> ( P )
A -> id
Thank you for this contribution! A formal parser will be really useful!
The parsing table it is:
Runtime parsing steps.
Maybe can be useful: https://github.com/vy/meta-sexp