The Bison parser detects a syntax error (or parse error) whenever it reads a token which cannot satisfy any syntax rule.
The prototypes are only indications of how the code produced by Bison uses yyerror. Bison-generated code always ignores the returned value, so yyerror can return any type, including void.
void is preferable since it more accurately describes the return type for yyerror.
This is a terminal symbol that is always defined (you need not declare it) and reserved for error handling.
an error followed by a newline makes a valid addition to any stmts.
Note that discarded symbols are possible sources of memory leaks, see Freeing Discarded Symbols, for a means to reclaim this memory
These functions will be defined in the epilogue, but the parser calls them so they must be declared in the prologue.
If the token kind is a character literal, then its numeric code is that of the character; you can use the same character literal in the lexical analyzer to express the number. If the token kind is an identifier, that identifier is defined by Bison as a C enum whose definition is the appropriate code. In this example, therefore, NUM becomes an enum for yylex to use.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.