working on parser

git-svn-id: svn://anubis/fart/trunk@84 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-02-08 19:42:55 +00:00
parent 80004438be
commit ba7190d7d8
2 changed files with 18 additions and 13 deletions

View File

@ -4,6 +4,7 @@
%} %}
%% %%
\+ return PLUS; \+ return PLUS;
- return MINUS; - return MINUS;
\* return STAR; \* return STAR;
@ -28,12 +29,15 @@
\< return LESS; \< return LESS;
\> return GREATER; \> return GREATER;
0b[01]+ return BIN_NUMBER; [0-9]+ return DEC_NUMBER;
0x[0-9A-Fa-f]+ return HEX_NUMBER; [0-9]*\.[0-9]+ return REAL_NUMBER;
0[0-7]* return OCT_NUMBER;
[1-9][0-9]* return DEC_NUMBER;
camera return CAMERA;
color return COLOR;
position return POSITION;
scene return SCENE;
\n /* ignore newlines */ \n /* ignore newlines */
[ \t\v] /* ignore whitespace */ [ \t\v] /* ignore whitespace */
%% %%

View File

@ -46,21 +46,22 @@ int yywrap()
%token LESS; %token LESS;
%token GREATER; %token GREATER;
%token BIN_NUMBER;
%token HEX_NUMBER;
%token OCT_NUMBER;
%token DEC_NUMBER; %token DEC_NUMBER;
%token REAL_NUMBER;
%token CAMERA;
%token COLOR;
%token POSITION;
%token SCENE;
%% %%
program: /* empty */ scene: /* empty */
| number program { printf("Saw a number\n"); } | scene_spec { printf("Saw a number\n"); }
; ;
number: BIN_NUMBER number: DEC_NUMBER
| OCT_NUMBER | REAL_NUMBER
| DEC_NUMBER
| HEX_NUMBER
; ;
%% %%