Programming Tools Guide
Chapter 13, yacc

Reserved words

Reserved words

Some programming languages permit you to use words like if, which are normally reserved as label or variable names, provided that such use does not conflict with the legal use of these names in the programming language. This is extremely hard to do in the framework of yacc. It is difficult to pass the lexical analyzer information telling it one instance of if is a keyword and another instance is a variable. The user can attempt to implement this using the mechanism described in the last subsection, but this is not trivial. It is better that the keywords be reserved, that is, forbidden for use as variable names.