added util/refptr, tests/Initial.jtl, parser/parser.h, c_statement to grammar

git-svn-id: svn://anubis/jtlc/trunk@7 f5bc74b8-7b62-4e90-9214-7121d538519f
This commit is contained in:
josh committed 2010-01-12 21:30:34 +00:00
1 parent bb982b62b8
commit c9c59e41fc
7 files changed
+169 -6

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
#ifndef PARSER_H
#define PARSER_H
#include "util/refptr.h"
void parse(const char * fileName);
#endif
+1
View File
@@ -75,6 +75,7 @@ float return FLOAT;
double return DOUBLE;
/* keywords */
c return C;
import return IMPORT;
module return MODULE;
return return RETURN;
+10 -2
View File
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <iostream>
#include "parser.tab.hh" /* bison-generated header with YY[SL]TYPE */
#include "parser.h"
using namespace std;
#define yyerror(msg) errFunc(msg, &yylloc)
@@ -76,6 +77,7 @@ int yywrap()
%token DOUBLE;
/* keywords */
%token C;
%token IMPORT;
%token MODULE;
%token RETURN;
@@ -94,6 +96,7 @@ program_item: module_declaration
| import
| variable_declaration
| function
| c_statement
;
module_declaration: MODULE module_name SEMICOLON
@@ -177,10 +180,11 @@ type: primitive_type
;
statement: expression SEMICOLON
| return_statement SEMICOLON
| return_statement
| c_statement
;
return_statement: RETURN expression
return_statement: RETURN expression SEMICOLON
;
expression: assign_expr
@@ -193,6 +197,10 @@ assign_expr: lvalue ASSIGN expression
lvalue: IDENTIFIER
;
c_statement: C LPAREN STRING_LITERAL RPAREN SEMICOLON {
}
;
%%
void parse(const char * fileName)