summaryrefslogtreecommitdiff
path: root/Parser.y
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-15 21:16:26 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-15 21:16:26 +0800
commit41f6e75e3f26bdcccfcb3910f202452e14653826 (patch)
tree0076a928d4ac9737f8b83b7b6b0c055e5ff4f46a /Parser.y
parentd80958f987790f533f5048c2e0e8a1cd5fd9f5a1 (diff)
basic support of types
Diffstat (limited to 'Parser.y')
-rw-r--r--Parser.y22
1 files changed, 8 insertions, 14 deletions
diff --git a/Parser.y b/Parser.y
index 993867f..bcde931 100644
--- a/Parser.y
+++ b/Parser.y
@@ -7,8 +7,9 @@
#include "Location.hh"
#include "Node.hh"
+#include "Context.hh"
-namespace pcc {
+namespace pcc{
class Driver;
}
}
@@ -16,11 +17,12 @@ namespace pcc {
%locations
%param {pcc::Driver& driver}
+%param {pcc::Context* context}
-%code {
-#include "Driver.hh"
+%code{
+#define YY_DECL \
+ pcc::Parser::symbol_type yylex(pcc::Driver& driver, pcc::Context* context)
-#define YY_DECL pcc::Parser::symbol_type yylex(pcc::Driver& driver)
YY_DECL;
}
@@ -36,7 +38,7 @@ YY_DECL;
%token PROGRAM IDENTIFIER CONST VAR BEGINS ENDS FUNCTION FILE_END
%token IF THEN ELSE WHILE DO
%token BOOLEAN CHAR INTEGER REAL STRING
-%token ADD SUB MUL REAL_DIV DIV MOD EXP LT LE GT GE EQ NE
+%token ADD SUB MUL REAL_DIV DIV MOD LT LE GT GE EQ NE
%token AND NOT OR XOR
%token INTEGER_LITERAL REAL_LITERAL STRING_LITERAL BOOLEAN_LITERAL CHAR_LITERAL
@@ -166,15 +168,11 @@ l2_expression
;
l3_expression
- : l3_expression l4_operator l4_expression
- | l4_expression
-
-l4_expression
: lvalue
| function_call
| literal
| LPARENTHESIS expression RPARENTHESIS
- | l5_operator l4_expression
+ | l4_operator l3_expression
;
l1_operator
@@ -202,10 +200,6 @@ l3_operator
;
l4_operator
- : EXP
- ;
-
-l5_operator
: NOT
| ADD
| SUB