-
Notifications
You must be signed in to change notification settings - Fork 0
Home
apfohl edited this page Nov 24, 2014
·
3 revisions
f = 1;
f = 1.;
f = .1;
f = 1.123;
v = [1, 2, 3];
v = [1 + 1, f, a + b];
w = 4 * [1, 2, 3];
u = [1, 2] + [4, 6];
u = [1, 2] - [4, 6];
s = 1 + 3 / 4 - 7 * 12.6;
p = (1 + 2) * 3;
[a-zA-Z][a-zA-Z0-9]* return IDENTIFIER;
[0-9]+(\.[0-9]+)? return NUMBER;
[ \t\n]+ ;
"[" return LBRACKET;
"]" return RBRACKET;
"(" return LPAREN;
")" return RPAREN;
"," return COMMA;
";" return SEMIC;
"=" return EQ;
"+" return ADD;
"-" return SUB;
"*" return MULT;
"/" return DIV;
translation_unit := declaration_sequence
declaration_sequence := declaration declaration_sequence | declaration
declaration := IDENTIFIER EQ expression SEMIC
vector := LBRACKET components RBRACKET
components := (atomic_expression COMMA components) | atomic_expression
expression := additive_expression
additive_expression := addition | multiplicative_expression
addition := (additive_expression ADD multiplicative_expression) | (additive_expression SUB multiplicative_expression)
multiplicative_expression := multiplication | negation
multiplication := (multiplicative_expression MULT negation) | (multiplicative_expression DIV negation)
negation := (SUB negation) | primary_expression
primary_expression := (LPAREN atomic_expression RPAREN) | atomic
atomic := IDENTIFIER | NUMBER | vector