Logic Parser Coding

I need to make a parser for propositional logic. I pretend to do it manually, like a recursive descent parser in java.

Mi's question about lexer, is it really necessary for this work ?, I mean to define a state machine for token recognition, etc. I saw several examples of simple parsers for arithmetic, and they process everything in a "single parser", relying only on grammar rules. It doesn't seem like they care about a separate independent lexer that provides tokens for the parser.

Since I want to do this in the most correct way, I ask for advice for this work. Any reference to relevant information is appreciated.

+4
source share
2 answers

A little more information would be helpful, i.e. the grammar you want to use and the String input example. I donโ€™t know how much you know about Chomskyโ€™s grammatical levels, but thatโ€™s the key. Simplified, a lexer can analyze the level of a word (Level 3: Regular grammars), and the analyzer syntax can also analyze (Level 2: Context-free grammars). (more information here: lexers vs parsers )

, , , , . , , , , , , . . , , lexer , ;) , , , !

+3

"" . -, (, , ). , .

. SO , : flex/bison, 8- ?

+1

All Articles