Mercurial > vba-clojure
view src/sdl/expr.y @ 319:92c47a9cdaea
adapting bootstrap to new util functions.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 03 Apr 2012 04:16:20 -0500 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 %{2 namespace std {3 #include <stdio.h>4 #include <memory.h>5 #include <stdlib.h>6 #include <string.h>7 }9 using namespace std;11 #include "System.h"12 #include "elf.h"13 #include "exprNode.h"15 extern int yyerror(char *);16 extern int yylex();17 extern char *yytext;20 //#define YYERROR_VERBOSE 121 //#define YYDEBUG 123 Node *result = NULL;24 %}26 %token TOKEN_IDENTIFIER TOKEN_DOT TOKEN_STAR TOKEN_ARROW TOKEN_ADDR27 %token TOKEN_SIZEOF TOKEN_NUMBER28 %left TOKEN_DOT TOKEN_ARROW '['29 %expect 630 %%32 final: expression { result = $1; }33 ;35 expression:36 simple_expression { $$ = $1; } |37 '(' expression ')' { $$ = $2; } |38 expression TOKEN_DOT ident { $$ = exprNodeDot($1, $3); } |39 expression TOKEN_ARROW ident { $$ = exprNodeArrow($1, $3); } |40 expression '[' number ']' { $$ = exprNodeArray($1, $3); }41 ;42 simple_expression:43 ident { $$ = $1; } |44 TOKEN_STAR expression { $$ = exprNodeStar($2); } |45 TOKEN_ADDR expression { $$ = exprNodeAddr($2); } |46 TOKEN_SIZEOF '(' expression ')' { $$ = exprNodeSizeof($3); }47 ;49 number:50 TOKEN_NUMBER { $$ = exprNodeNumber(); }51 ;53 ident:54 TOKEN_IDENTIFIER {$$ = exprNodeIdentifier(); }55 ;57 %%59 int yyerror(char *s)60 {61 return 0;62 }64 #ifndef SDL65 extern FILE *yyin;66 int main(int argc, char **argv)67 {68 // yydebug = 1;69 ++argv, --argc;70 if(argc > 0)71 yyin = fopen(argv[0], "r");72 else73 yyin = stdin;74 if(!yyparse())75 result->print();76 }77 #endif