| Frabrice Bellard | a969305 | 2009-05-11 14:50:37 -0700 | [diff] [blame] | 1 |  | 
 | 2 | Supported C language subset (read joint example 'otccex.c' to have | 
 | 3 |     an introduction to OTCC dialect): | 
 | 4 |  | 
 | 5 |     - Expressions: | 
 | 6 |  | 
 | 7 |         * binary operators, by decreasing priority order: '*' '/' '%', | 
 | 8 |           '+' '-', '>>' '<<', '<' '<=' '>' '>=', '==' '!=', '&', | 
 | 9 |           '^', '|', '=', '&&', '||'. | 
 | 10 |  | 
 | 11 |         * '&&' and '||' have the same semantics as C : left to right | 
 | 12 |           evaluation and early exit. | 
 | 13 |  | 
 | 14 |         * Parenthesis are supported. | 
 | 15 |  | 
 | 16 |         * Unary operators: '&', '*' (pointer indirection), '-' | 
 | 17 |           (negation), '+', '!', '~', post fixed '++' and '--'. | 
 | 18 |  | 
 | 19 |         * Pointer indirection ('*') only works with explicit cast to | 
 | 20 |           'char *', 'int *' or 'int (*)()' (function pointer). | 
 | 21 |  | 
 | 22 |         * '++', '--', and unary '&' can only be used with variable | 
 | 23 |           lvalue (left value). | 
 | 24 |  | 
 | 25 |         * '=' can only be used with variable or '*' (pointer | 
 | 26 |           indirection) lvalue. | 
 | 27 |  | 
 | 28 |         * Function calls are supported with standard i386 calling | 
 | 29 |           convention. Function pointers are supported with explicit | 
 | 30 |           cast. Functions can be used before being declared. | 
 | 31 |  | 
 | 32 |     - Types: only signed integer ('int') variables and functions can | 
 | 33 |       be declared. Variables cannot be initialized in | 
 | 34 |       declarations. Only old K&R function declarations are parsed | 
 | 35 |       (implicit integer return value and no types on arguments). | 
 | 36 |  | 
 | 37 |     - Any function or variable from the libc can be used because OTCC | 
 | 38 |       uses the libc dynamic linker to resolve undefined symbols. | 
 | 39 |  | 
 | 40 |     - Instructions: blocks ('{' '}') are supported as in C. 'if' and | 
 | 41 |       'else' can be used for tests. The 'while' and 'for' C constructs | 
 | 42 |       are supported for loops. 'break' can be used to exit | 
 | 43 |       loops. 'return' is used for the return value of a function. | 
 | 44 |  | 
 | 45 |     - Identifiers are parsed the same way as C. Local variables are | 
 | 46 |       handled, but there is no local name space (not a problem if | 
 | 47 |       different names are used for local and global variables). | 
 | 48 |  | 
 | 49 |     - Numbers can be entered in decimal, hexadecimal ('0x' or '0X' | 
 | 50 |       prefix), or octal ('0' prefix). | 
 | 51 |  | 
 | 52 |     - '#define' is supported without function like arguments. No macro | 
 | 53 |       recursion is tolerated. Other preprocessor directives are | 
 | 54 |       ignored. | 
 | 55 |  | 
 | 56 |     - C Strings and C character constants are supported. Only '\n', | 
 | 57 |       '\"', '\'' and '\\' escapes are recognized. | 
 | 58 |  | 
| Jack Palevich | 9918d0a | 2009-05-15 10:57:02 -0700 | [diff] [blame] | 59 |     - Both C comments ( /* */ ) and C++ comments ( // ... end-of-line ) can be used. | 
| Frabrice Bellard | a969305 | 2009-05-11 14:50:37 -0700 | [diff] [blame] | 60 |  | 
 | 61 |     - No error is displayed if an incorrect program is given. | 
 | 62 |  | 
 | 63 |     - Memory: the code, data, and symbol sizes are limited to 100KB | 
 | 64 |       (it can be changed in the source code). | 
 | 65 |  |