Hi I’d like to make my own ‘parser’, e.g: computing (4+(3-4^2))*2 or parsing java,jsf,html code.
In fact I did something like this but I feel it’s not good.
Is there anything good for me? I’ve tried to read more, but I’m bit confused, LL, LR, AST,BNF,javacc yacc etc :). I’m not sure which way to go, when I would like to compute 4+…
or if I’d like to parse java,jsf code and produce something from this(another java code)
Is there anything generaly good enough like ast? or something which I can use for both?
thank you for help.
Before anything else, you have to understand that everything about parsing is based on grammars.
Grammars describe the language you want to implement in terms of how to decompose the text in basic units and how to stack those units in some meaning ful way. You may also want to look for the token, non-terminal, terminal concepts.
Differences between LL and LR can be of two kinds: implementation differences, and grammar writing differences. If you use a standard tool you only need to understand the second part.
I usually use LL (top-down) grammars. They are simpler to write and to implement even using custom code. LR grammars theoretically cover more kinds of languages but in a normal situation they are just a hindrance when you need some correct error detection.
Some random pointers: