I want to use Java to parse a very simple grammar, for example:
/*comments*/
"aaa" = "bbb"
That's all. I want all tokens (comment, string, equals).
Is there any Java library that can handle this?
You gonna have to write the base grammar that recognize everyone of these tokens and then generate the parser (lexical and syntaxic) with a tool like SableCC or JavaCC (They both produce Java classes). Then you'll have a parser that can parse your language.
I hope it is what you meant by parse a [...] grammar.
for really basic needs you can use either java.util.StringTokenizer or java.io.StreamTokenizer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With