refactored transmute rule and added bracketed expressions
This commit is contained in:
parent
fc80e23917
commit
8c17749923
|
@ -52,6 +52,7 @@
|
||||||
"float" {DEBUG("\"%s\" tokenized with \'KeyFloat\'", yytext); return(KeyFloat);};
|
"float" {DEBUG("\"%s\" tokenized with \'KeyFloat\'", yytext); return(KeyFloat);};
|
||||||
"self" {DEBUG("\"%s\" tokenized with \'KeySelf\'", yytext); return(KeySelf);};
|
"self" {DEBUG("\"%s\" tokenized with \'KeySelf\'", yytext); return(KeySelf);};
|
||||||
"as" {DEBUG("\"%s\" tokenized with \'KeyAs'", yytext); return (KeyAs);};
|
"as" {DEBUG("\"%s\" tokenized with \'KeyAs'", yytext); return (KeyAs);};
|
||||||
|
"to" {DEBUG("\"%s\" tokenized with \'KeyTo'", yytext); return (KeyTo);};
|
||||||
"short" {DEBUG("\"%s\" tokenized with \'KeyShort\'", yytext); return(KeyShort);};
|
"short" {DEBUG("\"%s\" tokenized with \'KeyShort\'", yytext); return(KeyShort);};
|
||||||
"long" {DEBUG("\"%s\" tokenized with \'KeyLong\'", yytext); return(KeyLong);};
|
"long" {DEBUG("\"%s\" tokenized with \'KeyLong\'", yytext); return(KeyLong);};
|
||||||
"half" {DEBUG("\"%s\" tokenized with \'KeyHalf\'", yytext); return(KeyHalf);};
|
"half" {DEBUG("\"%s\" tokenized with \'KeyHalf\'", yytext); return(KeyHalf);};
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
%token KeyFloat
|
%token KeyFloat
|
||||||
%token KeySelf
|
%token KeySelf
|
||||||
%token KeyAs
|
%token KeyAs
|
||||||
|
%token KeyTo
|
||||||
%token <string> ValInt
|
%token <string> ValInt
|
||||||
%token <string> Ident
|
%token <string> Ident
|
||||||
%token <string> ValFloat
|
%token <string> ValFloat
|
||||||
|
@ -128,7 +129,7 @@
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%left OpNot OpBitnot
|
%left OpNot OpBitnot
|
||||||
%left KeyAs
|
%left KeyAs KeyTo
|
||||||
%left '(' ')'
|
%left '(' ')'
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
@ -154,6 +155,7 @@ expr: ValFloat {$$ = AST_new_node(AST_Float, $1);}
|
||||||
| boxselfaccess{$$ = $1;}
|
| boxselfaccess{$$ = $1;}
|
||||||
| typecast{$$ = $1;}
|
| typecast{$$ = $1;}
|
||||||
| reinterpretcast{$$ = $1;}
|
| reinterpretcast{$$ = $1;}
|
||||||
|
| '(' expr ')' {$$=$2;}
|
||||||
|
|
||||||
exprlist: expr ',' exprlist {AST_push_node($3, $1);
|
exprlist: expr ',' exprlist {AST_push_node($3, $1);
|
||||||
$$ = $3;}
|
$$ = $3;}
|
||||||
|
@ -289,9 +291,9 @@ typecast: expr KeyAs type %prec KeyAs {AST_NODE_PTR cast = AST_new_node(AST_Typ
|
||||||
$$ = cast;
|
$$ = cast;
|
||||||
DEBUG("Type-Cast"); };
|
DEBUG("Type-Cast"); };
|
||||||
|
|
||||||
reinterpretcast: '(' type ')' expr { AST_NODE_PTR cast = AST_new_node(AST_Transmute, NULL);
|
reinterpretcast: expr KeyTo type %prec KeyTo { AST_NODE_PTR cast = AST_new_node(AST_Transmute, NULL);
|
||||||
AST_push_node(cast, $4);
|
AST_push_node(cast, $1);
|
||||||
AST_push_node(cast, $2);
|
AST_push_node(cast, $3);
|
||||||
$$ = cast;
|
$$ = cast;
|
||||||
DEBUG("Reinterpret-Cast"); };
|
DEBUG("Reinterpret-Cast"); };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue