Merge branch 'parser-devel' into 40-add-parser-rule-for-calling-functions
This commit is contained in:
commit
96a50f4289
|
@ -15,6 +15,8 @@
|
||||||
%%
|
%%
|
||||||
"\n" yyLineNumber++;
|
"\n" yyLineNumber++;
|
||||||
|
|
||||||
|
#.* ;
|
||||||
|
|
||||||
":" {DEBUG("\"%s\" tokenized with \':\'", yytext); return(':');};
|
":" {DEBUG("\"%s\" tokenized with \':\'", yytext); return(':');};
|
||||||
"=" {DEBUG("\"%s\" tokenized with \'=\'", yytext); return('=');};
|
"=" {DEBUG("\"%s\" tokenized with \'=\'", yytext); return('=');};
|
||||||
"+" {DEBUG("\"%s\" tokenized with \'+\'", yytext); return('+');};
|
"+" {DEBUG("\"%s\" tokenized with \'+\'", yytext); return('+');};
|
||||||
|
@ -24,7 +26,6 @@
|
||||||
"," {DEBUG("\"%s\" tokenized with \',\'", yytext); return(',');};
|
"," {DEBUG("\"%s\" tokenized with \',\'", yytext); return(',');};
|
||||||
";" {DEBUG("\"%s\" tokenized with \';\'", yytext); return(';');};
|
";" {DEBUG("\"%s\" tokenized with \';\'", yytext); return(';');};
|
||||||
"." {DEBUG("\"%s\" tokenized with \'.\'", yytext); return('.');};
|
"." {DEBUG("\"%s\" tokenized with \'.\'", yytext); return('.');};
|
||||||
"#" {DEBUG("\"%s\" tokenized with \'#\'", yytext); return('#');};
|
|
||||||
|
|
||||||
"(" {DEBUG("\"%s\" tokenized with \'(\'", yytext); return('(');};
|
"(" {DEBUG("\"%s\" tokenized with \'(\'", yytext); return('(');};
|
||||||
")" {DEBUG("\"%s\" tokenized with \')\'", yytext); return(')');};
|
")" {DEBUG("\"%s\" tokenized with \')\'", yytext); return(')');};
|
||||||
|
|
|
@ -55,14 +55,22 @@
|
||||||
%token FunLineno
|
%token FunLineno
|
||||||
%token FunExtsupport
|
%token FunExtsupport
|
||||||
|
|
||||||
|
/* Operator associativity */
|
||||||
|
%right '='
|
||||||
|
%left '+' '-' '*' '/'
|
||||||
|
%left OpEquals OpNot '<' '>'
|
||||||
|
%left OpAnd OpOr OpXor
|
||||||
|
%left OpBitand OpBitor OpBitxor OpBitnot
|
||||||
|
|
||||||
%%
|
%%
|
||||||
program: funcall;
|
program: statementlist;
|
||||||
|
|
||||||
expr: ValFloat
|
expr: ValFloat
|
||||||
| ValInt
|
| ValInt
|
||||||
| ValMultistr
|
| ValMultistr
|
||||||
| ValStr
|
| ValStr
|
||||||
| Ident;
|
| Ident
|
||||||
|
| operation;
|
||||||
|
|
||||||
exprlist: expr ',' exprlist
|
exprlist: expr ',' exprlist
|
||||||
| expr
|
| expr
|
||||||
|
@ -75,6 +83,24 @@ funcall: Ident paramlist { DEBUG("Function call"); };
|
||||||
|
|
||||||
assign: Ident '=' expr { DEBUG("Assignment"); };
|
assign: Ident '=' expr { DEBUG("Assignment"); };
|
||||||
|
|
||||||
|
statementlist: statementlist statement
|
||||||
|
| ;
|
||||||
|
|
||||||
|
statement: assign
|
||||||
|
| decl
|
||||||
|
| definition
|
||||||
|
| branch;
|
||||||
|
|
||||||
|
branchif: KeyIf expr '{' statementlist '}' { DEBUG("if"); };
|
||||||
|
branchelse: KeyElse '{' statementlist '}' { DEBUG("if-else"); };
|
||||||
|
branchelseif: KeyElse KeyIf expr '{' statementlist '}' { DEBUG("else-if"); };
|
||||||
|
|
||||||
|
branchelseifs: branchelseifs branchelseif
|
||||||
|
| ;
|
||||||
|
|
||||||
|
branch: branchif branchelseifs
|
||||||
|
| branchif branchelseifs branchelse;
|
||||||
|
|
||||||
identlist: Ident ',' identlist
|
identlist: Ident ',' identlist
|
||||||
| Ident
|
| Ident
|
||||||
| ;
|
| ;
|
||||||
|
@ -83,6 +109,8 @@ decl: type ':' identlist { DEBUG("Declaration"); };
|
||||||
|
|
||||||
definition: decl '=' expr { DEBUG("Definition"); };
|
definition: decl '=' expr { DEBUG("Definition"); };
|
||||||
|
|
||||||
|
assign: Ident '=' expr { DEBUG("Assignment"); };
|
||||||
|
|
||||||
sign: KeySigned
|
sign: KeySigned
|
||||||
| KeyUnsigned
|
| KeyUnsigned
|
||||||
| ;
|
| ;
|
||||||
|
@ -97,8 +125,30 @@ type: sign scale Ident
|
||||||
| sign scale KeyInt
|
| sign scale KeyInt
|
||||||
| sign scale KeyFloat;
|
| sign scale KeyFloat;
|
||||||
|
|
||||||
|
operation: oparith
|
||||||
|
| oplogic
|
||||||
|
| opbool
|
||||||
|
| opbit;
|
||||||
|
|
||||||
|
oparith: expr '+' expr
|
||||||
|
| expr '-' expr
|
||||||
|
| expr '*' expr
|
||||||
|
| expr '/' expr
|
||||||
|
| '-' expr %prec '*';
|
||||||
|
|
||||||
|
oplogic: expr OpEquals expr
|
||||||
|
| expr '<' expr
|
||||||
|
| expr '>' expr;
|
||||||
|
|
||||||
|
opbool: expr OpAnd expr
|
||||||
|
| expr OpOr expr
|
||||||
|
| expr OpXor expr
|
||||||
|
| OpNot expr %prec OpAnd;
|
||||||
|
|
||||||
|
opbit: expr OpBitand expr
|
||||||
|
| expr OpBitor expr
|
||||||
|
| expr OpBitxor expr
|
||||||
|
| OpBitnot expr %prec OpBitand;
|
||||||
%%
|
%%
|
||||||
|
|
||||||
int yyerror(char *s) {
|
int yyerror(char *s) {
|
||||||
|
|
Loading…
Reference in New Issue