Flex/Bison based lexer/parser for C language

Mahdi picture Mahdi · Jan 26, 2016 · Viewed 7.2k times · Source

Is there a simple lexer/parser for C language or a subset of it which is based on Flex/Bison?

I have found some open source parsers for C (TCC, LCC, ...) but none of them are based on bison.

Answer

Mikhail Maltsev picture Mikhail Maltsev · Jan 27, 2016

There is a C11 grammar for YACC (a predecessor of Bison), it should work with Bison (maybe some tweaks will be needed).

GCC used to be based on Bison a long ago. GCC 3.4 source code contains a file with C grammar.