Add bootstrap/n.sh test script, fix ../../bootstrap_bison.git/src/parse-gram.y
authorNick Downing <nick@ndcode.org>
Sat, 19 Jan 2019 10:49:19 +0000 (21:49 +1100)
committerNick Downing <nick@ndcode.org>
Sat, 19 Jan 2019 10:49:19 +0000 (21:49 +1100)
.gitignore
bootstrap/n.sh [new file with mode: 0755]
bootstrap/parse-gram.y
bootstrap/scan-gram.l
bootstrap/state.py

index 3d4aaf5..7e7d720 100644 (file)
@@ -2,6 +2,7 @@ __pycache__
 bootstrap/*.xml
 bootstrap/lex_yy.py
 bootstrap/lex_yy_code.py
+bootstrap/out
 bootstrap/y_tab.py
 lex-yacc-examples/*.c
 lex-yacc-examples/*.h
diff --git a/bootstrap/n.sh b/bootstrap/n.sh
new file mode 100755 (executable)
index 0000000..36871bd
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+if ! test -d out
+then
+  mkdir out
+  ../../bootstrap_bison.git/src/bison -o /dev/null ../tests/cal.y 2>out/cal.y.xml.ok
+  ../../bootstrap_bison.git/src/bison -o /dev/null ../../bootstrap_flex.git/src/parse.y 2>out/parse.y.xml.ok
+  ../../bootstrap_bison.git/src/bison ../../bootstrap_bison.git/src/parse-gram.y 2>out/parse-gram.y.xml.ok
+  rm parse-gram.output parse-gram.tab.c parse-gram.tab.h
+fi
+./markup.py <../tests/cal.y >out/cal.y.xml
+diff --unified out/cal.y.xml.ok out/cal.y.xml
+./markup.py <../../bootstrap_flex.git/src/parse.y >out/parse.y.xml
+diff --unified out/parse.y.xml.ok out/parse.y.xml
+./markup.py <../../bootstrap_bison.git/src/parse-gram.y >out/parse-gram.y.xml
+diff --unified out/parse-gram.y.xml.ok out/parse-gram.y.xml
index 8daa104..8782db7 100644 (file)
@@ -490,6 +490,7 @@ grammar_declaration
       lex_yy_code.yy_buffer_stack = [lex_yy_code.YYBufferState()]
       lex_yy_code.yytext = '' # fool unput()
       lex_yy_code.unput($2)
+      lex_yy_code.sc_context = lex_yy_code.SC_SYMBOL_ACTION # CODE_PROPS_SYMBOL_ACTION
       lex_yy_code.yylex()
       lex_yy_code.code_piece_append('</AST_Text>')
       lex_yy_code.code_piece_pack()
@@ -562,11 +563,11 @@ grammar_declaration
 code_props_type
   : "%destructor"
     {
-      $$ = destructor
+      $$ = state.destructor
     }
   | "%printer"
     {
-      $$ = printer
+      $$ = state.printer
     }
   ;
 
index af28282..9419da7 100644 (file)
@@ -172,7 +172,7 @@ eqopt    ([[:space:]]*=)?
   }
   "%prec"                      return y_tab.PERCENT_PREC
   "%precedence"                        return y_tab.PERCENT_PRECEDENCE
-  "%printer"                   return y_tab.PERCENT_PRy_tab.INTER
+  "%printer"                   return y_tab.PERCENT_PRINTER
   "%pure-parser" {
     y_tab.yylval = 'api.pure'
     return y_tab.PERCENT_FLAG
@@ -981,14 +981,14 @@ eqopt    ([[:space:]]*=)?
 #        pass
 #      return w - buf
 #  return bytes_read
-#
-#def scan_integer(number, base, loc):
-#  num = strtoul(number, None, base)
-#  if 0x7fffffff < num:
-#    state.complain(y_tab.yylloc, state.complaint, 'integer out of range: %s', quote(number))
-#    num = 0x7fffffff
-#  return num
-#
+
+def scan_integer(number, base, loc):
+  num = int(number, base)
+  if 0x7fffffff < num:
+    state.complain(y_tab.yylloc, state.complaint, 'integer out of range: %s', quote(number))
+    num = 0x7fffffff
+  return num
+
 #def convert_ucn_to_byte(ucn):
 #  code = strtoul(ucn + 2, None, 16)
 #  if 0x7f * 2 + 1 < code:
index 03591b7..f4eb74c 100644 (file)
@@ -69,3 +69,6 @@ right_assoc = 1
 left_assoc = 2
 non_assoc = 3
 precedence_assoc = 4
+
+destructor = 0
+printer = 1