include lex
This commit is contained in:
@ -1,2 +0,0 @@
|
||||
/* Code Generation File - Contains functions to generate assembly code */
|
||||
|
@ -87,6 +87,7 @@
|
||||
%token RESERVE 613
|
||||
%token RELEASE 614
|
||||
%token COMMENT 700
|
||||
%token INCLUDE 901
|
||||
|
||||
//precedence order
|
||||
%left ASSIGN
|
||||
@ -106,6 +107,7 @@
|
||||
|
||||
program:
|
||||
prototype_or_definition_list
|
||||
| include_list prototype_or_definition_list
|
||||
;
|
||||
|
||||
|
||||
@ -123,7 +125,19 @@ prototype_or_definition_list:
|
||||
|
||||
prototype:
|
||||
L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID
|
||||
;
|
||||
|
||||
|
||||
|
||||
include_list:
|
||||
include_statement SEMI_COLON include_list
|
||||
| include_statement
|
||||
;
|
||||
|
||||
|
||||
|
||||
include_statement:
|
||||
INCLUDE C_STRING SEMI_COLON
|
||||
;
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
||||
|
||||
%%
|
||||
|
||||
"#include" { if(tok_flag != NULL) {print_tok(INCLUDE);} incr(line_number,column_number,INCLUDE); return INCLUDE; }
|
||||
|
||||
"integer" { if(tok_flag != NULL) {print_tok(T_INTEGER);} incr(line_number,column_number,T_INTEGER); yylval.tn = integ; return T_INTEGER; }
|
||||
"address" { if(tok_flag != NULL) {print_tok(T_ADDRESS);} incr(line_number,column_number,T_ADDRESS); yylval.tn = addr; return T_ADDRESS; }
|
||||
"Boolean" { if(tok_flag != NULL) {print_tok(T_INTEGER);} incr(line_number,column_number,T_INTEGER); yylval.tn = boo; return T_BOOLEAN; }
|
||||
|
@ -56,4 +56,5 @@
|
||||
// comments
|
||||
#define COMMENT 700
|
||||
//Additional tokens
|
||||
#define ACCESS 801
|
||||
#define ACCESS 801
|
||||
#define INCLUDE 901
|
4
tests/sprint1/test/sp1_include.alpha
Normal file
4
tests/sprint1/test/sp1_include.alpha
Normal file
@ -0,0 +1,4 @@
|
||||
(* TEST: [-tok -asc -tc] *)
|
||||
#include "alpha.h";
|
||||
#include "alpha.h";
|
||||
#include "alpha.h";
|
Reference in New Issue
Block a user