diff --git a/src/ast/ast.h b/src/ast/ast.h index 5c71d2c..a7be0be 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -79,6 +79,7 @@ enum AST_SyntaxElement_t { AST_AddressOf, AST_Dereference, AST_Reference, + AST_Include, AST_ELEMENT_COUNT }; diff --git a/src/lex/lexer.l b/src/lex/lexer.l index bfde8ff..e955b0e 100644 --- a/src/lex/lexer.l +++ b/src/lex/lexer.l @@ -81,6 +81,7 @@ "!" {DEBUG("\"%s\" tokenized with \'OpBitnot\'", yytext); return(OpBitnot);}; "^" {DEBUG("\"%s\" tokenized with \'OpBitxor\'", yytext); return(OpBitxor);}; "import" {DEBUG("\"%s\" tokenized with \'KeyImport\'", yytext); return(KeyImport);}; +"include" {DEBUG("\"%s\" tokenized with \'KeyInclude\'", yytext); return(KeyInclude);}; "silent" {DEBUG("\"%s\" tokenized with \'KeySilent\'", yytext); return(KeySilent);}; "box" {DEBUG("\"%s\" tokenized with \'KeyBox\'", yytext); return(KeyBox);}; "typeof" {DEBUG("\"%s\" tokenized with \'FunTypeof\'", yytext); return(FunTypeof);}; diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 70f3069..29dd70c 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -53,6 +53,7 @@ %type opbool %type opbit %type moduleimport +%type moduleinclude %type programbody %type fundef %type fundecl @@ -109,6 +110,7 @@ %token OpBitnot %token OpBitxor %token KeyImport +%token KeyInclude %token KeySilent %token KeyBox %token FunTypeof @@ -142,6 +144,7 @@ program: program programbody {AST_push_node(root, $2); | programbody {AST_push_node(root, $1);}; programbody: moduleimport {$$ = $1;} + | moduleinclude {$$ = $1;} | fundef{$$ = $1;} | fundecl{$$ = $1;} | box{$$ = $1;} @@ -328,6 +331,9 @@ funcall: Ident argumentlist {AST_NODE_PTR funcall = AST_new_node(new_loc(), AST_ moduleimport: KeyImport ValStr {$$ = AST_new_node(new_loc(), AST_Import, $2); DEBUG("Module-Import"); }; +moduleinclude: KeyInclude ValStr {$$ = AST_new_node(new_loc(), AST_Include, $2); + DEBUG("Module-Include"); }; + statementlist: statementlist statement {AST_push_node($1, $2); $$ = $1;} | statement {AST_NODE_PTR list = AST_new_node(new_loc(), AST_StmtList, NULL);