|
|
@ -49,15 +49,18 @@ inline void conferror(YYLTYPE *locp, yyscan_t sc, const char * str) |
|
|
|
%token <str> IDENTIFIER |
|
|
|
%token <str> IDENTIFIER |
|
|
|
%token <str> STRING |
|
|
|
%token <str> STRING |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%left DELIM |
|
|
|
|
|
|
|
%precedence ASSIGN |
|
|
|
|
|
|
|
%precedence IDENTIFIER /* low-priority for just identifier */ |
|
|
|
%left '-' '+' |
|
|
|
%left '-' '+' |
|
|
|
%left '*' '/' |
|
|
|
%left '*' '/' |
|
|
|
%precedence UNARY /* negation--unary minus */ |
|
|
|
%precedence UNARY /* negation--unary minus */ |
|
|
|
%right '^' /* exponentiation */ |
|
|
|
%right '^' /* exponentiation */ |
|
|
|
%left '.' |
|
|
|
%left '.' |
|
|
|
|
|
|
|
%precedence OBRACE CBRACE |
|
|
|
|
|
|
|
|
|
|
|
%type <ob> longidentifier |
|
|
|
%type <ob> longidentifier |
|
|
|
%type <ob> expression |
|
|
|
%type <ob> expression |
|
|
|
%type <ob> call |
|
|
|
|
|
|
|
%type <ob> object |
|
|
|
%type <ob> object |
|
|
|
%type <ob> pair |
|
|
|
%type <ob> pair |
|
|
|
%type <ob> list |
|
|
|
%type <ob> list |
|
|
@ -115,23 +118,20 @@ object: |
|
|
|
STRING {COUT(DEBUG)<<" STRING\n"; $$=new ObjectString($1); delete $1;} |
|
|
|
STRING {COUT(DEBUG)<<" STRING\n"; $$=new ObjectString($1); delete $1;} |
|
|
|
| BOOL {COUT(DEBUG)<<" BOOL\n"; $$=new ObjectBool($1);} |
|
|
|
| BOOL {COUT(DEBUG)<<" BOOL\n"; $$=new ObjectBool($1);} |
|
|
|
| OBRACE list CBRACE {COUT(DEBUG)<<" OBRACE list CBRACE\n"; $$=$2;} |
|
|
|
| OBRACE list CBRACE {COUT(DEBUG)<<" OBRACE list CBRACE\n"; $$=$2;} |
|
|
|
| expression {COUT(DEBUG)<<" expression\n"; $$=$1;} |
|
|
|
| expression %prec ASSIGN {COUT(DEBUG)<<" expression\n"; $$=$1;} |
|
|
|
| pair {COUT(DEBUG)<<" pair\n"; $$=$1;} |
|
|
|
| pair {COUT(DEBUG)<<" pair\n"; $$=$1;} |
|
|
|
| OBRACE object CBRACE {COUT(DEBUG)<<" OBRACE object CBRACE\n"; $$=$2;} |
|
|
|
| OBRACE object CBRACE {COUT(DEBUG)<<" OBRACE object CBRACE\n"; $$=$2;} |
|
|
|
| object DELIM {COUT(DEBUG)<<" OBJECT DELIM\n"; $$=$1;} |
|
|
|
| object DELIM {COUT(DEBUG)<<" OBJECT DELIM\n"; $$=$1;} |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
call: |
|
|
|
|
|
|
|
IDENTIFIER OBRACE object CBRACE {COUT(DEBUG)<<" IDENTIFIER OBRACE object CBRACE\n"; $$=new OFunc($1,$3); delete $1;} |
|
|
|
|
|
|
|
| IDENTIFIER OBRACE list CBRACE {COUT(DEBUG)<<" IDENTIFIER OBRACE list CBRACE\n"; $$=new OFunc($1,$3); delete $1;} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
longidentifier: |
|
|
|
longidentifier: |
|
|
|
IDENTIFIER '.' IDENTIFIER {COUT(DEBUG)<<" IDENTIFIER DOT IDENTIFIER\n"; $$=new OFunc("GET",(new ObjectList(new OId($1)))->PushBack(new ObjectString($3))); delete $1; delete $3;} |
|
|
|
IDENTIFIER '.' IDENTIFIER {COUT(DEBUG)<<" IDENTIFIER DOT IDENTIFIER\n"; $$=new OFunc("GET",(new ObjectList(new OId($1)))->PushBack(new ObjectString($3))); delete $1; delete $3;} |
|
|
|
| longidentifier '.' IDENTIFIER {COUT(DEBUG)<<" longidentifier '.' IDENTIFIER\n"; $$=new OFunc("GET",(new ObjectList($1))->PushBack(new ObjectString($3))); delete $3;} |
|
|
|
| longidentifier '.' IDENTIFIER {COUT(DEBUG)<<" longidentifier '.' IDENTIFIER\n"; $$=new OFunc("GET",(new ObjectList($1))->PushBack(new ObjectString($3))); delete $3;} |
|
|
|
|
|
|
|
|
|
|
|
expression: |
|
|
|
expression: |
|
|
|
IDENTIFIER {COUT(DEBUG)<<" IDENTIFIER\n"; $$=new OId($1); delete $1;} |
|
|
|
IDENTIFIER {COUT(DEBUG)<<" IDENTIFIER\n"; $$=new OId($1); delete $1;} |
|
|
|
|
|
|
|
| IDENTIFIER OBRACE object CBRACE {COUT(DEBUG)<<" IDENTIFIER OBRACE object CBRACE\n"; $$=new OFunc($1,$3); delete $1;} |
|
|
|
|
|
|
|
| IDENTIFIER OBRACE list CBRACE {COUT(DEBUG)<<" IDENTIFIER OBRACE list CBRACE\n"; $$=new OFunc($1,$3); delete $1;} |
|
|
|
| longidentifier {COUT(DEBUG)<<" longidentifier\n"; $$=$1;} |
|
|
|
| longidentifier {COUT(DEBUG)<<" longidentifier\n"; $$=$1;} |
|
|
|
| REAL {COUT(DEBUG)<<" REAL\n"; $$=new ObjectReal($1);} |
|
|
|
| REAL {COUT(DEBUG)<<" REAL\n"; $$=new ObjectReal($1);} |
|
|
|
| INTEGER {COUT(DEBUG)<<" INTEGER\n"; $$=new ObjectInt($1);} |
|
|
|
| INTEGER {COUT(DEBUG)<<" INTEGER\n"; $$=new ObjectInt($1);} |
|
|
@ -143,5 +143,4 @@ expression: |
|
|
|
| '-' expression %prec UNARY {COUT(DEBUG)<<" unary -\n"; $$=new OFunc("NEG",$2);} |
|
|
|
| '-' expression %prec UNARY {COUT(DEBUG)<<" unary -\n"; $$=new OFunc("NEG",$2);} |
|
|
|
| '+' expression %prec UNARY {COUT(DEBUG)<<" unary +\n"; $$=new OFunc("POS",$2);} |
|
|
|
| '+' expression %prec UNARY {COUT(DEBUG)<<" unary +\n"; $$=new OFunc("POS",$2);} |
|
|
|
| OBRACE expression CBRACE {COUT(DEBUG)<<" OBRACE expression CBRACE\n"; $$=$2;} |
|
|
|
| OBRACE expression CBRACE {COUT(DEBUG)<<" OBRACE expression CBRACE\n"; $$=$2;} |
|
|
|
| call {COUT(DEBUG)<<" call\n"; $$=$1;} |
|
|
|
|
|
|
|
; |
|
|
|
; |
|
|
|