I want to parse some C++ code, and as a guide I've been looking at the C lex/yacc definitions here: <http://www.lysator.liu.se/c/ANSI-C-grammar-l.html> and <http://www.lysator.liu.se/c/ANSI-C-grammar-y.html>

I understand the specifications of the tokens themselves, but not how they interact. eg. it's OK to have an operator such as = directly follow an identifier without intervening white space (ie. "foo="), but it's not OK to have a numerical constant immediately followed by an identifier (ie. 123foo). However, I don't see any way that such rules are represented.

What am I missing?... or is this lex/yacc too liberal in its acceptance of errors.