Language Description for C2008 Language

We'll be using a modified version of Louden's C- language (from Louden, Compiler Construction: Principles and Practice). I used Thomas Cormen's modification of C- as a starting point. Let's call it C2008. If you're unsure about syntax or semantics for a particular feature, take a look at the official C documents. In particular, Kernighan and Ritchie, The C Programming Language, 2nd Edition, has a C Reference Manual in Appendix A. I have a copy of this if you need to look something up.

Clarifications and Additional Lexical Conventions

Add the keywords:

     float char for do

The special symbols are single tokens even if they consist of multiple characters (except /* and */). So, for example, < is a token as is <=.

Add the following special symbols (each is a token):

     ++ -- !

Add a token for character literals:

     CHARLIT = '(letter | digit | \n)'

The value for the token is a one-character string where that character is the character or escape sequence from the literal.

Add a token for floating-point numbers:

     FNUM = NUM. | .NUM | NUM.NUM

So these float literals are written as:

     int_part . frac_part 

where either the int_part or the frac_part can be missing, but not both. The value stored for the token is a string representing the floating point number.

Modify the token for ID to match C language conventions:

     ID = ( _ | letter ) ( _ | letter | digit )*

Additional Syntax and Semantics

Semantics are as in C. Additional basic features are:

These should work on int or char variables.

This operator requires int or char operands. As in C- in a logical test, a value of 0 is false and anything else is true. The ! operator negates the logical result.