diff options
-rw-r--r-- | mypc.c | 6 | ||||
-rw-r--r-- | pc.l | 15 | ||||
-rw-r--r-- | pc.y | 8 |
3 files changed, 29 insertions, 0 deletions
@@ -65,6 +65,12 @@ union YYSTYPE* y; fprintf(stderr, "[WHILE]"); } else if (d == DO){ fprintf(stderr, "[DO]"); + } else if (d == FOR){ + fprintf(stderr, "[FOR]"); + } else if (d == TO){ + fprintf(stderr, "[TO]"); + } else if (d == DT){ + fprintf(stderr, "[DOWNTO]"); } else if (d == NOT){ fprintf(stderr, "[NOT]"); } else if (d == DOTS){ @@ -104,6 +104,21 @@ id [A-Za-z][A-Za-z0-9_]* return DO; } +"for" { + debug_print(FOR, NULL); + return FOR; +} + +"to" { + debug_print(TO, NULL); + return TO; +} + +"downto" { + debug_print(DT, NULL); + return DT; +} + "not" { debug_print(NOT, NULL); return NOT; @@ -56,6 +56,7 @@ extern int yylex(); %token IF ELSE THEN %token WHILE DO +%token FOR TO DT %token FCALL PCALL %token ARRAY_ACCESS @@ -227,8 +228,15 @@ statement { $$ = mktree(WHILE, $2, $4); } + |FOR var ASSIGNOP expr TD expr DO statement + { + /*TODO design tree structure for FOR loops*/ + $$ = NULL; + } ; +TD: TO | DT; + var :ID { |