Types, Identifiers and Numbers

Reflex limits types to integer types and booleans. There is no floating point type included in the language, and new types cannot be declared. There are a couple of cases where certain constructs behave like types. For instance module definitions and declarations behave in some ways like types, but are not treated as such in the grammar or in the language definition. Identifiers follow the familiar C-like rules, Identifiers must start with a character which is not a digit, terminal character or ‘+’ and identifiers cannot shadow keywords.

Legal Identifiers

__hello
value
v1234
$value
@value
aHappyVariable
a$Happy@Variable
another_happy_variable

Illegal Character

1badvar
+mybadvar
;anotherbadvar

Integer Literals

Negative integer literals can be written by prefixing the integer with a - sign. Signed values are represented by two’s complement values as in other C-like languages.

Integer literals can also be represented as hexidecimal values to wite a hex value,prefix the literal with 0x. So 127 can be represented as 0x7F and -128 can be represented as -0xF0

Signed vs Unsigned

A given type is considered a signed value unless it is prefixed with the unsigned keyword. The language does include the signed keyword and a value may be fully and explicitly declared as such, but in general use of signed is not necessary.

Type

Size in Bytes

Min

Max

unsigned Max

char (byte)

1

-128

127

255

short

2

–32768

32767

65535

int

4

–2147483648

2147483647

4294967295

Identifiers, and Type Declarations EBNF

Identifier

letter      ::=    'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J'
                 | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T'
                 | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | 'a' | 'b' | 'c' | 'd'
                 | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n'
                 | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x'
                 | 'y' | 'z' ;
nonterminal ::=  '_' | '$' | '@' ;
ID          ::=  letter | nonterminal , { letter | digit | nontermial } ;

Integer Literal

digit-not-zero ::=    '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8'
                    | '9' ;
digit          ::=  '0' | digit-not-zero ;
hex-digit      ::=  digit | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c'
                    | 'd' | 'e' | 'f' ;
INT            ::=  '0'
                    | digit-not-zero , { digit }
                    | '-' digit-not-zero , { digit }
                    | '0x' hex-digit , { hex-digit }
                    | '-0x' hex-digit, { hex-digit } ;

Type Specifier

TYPE           ::=  'char' | 'short' | 'int' ;
type_specifier ::=  TYPE | 'unsigned' , TYPE | 'signed' , TYPE ;