Replace EQUAL, PIPE and SEMICOLON tokens with their ASCII values
authorNick Downing <nick@ndcode.org>
Sat, 23 Oct 2021 00:32:24 +0000 (11:32 +1100)
committerNick Downing <nick@ndcode.org>
Sat, 23 Oct 2021 00:32:24 +0000 (11:32 +1100)
ndcode/piyacc/cli.py
ndcode/piyacc/parse-gram.y
ndcode/piyacc/scan-gram.l

index dda7f7e..3047cef 100755 (executable)
@@ -29,8 +29,8 @@ import os
 import sys
 from ndcode.piyacc import t_def
 from ndcode.piyacc import element
-from ndcode.piyacc import generate_bison
-from ndcode.piyacc import generate_py
+from ndcode.piyacc.generate_bison import generate_bison
+from ndcode.piyacc.generate_py import generate_py
 
 EXIT_SUCCESS = 0
 EXIT_FAILURE = 1
@@ -100,7 +100,7 @@ Runs the following steps:
   _ast.post_process()
   #element.serialize(_ast, 'b.xml', 'utf-8')
   #_ast = element.deserialize('b.xml', t_def.factory, 'utf-8')
-  (generate_py.generate_py if python else generate_bison.generate_bison)(
+  (generate_py if python else generate_bison)(
     _ast,
     _element,
     home_dir,
index d30e725..ec9a945 100644 (file)
 %token BRACKETED_ID    "[identifier]"
 %token CHAR            "char"
 %token EPILOGUE        "epilogue"
-%token EQUAL           "="
 %token ID              "identifier"
 %token ID_COLON        "identifier:"
 %token PERCENT_PERCENT "%%"
-%token PIPE            "|"
 %token PROLOGUE        "%{...%}"
-%token SEMICOLON       ";"
 %token TAG             "<tag>"
 %token TAG_ANY         "<*>"
 %token TAG_NONE        "<>"
@@ -299,7 +296,7 @@ prologue_declaration
   | %space (?E{t_def.AST.Section1.TokenTable}"%token-table")
   | %space (?E{t_def.AST.Section1.Verbose}"%verbose")
   | %space (?E{t_def.AST.Section1.YACC}"%yacc")
-  | /*FIXME: Err?  What is this horror doing here? */ ";"
+  | /*FIXME: Err?  What is this horror doing here? */ ';'
   ;
 
 params
@@ -507,8 +504,8 @@ grammar
    body of the grammar.  */
 rules_or_grammar_declaration
   : rules
-  | grammar_declaration ";"
-  | error ";"
+  | grammar_declaration ';'
+  | error ';'
     {
       #yyerrok
     }
@@ -520,8 +517,8 @@ rules
 
 rhses.1
   : %space (?E{t_def.AST.Production}rhs)
-  | rhses.1 "|" %space (?E{t_def.AST.Production}rhs)
-  | rhses.1 ";"
+  | rhses.1 '|' %space (?E{t_def.AST.Production}rhs)
+  | rhses.1 ';'
   ;
 
 %token PERCENT_EMPTY "%empty";
index 1f15aeb..ee7d75c 100644 (file)
@@ -248,9 +248,7 @@ eqopt    ([[:space:]]*=)?
 
   "%"{id}                      state.complain(y_tab.yylloc, state.complaint, 'invalid directive: {0:s}'.format(state.quote(yytext)))
 
-  "="                          return y_tab.EQUAL
-  "|"                          return y_tab.PIPE
-  ";"                          return y_tab.SEMICOLON
+  [=|;]                         return ord(yytext[0])
 
   (?E{t_def.AST.ID}{id}) {
     global id_loc, bracketed_id_str