Copyright (C) 2001 Michael Leonhard Mike Leonhard mike at tamale dot net http://tamale.net/ Vitamin C Vitamin C is a simplistic programming language. Three data types are supported, integer, floating point, and string. `sub' defines a subroutine. Input data types are specified. Output data types are inferred from the `return' statements. Subroutines may take one parameter or none. Subroutines may return one value or none. // single line comment /* nested /* comments */ */ sub foo int a: return a ; sub main: int x = 1 int b b := foo x return ; Tokenizer grammar: identifier: alpha alphanum* subkeyword: `s' `u' `b' returnkeyword: `r' `e' `t' `u' `r' `n' intkeyword: `i' `n' `t' floatkeyword: `f' `l' `o' `a' `t' stringkeyword: `s' `t' `r' `i' `n' `g' integer: decimal | hexadecimal decimal: decdigit decdigit* hexadecimal: `0' `x' hexdigit hexdigit* floatingpoint: frontfloat | bothfloat | backfloat frontfloat: decdigit decdigit* `.' bothfloat: decdigit decdigit* `.' decdigit decdigit* backfloat: `.' decdigit decdigit* string: `"' nonquote* `"' nonquote: ` ' | `!' | escapedquote | #..[ | escapedbackslash | ]..~ escapedquote: `\' `"' escapedbackslash: `\' `\' alpha: a..z | A..Z alphanum: a..z | A..Z | decdigit decdigit: 1..0 hexdigit: decdigit | a..f | A..F colonsymbol: `:' assignsymbol: ':=' semicolonsymbol: `;' leftparensymbol: `(' rightparensymbol: `)' orsymbol: `|' xorsymbol: `^' lshsymbol: `<<' rshsymbol: `>>' gtsymbol: `>' ltsymbol: `<' equalsymbol: `=' subtractsymbol: `-' addsymbol: `+' multiplysymbol: `*' dividesymbol: `/' whitespace: ' ' | '\t' | '\r' endline: '\n' | '\n' '\n'* Parser grammar: vitaminc: sub sub* sub: subkeyword identifier block | subkeyword identifier definition block block: colonsymbol statement* return semicolonsymbol return: returnkeyword expression | returnkeyword statement: definition | assignment | subcall definition: intdefition | floatdefinition | stringdefinition intdefinition: intkeyword identifier assignsymbol expression | intkeyword identifier floatdefinition: floatkeyword identifier assignsymbol expression | floatkeyword identifier stringdefinition: stringkeyword identifier assignsymbol expression | stringkeyword identifier assign: identifer assignsymbol expression subcall: identifier expression | identifier expression: parens | integer | floatingpoint | string | subcall | or | xor | lsh | rsh | gt | lt | equal | subtract | add | multiply | divide parens: leftparensymbol expression rightparensymbol or: expression orsymbol expression xor: expression xorsymbol expression lsh: expression lshsymbol expression rsh: expression rshsymbol expression gt: expression gtsymbol expression lt: expression ltsymbol expression equal: expression equalsymbol expression subtract: expression subtractsymbol expression add: expression addsymbol expression multiply: expression multiplysymbol expression divide: expression dividesymbol expression Operator precedence is as follows, from lowest to highest: | ^ = << >> > < - + * /