06.01.2015 Views

Manual

Manual

Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3: Bison Grammar Files 43<br />

• A character token type (or literal character token) is written in the grammar using the<br />

same syntax used in C for character constants; for example, ’+’ is a character token<br />

type. A character token type doesn’t need to be declared unless you need to specify its<br />

semantic value data type (see Section 3.5.1 [Data Types of Semantic Values], page 46),<br />

associativity, or precedence (see Section 5.3 [Operator Precedence], page 73).<br />

By convention, a character token type is used only to represent a token that consists of<br />

that particular character. Thus, the token type ’+’ is used to represent the character<br />

‘+’ as a token. Nothing enforces this convention, but if you depart from it, your program<br />

will confuse other readers.<br />

All the usual escape sequences used in character literals in C can be used in Bison<br />

as well, but you must not use the null character as a character literal because its<br />

numeric code, zero, signifies end-of-input (see Section 4.2.1 [Calling Convention for<br />

yylex], page 64). Also, unlike standard C, trigraphs have no special meaning in Bison<br />

character literals, nor is backslash-newline allowed.<br />

• A literal string token is written like a C string constant; for example, "

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!