From: Jordan Date: Thu, 15 Dec 2016 22:43:35 +0000 (-0800) Subject: fixed parser bugs X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=commitdiff_plain;h=c6453f4b6219125bf45a61cde2f44bd7a3154e17 fixed parser bugs --- diff --git a/src/lexer.c b/src/lexer.c index 1550db9..b2bb535 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -28,7 +28,7 @@ #include /* Local */ -#include "parser.tab.h" +#include "src/parser.tab.h" #ifndef DE_STACKSIZE #define DE_STACKSIZE 1024 #endif diff --git a/src/lexer_lex.rl b/src/lexer_lex.rl index 5e395d0..22320d0 100755 --- a/src/lexer_lex.rl +++ b/src/lexer_lex.rl @@ -1,8 +1,8 @@ /* Ragel State Machine for tokenizing text */ #include #include -#include -#include +#include "apc.h" +#include "parser.tab.h" int ipow(int, int); diff --git a/src/parser.y b/src/parser.y index 6fe0969..85c6c50 100644 --- a/src/parser.y +++ b/src/parser.y @@ -30,7 +30,6 @@ %} %define parse.error verbose %define lr.type ielr -%glr-parser %union { int ref; @@ -58,7 +57,6 @@ %token WIDTH %token D %token NAME -%token SHIFT //nonterminals %type ref_id /* Syntax Directed Translation Scheme of the APC grammar */ @@ -117,7 +115,7 @@ set_namelist MOPEN map ; map: -NAME NUM NUM PATH {insert_map($1, 0, $3, $4, 0, $5);}; +NAME NUM NUM PATH {insert_map(0, $1, $2, $3, 0, $4);}; | NAME PATH {insert_map($1, 0, 0, 0, 0, $2);}; | NAME D PATH {insert_map($1, $2, 0, 0, 0, $3);}; | NAME D NUM NUM PATH {insert_map($1, $2, $3, $4, 0, $5);}; @@ -129,10 +127,10 @@ NAME NUM NUM PATH {insert_map($1, 0, $3, $4, 0, $5);} //shift list_namelist name > reduce mlink mlink: -MOPEN LINK NAME LINK link_namelist PATH {insert_mlink($4, 0); }; +MOPEN LINK NAME LINK link_namelist PATH {insert_mlink($3, 0); }; | MOPEN LINK link_namelist PATH {insert_mlink(NULL, 0); }; -| MOPEN LINK ref_id PATH {insert_mlink(NULL, $4); }; -| MOPEN LINK NAME LINK ref_id PATH {insert_mlink($4,$6); }; +| MOPEN LINK ref_id PATH {insert_mlink(NULL, $3); }; +| MOPEN LINK NAME LINK ref_id PATH {insert_mlink($3,$5); }; ; //shift list_namelist name > reduce vlink