orangeduck / mpc

A Parser Combinator library for C
Other
2.69k stars 294 forks source link

Add support for semantic action for language parser #100

Open stevefan1999-personal opened 5 years ago

stevefan1999-personal commented 5 years ago

I was trying to do inline type inference rather than to generate a parse tree then traverse it after PEG passes, this way we could avoid some potential backtracking issue by stopping ahead and hence sped up (or terminate) the parsing process.

I know Clang does parse tree scan too but they clearly had more information than what mpc currently have to deduce a sound combinations.

orangeduck commented 5 years ago

If you build up your own AST data type as you go using the combinator approach (rather than the grammar approach) you can insert as much functionality as you like in-between parsing. Yes it is a bit less user friendly than the grammar definition but it is the only sane way to do this sort of thing while still making use of mpc.