Add /fix_bootstrap.sh and run it due to reserved ast and _ast in recent python3
authorNick Downing <nick@ndcode.org>
Mon, 13 Nov 2023 11:14:14 +0000 (22:14 +1100)
committerNick Downing <nick@ndcode.org>
Mon, 13 Nov 2023 11:14:14 +0000 (22:14 +1100)
20 files changed:
bootstrap_pilex/generate_flex.py
bootstrap_pilex/generate_py.py
bootstrap_pilex/lex_yy.py
bootstrap_pilex/parse.y
bootstrap_pilex/pilex.py
bootstrap_pilex/scan.l
bootstrap_pilex/xast.py [moved from bootstrap_pilex/ast.py with 98% similarity]
bootstrap_pilex/y_tab.py
bootstrap_piyacc/generate_bison.py
bootstrap_piyacc/generate_py.py
bootstrap_piyacc/lex_yy.py
bootstrap_piyacc/lex_yy_code.py
bootstrap_piyacc/lr1dfa.py
bootstrap_piyacc/parse-gram.y
bootstrap_piyacc/piyacc.py
bootstrap_piyacc/scan-code.l
bootstrap_piyacc/scan-gram.l
bootstrap_piyacc/xast.py [moved from bootstrap_piyacc/ast.py with 95% similarity]
bootstrap_piyacc/y_tab.py
fix_bootstrap.sh [new file with mode: 0755]

index b73f057..c45563a 100644 (file)
 import os
 import regex
 
-def generate_flex(_ast, _element, home_dir, skel_file, out_file):
+def generate_flex(_xast, _element, home_dir, skel_file, out_file):
   # generate group_ref_data which emulates the old way where
   # start = even, end = odd, remaining bits = flex rule index,
   # ignoring user-defined groups by putting start = end = -1:
   group_ref_data = []
-  for i in range(len(_ast.flex_rules)):
+  for i in range(len(_xast.flex_rules)):
     group_ref_data.extend(
-      [(-1, -1) for j in range(len(_ast.flex_rules[i].groups0))] +
+      [(-1, -1) for j in range(len(_xast.flex_rules[i].groups0))] +
       [(i * 2, i * 2 + 1)] +
-      [(-1, -1) for j in range(len(_ast.flex_rules[i].groups1))]
+      [(-1, -1) for j in range(len(_xast.flex_rules[i].groups1))]
     )
 
-  _nfa = _ast.to_nfa(group_ref_data)
+  _nfa = _xast.to_nfa(group_ref_data)
 
   # end of buffer expression (do here because only necessary for flex)
   eob_regex = regex.RegexGroup(children = [regex.RegexEmpty()])
   eob_groups = []
-  eob_regex.post_process(eob_groups, caseless = _ast[0].caseless)
+  eob_regex.post_process(eob_groups, caseless = _xast[0].caseless)
   assert len(eob_groups) == 1
   eob_regex.add_to_nfa(
     _nfa,
-    [(len(_ast.flex_rules) * 2, len(_ast.flex_rules) * 2 + 1)]
+    [(len(_xast.flex_rules) * 2, len(_xast.flex_rules) * 2 + 1)]
   )
 
   _flex_dfa = _nfa.to_dfa().to_flex_dfa()
@@ -47,9 +47,9 @@ def generate_flex(_ast, _element, home_dir, skel_file, out_file):
     skel_file = os.path.join(home_dir, 'skel/skel_flex.c')
   if out_file is None:
     out_file = (
-      _ast[0].outfile
-    if len(_ast[0].outfile) else
-      'lex.{0:s}.c'.format(_ast[0].prefix)
+      _xast[0].outfile
+    if len(_xast[0].outfile) else
+      'lex.{0:s}.c'.format(_xast[0].prefix)
     )
   with open(skel_file, 'r') as fin:
     with open(out_file, 'w+') as fout:
@@ -61,12 +61,12 @@ def generate_flex(_ast, _element, home_dir, skel_file, out_file):
 {0:s}/* GENERATE END */
 '''.format(
               ''
-            if _ast[0].prefix == 'yy' else
+            if _xast[0].prefix == 'yy' else
               ''.join(
                 [
                   '#define yy{0:s} {1:s}{2:s}\n'.format(
                     i,
-                    _ast[0].prefix,
+                    _xast[0].prefix,
                     i
                   )
                   for i in [
@@ -144,11 +144,11 @@ def generate_flex(_ast, _element, home_dir, skel_file, out_file):
 {0:s}/* GENERATE END */
 '''.format(
               ''
-            if _ast[0].yywrap else
+            if _xast[0].yywrap else
               '''#define {0:s}wrap() (/*CONSTCOND*/1)
 #define YY_SKIP_YYWRAP
 '''.format(
-                _ast[0].prefix
+                _xast[0].prefix
               )
             )
           )
@@ -170,7 +170,7 @@ static const flex_uint16_t yy_chk[] = {{{6:s}
 }};
 /* GENERATE END */
 '''.format(
-              len(_ast.actions_text),
+              len(_xast.actions_text),
               ','.join(
                 [
                   '\n\t{0:s}'.format(
@@ -256,7 +256,7 @@ static const flex_uint16_t yy_chk[] = {{{6:s}
             '''/* GENERATE SECTION1 BEGIN */
 {0:s}/* GENERATE END */
 '''.format(
-              ''.join([i.get_text() for i in _ast[0].code_blocks_text])
+              ''.join([i.get_text() for i in _xast[0].code_blocks_text])
             )
           )
         elif line == '/* GENERATE STARTCONDDECL */\n':
@@ -267,10 +267,10 @@ static const flex_uint16_t yy_chk[] = {{{6:s}
               ''.join(
                 [
                   '#define {0:s} {1:d}\n'.format(
-                    _ast.start_conditions[i].name,
+                    _xast.start_conditions[i].name,
                     i
                   )
-                  for i in range(len(_ast.start_conditions))
+                  for i in range(len(_xast.start_conditions))
                 ]
               )
             )
@@ -280,17 +280,17 @@ static const flex_uint16_t yy_chk[] = {{{6:s}
             '''/* GENERATE SECTION2INITIAL BEGIN */
 {0:s}/* GENERATE END */
 '''.format(
-              ''.join([i.get_text() for i in _ast[1].code_blocks_text])
+              ''.join([i.get_text() for i in _xast[1].code_blocks_text])
             )
           )
         elif line == '/* GENERATE SECTION2 */\n':
           eof_action_to_start_conditions = [
             [
               j
-              for j in range(len(_ast.start_conditions))
-              if _ast.start_conditions[j].eof_action == i
+              for j in range(len(_xast.start_conditions))
+              if _xast.start_conditions[j].eof_action == i
             ]
-            for i in range(len(_ast.eof_actions_text))
+            for i in range(len(_xast.eof_actions_text))
           ]
           #print('eof_action_to_start_conditions', eof_action_to_start_conditions)
           fout.write(
@@ -304,9 +304,9 @@ YY_RULE_SETUP
 {1:s}  YY_BREAK
 '''.format(
                     i,
-                    _ast.actions_text[i].get_text()
+                    _xast.actions_text[i].get_text()
                   )
-                  for i in range(len(_ast.actions_text))
+                  for i in range(len(_xast.actions_text))
                 ]
               ),
               ''.join(
@@ -315,14 +315,14 @@ YY_RULE_SETUP
                     ''.join(
                       [
                         '\t\t\tcase YY_STATE_EOF({0:s}):\n'.format(
-                          _ast.start_conditions[j].name
+                          _xast.start_conditions[j].name
                         )
                         for j in eof_action_to_start_conditions[i]
                       ]
                     ),
-                    _ast.eof_actions_text[i].get_text()
+                    _xast.eof_actions_text[i].get_text()
                   )
-                  for i in range(len(_ast.eof_actions_text))
+                  for i in range(len(_xast.eof_actions_text))
                   if len(eof_action_to_start_conditions[i]) > 0
                 ]
               )
@@ -333,11 +333,11 @@ YY_RULE_SETUP
             '''/* GENERATE SECTION3 BEGIN */
 {0:s}/* GENERATE END */
 '''.format(
-              '' if len(_ast) < 3 else _ast[2].get_text()
+              '' if len(_xast) < 3 else _xast[2].get_text()
             )
           )
         else:
-          if _ast[0].prefix != 'yy':
-            line = line.replace('yywrap', '{0:s}wrap'.format(_ast[0].prefix))
+          if _xast[0].prefix != 'yy':
+            line = line.replace('yywrap', '{0:s}wrap'.format(_xast[0].prefix))
           fout.write(line)
         line = fin.readline()
index ca0fe35..553d44f 100644 (file)
@@ -47,18 +47,18 @@ def text_to_python(text, indent):
   return ''.join(lines)
 
 # note: these routines are literally the same, but conceptually different,
-# because ast.Text and regex.Text are different and unrelated base classes
-def ast_text_to_python(ast_text, indent):
-  return text_to_python(ast_text.get_text(), indent)
+# because xast.Text and regex.Text are different and unrelated base classes
+def xast_text_to_python(xast_text, indent):
+  return text_to_python(xast_text.get_text(), indent)
 def regex_text_to_python(regex_text, indent):
   return text_to_python(regex_text.get_text(), indent)
 
-def generate_py(_ast, _element, home_dir, skel_file, out_file):
+def generate_py(_xast, _element, home_dir, skel_file, out_file):
   # generate group action function names (ref_data) and body text
   group_ref_data = []
   group_rules_text = []
   group_actions_text = []
-  for i in _ast.flex_rules:
+  for i in _xast.flex_rules:
     group_ref_data.extend(
       [
         (
@@ -162,12 +162,12 @@ yy_groups = [yy_group_text[:yy_group_stack[-1]]]
 yy_groups_by_name = {{}}
 yy_action = yy_action{0:d}
 '''.format(
-        _ast.default_action
+        _xast.default_action
       )
     )
   )
 
-  _dfa = _ast.to_nfa(group_ref_data).to_dfa()
+  _dfa = _xast.to_nfa(group_ref_data).to_dfa()
 
   if skel_file is None:
     skel_file = os.path.join(
@@ -176,9 +176,9 @@ yy_action = yy_action{0:d}
     )
   if out_file is None:
     out_file = (
-      _ast[0].outfile
-    if len(_ast[0].outfile) else
-      'lex_{0:s}.py'.format(_ast[0].prefix)
+      _xast[0].outfile
+    if len(_xast[0].outfile) else
+      'lex_{0:s}.py'.format(_xast[0].prefix)
     )
   with open(skel_file, 'r') as fin:
     with open(out_file, 'w+') as fout:
@@ -191,8 +191,8 @@ yy_action = yy_action{0:d}
 '''.format(
               ''.join(
                 [
-                  ast_text_to_python(i, '')
-                  for i in _ast[0].code_blocks_text
+                  xast_text_to_python(i, '')
+                  for i in _xast[0].code_blocks_text
                 ]
               )
             )
@@ -205,10 +205,10 @@ yy_action = yy_action{0:d}
               ''.join(
                 [
                   '{0:s} = {1:d}\n'.format(
-                    _ast.start_conditions[i].name,
+                    _xast.start_conditions[i].name,
                     i
                   )
-                  for i in range(len(_ast.start_conditions))
+                  for i in range(len(_xast.start_conditions))
                 ]
               )
             )
@@ -226,9 +226,9 @@ yy_action = yy_action{0:d}
 {1:s}  raise YYContinue()
 '''.format(
                     i,
-                    ast_text_to_python(_ast.actions_text[i], '  ')
+                    xast_text_to_python(_xast.actions_text[i], '  ')
                   )
-                  for i in range(len(_ast.actions_text))
+                  for i in range(len(_xast.actions_text))
                 ]
               ),
               ''.join(
@@ -271,15 +271,15 @@ yy_action = yy_action{0:d}
 {1:s}  return 0
 '''.format(
                     i,
-                    ast_text_to_python(_ast.eof_actions_text[i], '  ')
+                    xast_text_to_python(_xast.eof_actions_text[i], '  ')
                   )
-                  for i in range(len(_ast.eof_actions_text))
+                  for i in range(len(_xast.eof_actions_text))
                 ]
               ),
               ','.join(
                 [
                   '\n  yy_eof_action{0:d}'.format(i.eof_action)
-                  for i in _ast.start_conditions
+                  for i in _xast.start_conditions
                 ]
               )
             )
@@ -291,8 +291,8 @@ yy_action = yy_action{0:d}
 '''.format(
               ''.join(
                 [
-                  ast_text_to_python(i, '  ')
-                  for i in _ast[1].code_blocks_text
+                  xast_text_to_python(i, '  ')
+                  for i in _xast[1].code_blocks_text
                 ]
               )
             )
@@ -302,11 +302,11 @@ yy_action = yy_action{0:d}
             '''# GENERATE SECTION3 BEGIN
 {0:s}# GENERATE END
 '''.format(
-              '' if len(_ast) < 3 else ast_text_to_python(_ast[2], '')
+              '' if len(_xast) < 3 else xast_text_to_python(_xast[2], '')
             )
           )
         else:
-          #if _ast[0].prefix != 'yy':
-          #  line = line.replace('yywrap', '{0:s}wrap'.format(_ast[0].prefix))
+          #if _xast[0].prefix != 'yy':
+          #  line = line.replace('yywrap', '{0:s}wrap'.format(_xast[0].prefix))
           fout.write(line)
         line = fin.readline()
index e242d4d..6c684d4 100644 (file)
@@ -29,7 +29,7 @@ import element
 import sys
 
 # GENERATE SECTION1 BEGIN
-import ast
+import xast
 import regex
 import state
 import y_tab
@@ -222,8 +222,8 @@ def yy_action0():
   yy_push_state(CODEBLOCK)
   indented_code = True
   #add_action(yytext)
-  markup_push(ast.AST.Section1Or2.CodeBlock)
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Section1Or2.CodeBlock)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action1():
   #add_action('/*[' '[')
@@ -246,9 +246,9 @@ def yy_action5():
   #add_action('[' '[')
   yy_push_state(CODEBLOCK)
   indented_code = False
-  markup_push(ast.AST.Section1Or2.CodeBlock)
+  markup_push(xast.AST.Section1Or2.CodeBlock)
   markup_flush(len(yytext))
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action6():
   global brace_start_line, brace_depth
@@ -369,9 +369,9 @@ def yy_action38():
   #add_action(']' ']')
   #if not indented_code:
   #  line_directive_out(None, 0)
-  markup_pop() # ast.AST.Text
+  markup_pop() # xast.AST.Text
   markup_flush(len(yytext))
-  markup_pop() # ast.AST.Section1Or2.CodeBlock
+  markup_pop() # xast.AST.Section1Or2.CodeBlock
   raise YYContinue()
 def yy_action39():
   #add_action(yytext)
@@ -388,8 +388,8 @@ def yy_action41():
     #if not indented_code:
     #  line_directive_out(None, 0)
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.Text
-    markup_pop() # ast.AST.Section1Or2.CodeBlock
+    markup_pop() # xast.AST.Text
+    markup_pop() # xast.AST.Section1Or2.CodeBlock
   raise YYContinue()
 def yy_action42():
   global brace_depth
@@ -997,8 +997,8 @@ def yy_action131():
   yy_push_state(CODEBLOCK)
   indented_code = True
   #add_action(yytext)
-  markup_push(ast.AST.Section1Or2.CodeBlock)
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Section1Or2.CodeBlock)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action132():
   global indented_code
@@ -1015,8 +1015,8 @@ def yy_action132():
     yy_push_state(CODEBLOCK)
     indented_code = True
     #add_action(yytext)
-    markup_push(ast.AST.Section1Or2.CodeBlock)
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Section1Or2.CodeBlock)
+    markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action133():
   #add_action(yytext)
@@ -1035,9 +1035,9 @@ def yy_action136():
   bracelevel = 1
   BEGIN(PERCENT_BRACE_ACTION)
   markup_flush(len(yytext) - 2)
-  markup_push(ast.AST.Section1Or2.CodeBlock)
+  markup_push(xast.AST.Section1Or2.CodeBlock)
   markup_flush(2)
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action137():
   if not (state._sf_stk[-1] & 4):
@@ -1070,11 +1070,11 @@ def yy_action142():
   bracelevel = 1
   BEGIN(PERCENT_BRACE_ACTION)
   markup_flush(len(yytext) - 2)
-  markup_push(ast.AST.Section2.Rule.Action)
+  markup_push(xast.AST.Section2.Rule.Action)
   doing_rule_action = True
   state.in_rule = False
   markup_flush(2)
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action143():
   if state._sf_stk[-1] & 4:
@@ -1107,8 +1107,8 @@ def yy_action146():
       doing_rule_action = True
       state.in_rule = False
       markup_flush(len(yytext))
-      markup_push(ast.AST.Section2.Rule.Action)
-      markup_push(ast.AST.Text)
+      markup_push(xast.AST.Section2.Rule.Action)
+      markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action147():
   global bracelevel, doing_rule_action
@@ -1123,8 +1123,8 @@ def yy_action147():
       doing_rule_action = True
       state.in_rule = False
       markup_flush(len(yytext))
-      markup_push(ast.AST.Section2.Rule.Action)
-      markup_push(ast.AST.Text)
+      markup_push(xast.AST.Section2.Rule.Action)
+      markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action148():
   markup_flush(len(yytext) - 7)
@@ -1465,7 +1465,7 @@ def yy_action219():
 def yy_action220():
   global bracelevel
   bracelevel = 0
-  markup_pop() # ast.AST.Text
+  markup_pop() # xast.AST.Text
   raise YYContinue()
 def yy_action221():
   #add_action(yytext)
@@ -1496,10 +1496,10 @@ def yy_action225():
     markup_flush(len(yytext))
     markup_pop() # as below
     if doing_codeblock:
-      # ast.AST.Section1Or2.CodeBlock
+      # xast.AST.Section1Or2.CodeBlock
       doing_codeblock = False
     else:
-      # ast.AST.Section2.Rule.Action
+      # xast.AST.Section2.Rule.Action
       return ord('\n')
   raise YYContinue()
 def yy_action226():
@@ -1539,8 +1539,8 @@ def yy_action233():
       doing_rule_action = False
       #add_action('\tYY_BREAK]' ']\n')
       markup_flush(len(yytext))
-      markup_pop() # ast.AST.Text
-      markup_pop() # ast.AST.Section2.Rule.Action
+      markup_pop() # xast.AST.Text
+      markup_pop() # xast.AST.Section2.Rule.Action
       return ord('\n')
   raise YYContinue()
 def yy_action234():
@@ -1574,8 +1574,8 @@ def yy_action241():
     markup_flush(len(yytext))
     if doing_rule_action:
       doing_rule_action = False # Nick added, error in the original?
-      markup_pop() # ast.AST.Text
-      markup_pop() # ast.AST.Section2.Rule.Action
+      markup_pop() # xast.AST.Text
+      markup_pop() # xast.AST.Section2.Rule.Action
       return '\n'
   else:
     BEGIN(ACTION)
@@ -3029,7 +3029,7 @@ def yy_group2():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options
+    xast.AST.Section1.Options
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3041,7 +3041,7 @@ def yy_group3():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Array
+    xast.AST.Section1.Options.Array
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3053,7 +3053,7 @@ def yy_group4():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options
+    xast.AST.Section1.Options
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3065,7 +3065,7 @@ def yy_group5():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Array, value = True
+    xast.AST.Section1.Options.Array, value = True
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3080,7 +3080,7 @@ def yy_group7():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Name
+    xast.AST.Name
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3098,7 +3098,7 @@ def yy_group10():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.SevenBit
+    xast.AST.Section1.Options.SevenBit
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3113,7 +3113,7 @@ def yy_group12():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.SevenBit
+    xast.AST.Section1.Options.SevenBit
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3128,7 +3128,7 @@ def yy_group14():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Align
+    xast.AST.Section1.Options.Align
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3143,7 +3143,7 @@ def yy_group16():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.AlwaysInteractive
+    xast.AST.Section1.Options.AlwaysInteractive
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3158,7 +3158,7 @@ def yy_group18():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Array
+    xast.AST.Section1.Options.Array
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3173,7 +3173,7 @@ def yy_group20():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Backup
+    xast.AST.Section1.Options.Backup
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3188,7 +3188,7 @@ def yy_group22():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Interactive
+    xast.AST.Section1.Options.Interactive
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3203,7 +3203,7 @@ def yy_group24():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.BisonBridge
+    xast.AST.Section1.Options.BisonBridge
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3218,7 +3218,7 @@ def yy_group26():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.BisonLocations
+    xast.AST.Section1.Options.BisonLocations
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3233,7 +3233,7 @@ def yy_group28():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.CPlusPlus
+    xast.AST.Section1.Options.CPlusPlus
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3248,7 +3248,7 @@ def yy_group30():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Caseless
+    xast.AST.Section1.Options.Caseless
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3263,7 +3263,7 @@ def yy_group32():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Caseless
+    xast.AST.Section1.Options.Caseless
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3278,7 +3278,7 @@ def yy_group34():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Debug
+    xast.AST.Section1.Options.Debug
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3293,7 +3293,7 @@ def yy_group36():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Default
+    xast.AST.Section1.Options.Default
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3308,7 +3308,7 @@ def yy_group38():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.ECS
+    xast.AST.Section1.Options.ECS
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3323,7 +3323,7 @@ def yy_group40():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Fast
+    xast.AST.Section1.Options.Fast
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3338,7 +3338,7 @@ def yy_group42():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Full
+    xast.AST.Section1.Options.Full
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3353,7 +3353,7 @@ def yy_group44():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Input
+    xast.AST.Section1.Options.Input
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3368,7 +3368,7 @@ def yy_group46():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Interactive
+    xast.AST.Section1.Options.Interactive
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3383,7 +3383,7 @@ def yy_group48():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.LexCompat
+    xast.AST.Section1.Options.LexCompat
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3398,7 +3398,7 @@ def yy_group50():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.PosixCompat
+    xast.AST.Section1.Options.PosixCompat
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3413,7 +3413,7 @@ def yy_group52():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Line
+    xast.AST.Section1.Options.Line
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3428,7 +3428,7 @@ def yy_group54():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Main
+    xast.AST.Section1.Options.Main
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3443,7 +3443,7 @@ def yy_group56():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.MetaECS
+    xast.AST.Section1.Options.MetaECS
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3458,7 +3458,7 @@ def yy_group58():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.NeverInteractive
+    xast.AST.Section1.Options.NeverInteractive
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3473,7 +3473,7 @@ def yy_group60():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.PerfReport
+    xast.AST.Section1.Options.PerfReport
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3488,7 +3488,7 @@ def yy_group62():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Array
+    xast.AST.Section1.Options.Array
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3503,7 +3503,7 @@ def yy_group64():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Read
+    xast.AST.Section1.Options.Read
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3518,7 +3518,7 @@ def yy_group66():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Reentrant
+    xast.AST.Section1.Options.Reentrant
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3533,7 +3533,7 @@ def yy_group68():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Reject
+    xast.AST.Section1.Options.Reject
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3548,7 +3548,7 @@ def yy_group70():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Stack
+    xast.AST.Section1.Options.Stack
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3563,7 +3563,7 @@ def yy_group72():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.StdInit
+    xast.AST.Section1.Options.StdInit
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3578,7 +3578,7 @@ def yy_group74():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.StdOut
+    xast.AST.Section1.Options.StdOut
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3593,7 +3593,7 @@ def yy_group76():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.UniStd
+    xast.AST.Section1.Options.UniStd
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3608,7 +3608,7 @@ def yy_group78():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Unput
+    xast.AST.Section1.Options.Unput
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3623,7 +3623,7 @@ def yy_group80():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Verbose
+    xast.AST.Section1.Options.Verbose
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3638,7 +3638,7 @@ def yy_group82():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.Warn
+    xast.AST.Section1.Options.Warn
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3653,7 +3653,7 @@ def yy_group84():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYLineNo
+    xast.AST.Section1.Options.YYLineNo
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3668,7 +3668,7 @@ def yy_group86():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYMore
+    xast.AST.Section1.Options.YYMore
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3683,7 +3683,7 @@ def yy_group88():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYWrap
+    xast.AST.Section1.Options.YYWrap
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3698,7 +3698,7 @@ def yy_group90():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYPushState
+    xast.AST.Section1.Options.YYPushState
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3713,7 +3713,7 @@ def yy_group92():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYPopState
+    xast.AST.Section1.Options.YYPopState
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3728,7 +3728,7 @@ def yy_group94():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYTopState
+    xast.AST.Section1.Options.YYTopState
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3743,7 +3743,7 @@ def yy_group96():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYScanBuffer
+    xast.AST.Section1.Options.YYScanBuffer
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3758,7 +3758,7 @@ def yy_group98():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYScanBytes
+    xast.AST.Section1.Options.YYScanBytes
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3773,7 +3773,7 @@ def yy_group100():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYScanString
+    xast.AST.Section1.Options.YYScanString
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3788,7 +3788,7 @@ def yy_group102():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYAlloc
+    xast.AST.Section1.Options.YYAlloc
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3803,7 +3803,7 @@ def yy_group104():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYRealloc
+    xast.AST.Section1.Options.YYRealloc
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3818,7 +3818,7 @@ def yy_group106():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYFree
+    xast.AST.Section1.Options.YYFree
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3833,7 +3833,7 @@ def yy_group108():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetDebug
+    xast.AST.Section1.Options.YYGetDebug
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3848,7 +3848,7 @@ def yy_group110():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYSetDebug
+    xast.AST.Section1.Options.YYSetDebug
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3863,7 +3863,7 @@ def yy_group112():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetExtra
+    xast.AST.Section1.Options.YYGetExtra
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3878,7 +3878,7 @@ def yy_group114():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYSetExtra
+    xast.AST.Section1.Options.YYSetExtra
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3893,7 +3893,7 @@ def yy_group116():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetLeng
+    xast.AST.Section1.Options.YYGetLeng
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3908,7 +3908,7 @@ def yy_group118():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetText
+    xast.AST.Section1.Options.YYGetText
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3923,7 +3923,7 @@ def yy_group120():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetLineNo
+    xast.AST.Section1.Options.YYGetLineNo
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3938,7 +3938,7 @@ def yy_group122():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYSetLineNo
+    xast.AST.Section1.Options.YYSetLineNo
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3953,7 +3953,7 @@ def yy_group124():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetIn
+    xast.AST.Section1.Options.YYGetIn
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3968,7 +3968,7 @@ def yy_group126():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYSetIn
+    xast.AST.Section1.Options.YYSetIn
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3983,7 +3983,7 @@ def yy_group128():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetOut
+    xast.AST.Section1.Options.YYGetOut
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -3998,7 +3998,7 @@ def yy_group130():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYSetOut
+    xast.AST.Section1.Options.YYSetOut
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4013,7 +4013,7 @@ def yy_group132():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetLVal
+    xast.AST.Section1.Options.YYGetLVal
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4028,7 +4028,7 @@ def yy_group134():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYSetLVal
+    xast.AST.Section1.Options.YYSetLVal
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4043,7 +4043,7 @@ def yy_group136():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYGetLLoc
+    xast.AST.Section1.Options.YYGetLLoc
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4058,7 +4058,7 @@ def yy_group138():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.YYSetLLoc
+    xast.AST.Section1.Options.YYSetLLoc
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4076,7 +4076,7 @@ def yy_group141():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section1.Options.TablesVerify
+    xast.AST.Section1.Options.TablesVerify
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4091,7 +4091,7 @@ def yy_group143():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.String
+    xast.AST.String
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4103,7 +4103,7 @@ def yy_group144():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text
+    xast.AST.Text
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4124,7 +4124,7 @@ def yy_group148():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Section2.Rule.Action, continued = True
+    xast.AST.Section2.Rule.Action, continued = True
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -4169,7 +4169,7 @@ def yy_group160():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Name
+    xast.AST.Name
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
index 9de59de..cc6e452 100644 (file)
@@ -38,7 +38,7 @@
 
 
 %{
-  import ast
+  import xast
   import regex
   import state
 
@@ -67,7 +67,7 @@
 %%
 
 goal
-  : %space (?E{ast.AST.Section1}initlex sect1 %space) sect1end (?E{ast.AST.Section2}sect2 %space) sect2end initforrule
+  : %space (?E{xast.AST.Section1}initlex sect1 %space) sect1end (?E{xast.AST.Section2}sect2 %space) sect2end initforrule
     {
       #def_rule = None
       #pat = cclinit()
@@ -95,8 +95,8 @@ initlex
   ;
 
 sect1
-  : sect1 %space (?E{ast.AST.Section1.StartConditions, exclusive = xcluflg} startconddecl namelist1)
-  | sect1 %space (?E{ast.AST.Section1.Options}options)
+  : sect1 %space (?E{xast.AST.Section1.StartConditions, exclusive = xcluflg} startconddecl namelist1)
+  | sect1 %space (?E{xast.AST.Section1.Options}options)
   |
   | error
     {
@@ -115,7 +115,7 @@ sect1end
 
 /* Nick */
 sect2end
-  : SECTEND (?E{ast.AST.Section3}%space)
+  : SECTEND (?E{xast.AST.Section3}%space)
   |
   ;
 
@@ -157,30 +157,30 @@ optionlist
   ;
 
 option
-  : %space (?E{ast.AST.Section1.Options.OutFile}TOK_OUTFILE '=' NAME)
+  : %space (?E{xast.AST.Section1.Options.OutFile}TOK_OUTFILE '=' NAME)
     {
       #outfilename = xstrdup(nmstr)
       #did_outfilename = 1
     }
-  | %space (?E{ast.AST.Section1.Options.ExtraType}TOK_EXTRA_TYPE '=' NAME)
+  | %space (?E{xast.AST.Section1.Options.ExtraType}TOK_EXTRA_TYPE '=' NAME)
     {
       #extra_type = xstrdup(nmstr)
     }
-  | %space (?E{ast.AST.Section1.Options.Prefix}TOK_PREFIX '=' NAME)
+  | %space (?E{xast.AST.Section1.Options.Prefix}TOK_PREFIX '=' NAME)
     {
       #prefix = xstrdup(nmstr)
       #if strchr(prefix, ord('[')) or strchr(prefix, ord(']')):
       #  flexerror('Prefix must not contain [ or ]')
     }
-  | %space (?E{ast.AST.Section1.Options.YYClass}TOK_YYCLASS '=' NAME)
+  | %space (?E{xast.AST.Section1.Options.YYClass}TOK_YYCLASS '=' NAME)
     {
       #yyclass = xstrdup(nmstr)
     }
-  | %space (?E{ast.AST.Section1.Options.HeaderFile}TOK_HEADER_FILE '=' NAME)
+  | %space (?E{xast.AST.Section1.Options.HeaderFile}TOK_HEADER_FILE '=' NAME)
     {
       #headerfilename = xstrdup(nmstr)
     }
-  | %space (?E{ast.AST.Section1.Options.TablesFile}TOK_TABLES_FILE '=' NAME)
+  | %space (?E{xast.AST.Section1.Options.TablesFile}TOK_TABLES_FILE '=' NAME)
     {
       #tablesext = True
       #tablesfilename = xstrdup(nmstr)
@@ -190,11 +190,11 @@ option
   ;
 
 sect2
-  : sect2 %space (?E{ast.AST.Section2.Rule}scon initforrule flexrule '\n')
+  : sect2 %space (?E{xast.AST.Section2.Rule}scon initforrule flexrule '\n')
     {
       #scon_stk_ptr = $2
     }
-  | sect2 %space (?E{ast.AST.Section2.CompoundRule}scon '{' sect2 '}')
+  | sect2 %space (?E{xast.AST.Section2.CompoundRule}scon '{' sect2 '}')
     {
       #scon_stk_ptr = $2
     }
@@ -215,7 +215,7 @@ initforrule
   ;
 
 flexrule
-  : %space (?E{ast.AST.Section2.Rule.FLexRule, bol = True}'^' rule)
+  : %space (?E{xast.AST.Section2.Rule.FLexRule, bol = True}'^' rule)
     {
       #pat = $2
       #finish_rule(pat, variable_trail_rule, headcnt, trailcnt, previous_continued_action)
@@ -235,7 +235,7 @@ flexrule
       #  if performance_report > 1:
       #    pinpoint_message('\'^\' operator results in sub-optimal performance')
     }
-  | %space (?E{ast.AST.Section2.Rule.FLexRule}rule)
+  | %space (?E{xast.AST.Section2.Rule.FLexRule}rule)
     {
       #pat = $1
       #finish_rule(pat, variable_trail_rule, headcnt, trailcnt, previous_continued_action)
@@ -251,7 +251,7 @@ flexrule
       #      scset[i] = mkbranch(scset[i], pat)
       #    i += 1
     }
-  | %space (?E{ast.AST.Section2.Rule.EOFRule}EOF_OP)
+  | %space (?E{xast.AST.Section2.Rule.EOFRule}EOF_OP)
     {
       #if scon_stk_ptr > 0:
       #  build_eof_action()
@@ -280,11 +280,11 @@ scon_stk_ptr
   ;
 
 scon
-  : %space (?E{ast.AST.Section2.StartConditions}'<' scon_stk_ptr namelist2 '>')
+  : %space (?E{xast.AST.Section2.StartConditions}'<' scon_stk_ptr namelist2 '>')
     {
       #$$ = $2
     }
-  | %space (?E{ast.AST.Section2.StartConditions, wildcard = True}'<' '*' '>')
+  | %space (?E{xast.AST.Section2.StartConditions, wildcard = True}'<' '*' '>')
     {
       #$$ = scon_stk_ptr
       #i = 1
@@ -299,7 +299,7 @@ scon
       #    scon_stk[++scon_stk_ptr] = i
       #  i += 1
     }
-  | %space (?E{ast.AST.Section2.StartConditions})
+  | %space (?E{xast.AST.Section2.StartConditions})
     {
       #$$ = scon_stk_ptr
     }
index 9ad7112..61bc1fe 100755 (executable)
@@ -16,7 +16,7 @@
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 
-import ast
+import xast
 import element
 import generate_flex
 import generate_py
@@ -61,21 +61,21 @@ in_file = args[0]
 
 with open(in_file) as fin:
   if in_file[-4:] == '.xml':
-    _ast = element.deserialize(fin, ast.factory)
+    _xast = element.deserialize(fin, xast.factory)
   else:
     import lex_yy
     import state
     import y_tab
     state.infilename = in_file
     lex_yy.yyin = fin
-    _ast = y_tab.yyparse(ast.AST)
-#element.serialize(_ast, 'a.xml', 'utf-8')
-#_ast = element.deserialize('a.xml', ast.factory, 'utf-8')
-_ast.post_process()
-#element.serialize(_ast, 'b.xml', 'utf-8')
-#_ast = element.deserialize('b.xml', ast.factory, 'utf-8')
+    _xast = y_tab.yyparse(xast.AST)
+#element.serialize(_xast, 'a.xml', 'utf-8')
+#_xast = element.deserialize('a.xml', xast.factory, 'utf-8')
+_xast.post_process()
+#element.serialize(_xast, 'b.xml', 'utf-8')
+#_xast = element.deserialize('b.xml', xast.factory, 'utf-8')
 (generate_py.generate_py if python else generate_flex.generate_flex)(
-  _ast,
+  _xast,
   _element,
   home_dir,
   skel_file,
index 42c5315..bc2e69f 100644 (file)
@@ -1,7 +1,7 @@
 /* scan.l - scanner for flex input -*-C-*- */
 
 %{
-  import ast
+  import xast
   import regex
   import state
   import y_tab
@@ -81,8 +81,8 @@ M4QEND      "]""]"
     yy_push_state(CODEBLOCK)
     indented_code = True
     #add_action(yytext)
-    markup_push(ast.AST.Section1Or2.CodeBlock)
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Section1Or2.CodeBlock)
+    markup_push(xast.AST.Text)
   }
   ^"/*" {
     #add_action('/*[' '[')
@@ -99,9 +99,9 @@ M4QEND      "]""]"
     #add_action('[' '[')
     yy_push_state(CODEBLOCK)
     indented_code = False
-    markup_push(ast.AST.Section1Or2.CodeBlock)
+    markup_push(xast.AST.Section1Or2.CodeBlock)
     markup_flush(len(yytext))
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
   ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
     global brace_start_line, brace_depth
@@ -126,11 +126,11 @@ M4QEND      "]""]"
     return y_tab.SECTEND
   }
 
-  ^(?E{ast.AST.Section1.Options}(?E{ast.AST.Section1.Options.Array}"%pointer".*)){NL} {
+  ^(?E{xast.AST.Section1.Options}(?E{xast.AST.Section1.Options.Array}"%pointer".*)){NL} {
     #yytext_is_array = False
     state.linenum += 1
   }
-  ^(?E{ast.AST.Section1.Options}(?E{ast.AST.Section1.Options.Array, value = True}"%array".*)){NL} {
+  ^(?E{xast.AST.Section1.Options}(?E{xast.AST.Section1.Options.Array, value = True}"%array".*)){NL} {
     #yytext_is_array = True
     state.linenum += 1
   }
@@ -153,7 +153,7 @@ M4QEND      "]""]"
     BEGIN(PICKUPDEF)
   }
 
-  (?E{ast.AST.Name}{SCNAME}) {
+  (?E{xast.AST.Name}{SCNAME}) {
     state.nmstr = yytext
     return y_tab.NAME
   }
@@ -224,9 +224,9 @@ M4QEND      "]""]"
     #add_action(']' ']')
     #if not indented_code:
     #  line_directive_out(None, 0)
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.Section1Or2.CodeBlock
+    markup_pop() # xast.AST.Section1Or2.CodeBlock
   }
   [^\n%\[\]]*                  #add_action(yytext)
   .                            #add_action(yytext)
@@ -239,8 +239,8 @@ M4QEND      "]""]"
       #if not indented_code:
       #  line_directive_out(None, 0)
       markup_flush(len(yytext))
-      markup_pop() # ast.AST.Text
-      markup_pop() # ast.AST.Section1Or2.CodeBlock
+      markup_pop() # xast.AST.Text
+      markup_pop() # xast.AST.Section1Or2.CodeBlock
   }
 }
 
@@ -312,26 +312,26 @@ M4QEND      "]""]"
     option_sense = not option_sense
   }*/
 
-  (?E{ast.AST.Section1.Options.SevenBit}("no"*)7bit) {
+  (?E{xast.AST.Section1.Options.SevenBit}("no"*)7bit) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #csize = 128 if option_sense else 256
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.SevenBit}("no"*)8bit) {
+  (?E{xast.AST.Section1.Options.SevenBit}("no"*)8bit) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #csize = 256 if option_sense else 128
     yy_element_token[0].value = not option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  (?E{ast.AST.Section1.Options.Align}("no"*)align) {
+  (?E{xast.AST.Section1.Options.Align}("no"*)align) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #long_align = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.AlwaysInteractive}("no"*)always-interactive) {
+  (?E{xast.AST.Section1.Options.AlwaysInteractive}("no"*)always-interactive) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_ALWAYS_INTERACTIVE', None)
@@ -341,44 +341,44 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Array}("no"*)array) {
+  (?E{xast.AST.Section1.Options.Array}("no"*)array) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #yytext_is_array = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Backup}("no"*)backup) {
+  (?E{xast.AST.Section1.Options.Backup}("no"*)backup) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #backing_up_report = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Interactive}("no"*)batch) {
+  (?E{xast.AST.Section1.Options.Interactive}("no"*)batch) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #interactive = not option_sense
     yy_element_token[0].value = not option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.BisonBridge}("no"*)bison-bridge) {
+  (?E{xast.AST.Section1.Options.BisonBridge}("no"*)bison-bridge) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #bison_bridge_lval = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.BisonLocations}("no"*)bison-locations) {
+  (?E{xast.AST.Section1.Options.BisonLocations}("no"*)bison-locations) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if bison_bridge_lloc = option_sense:
     #  bison_bridge_lval = True
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.CPlusPlus}("no"*)"c++") {
+  (?E{xast.AST.Section1.Options.CPlusPlus}("no"*)"c++") {
     option_sense = (len(yy_groups[1]) & 2) == 0
     #C_plus_plus = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Caseless}("no"*)caseful|case-sensitive) {
+  (?E{xast.AST.Section1.Options.Caseless}("no"*)caseful|case-sensitive) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     if not option_sense:
       state._sf_stk[-1] |= 1
@@ -387,7 +387,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = not option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Caseless}("no"*)caseless|case-insensitive) {
+  (?E{xast.AST.Section1.Options.Caseless}("no"*)caseless|case-insensitive) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     if option_sense:
       state._sf_stk[-1] |= 1
@@ -396,70 +396,70 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Debug}("no"*)debug) {
+  (?E{xast.AST.Section1.Options.Debug}("no"*)debug) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #ddebug = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Default}("no"*)default) {
+  (?E{xast.AST.Section1.Options.Default}("no"*)default) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #spprdflt = not option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.ECS}("no"*)ecs) {
+  (?E{xast.AST.Section1.Options.ECS}("no"*)ecs) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #useecs = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Fast}("no"*)fast) {
+  (?E{xast.AST.Section1.Options.Fast}("no"*)fast) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #useecs = usemecs = False
     #use_read = fullspd = True
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Full}("no"*)full) {
+  (?E{xast.AST.Section1.Options.Full}("no"*)full) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #useecs = usemecs = False
     #use_read = fulltbl = True
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Input}("no"*)input) {
+  (?E{xast.AST.Section1.Options.Input}("no"*)input) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  action_define('YY_NO_INPUT', 1)
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Interactive}("no"*)interactive) {
+  (?E{xast.AST.Section1.Options.Interactive}("no"*)interactive) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #interactive = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.LexCompat}("no"*)lex-compat) {
+  (?E{xast.AST.Section1.Options.LexCompat}("no"*)lex-compat) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     state.lex_compat = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.PosixCompat}("no"*)posix-compat) {
+  (?E{xast.AST.Section1.Options.PosixCompat}("no"*)posix-compat) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     state.posix_compat = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Line}("no"*)line) {
+  (?E{xast.AST.Section1.Options.Line}("no"*)line) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #gen_line_dirs = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Main}("no"*)main) {
+  (?E{xast.AST.Section1.Options.Main}("no"*)main) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_MAIN', None)
@@ -470,13 +470,13 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.MetaECS}("no"*)meta-ecs) {
+  (?E{xast.AST.Section1.Options.MetaECS}("no"*)meta-ecs) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #usemecs = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.NeverInteractive}("no"*)never-interactive) {
+  (?E{xast.AST.Section1.Options.NeverInteractive}("no"*)never-interactive) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NEVER_INTERACTIVE', None)
@@ -486,37 +486,37 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.PerfReport}("no"*)perf-report) {
+  (?E{xast.AST.Section1.Options.PerfReport}("no"*)perf-report) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #performance_report += 1 if option_sense else -1
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Array}("no"*)pointer) {
+  (?E{xast.AST.Section1.Options.Array}("no"*)pointer) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #yytext_is_array = not option_sense
     yy_element_token[0].value = not option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Read}("no"*)read) {
+  (?E{xast.AST.Section1.Options.Read}("no"*)read) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #use_read = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Reentrant}("no"*)reentrant) {
+  (?E{xast.AST.Section1.Options.Reentrant}("no"*)reentrant) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #reentrant = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Reject}("no"*)reject) {
+  (?E{xast.AST.Section1.Options.Reject}("no"*)reject) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #reject_really_used = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Stack}("no"*)stack) {
+  (?E{xast.AST.Section1.Options.Stack}("no"*)stack) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_STACK_USED', None)
@@ -525,26 +525,26 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.StdInit}("no"*)stdinit) {
+  (?E{xast.AST.Section1.Options.StdInit}("no"*)stdinit) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #do_stdinit = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.StdOut}("no"*)stdout) {
+  (?E{xast.AST.Section1.Options.StdOut}("no"*)stdout) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #use_stdout = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.UniStd}("no"*)unistd) {
+  (?E{xast.AST.Section1.Options.UniStd}("no"*)unistd) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  action_define('YY_NO_UNISTD_H', 1)
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Unput}("no"*)unput) {
+  (?E{xast.AST.Section1.Options.Unput}("no"*)unput) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_UNPUT', None)
@@ -553,19 +553,19 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Verbose}("no"*)verbose) {
+  (?E{xast.AST.Section1.Options.Verbose}("no"*)verbose) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #printstats = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.Warn}("no"*)warn) {
+  (?E{xast.AST.Section1.Options.Warn}("no"*)warn) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #nowarn = not option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYLineNo}("no"*)yylineno) {
+  (?E{xast.AST.Section1.Options.YYLineNo}("no"*)yylineno) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #do_yylineno = option_sense
     #if option_sense:
@@ -575,20 +575,20 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYMore}("no"*)yymore) {
+  (?E{xast.AST.Section1.Options.YYMore}("no"*)yymore) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #yymore_really_used = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYWrap}("no"*)yywrap) {
+  (?E{xast.AST.Section1.Options.YYWrap}("no"*)yywrap) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #do_yywrap = option_sense
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  (?E{ast.AST.Section1.Options.YYPushState}("no"*)yy_push_state) {
+  (?E{xast.AST.Section1.Options.YYPushState}("no"*)yy_push_state) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_PUSH_STATE', None)
@@ -597,7 +597,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYPopState}("no"*)yy_pop_state) {
+  (?E{xast.AST.Section1.Options.YYPopState}("no"*)yy_pop_state) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_POP_STATE', None)
@@ -606,7 +606,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYTopState}("no"*)yy_top_state) {
+  (?E{xast.AST.Section1.Options.YYTopState}("no"*)yy_top_state) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_TOP_STATE', None)
@@ -616,7 +616,7 @@ M4QEND      "]""]"
     return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  (?E{ast.AST.Section1.Options.YYScanBuffer}("no"*)yy_scan_buffer) {
+  (?E{xast.AST.Section1.Options.YYScanBuffer}("no"*)yy_scan_buffer) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SCAN_BUFFER', None)
@@ -625,7 +625,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYScanBytes}("no"*)yy_scan_bytes) {
+  (?E{xast.AST.Section1.Options.YYScanBytes}("no"*)yy_scan_bytes) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SCAN_BYTES', None)
@@ -634,7 +634,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYScanString}("no"*)yy_scan_string) {
+  (?E{xast.AST.Section1.Options.YYScanString}("no"*)yy_scan_string) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SCAN_STRING', None)
@@ -644,7 +644,7 @@ M4QEND      "]""]"
     return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  (?E{ast.AST.Section1.Options.YYAlloc}("no"*)yyalloc) {
+  (?E{xast.AST.Section1.Options.YYAlloc}("no"*)yyalloc) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_FLEX_ALLOC', None)
@@ -653,7 +653,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYRealloc}("no"*)yyrealloc) {
+  (?E{xast.AST.Section1.Options.YYRealloc}("no"*)yyrealloc) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_FLEX_REALLOC', None)
@@ -662,7 +662,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYFree}("no"*)yyfree) {
+  (?E{xast.AST.Section1.Options.YYFree}("no"*)yyfree) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_FLEX_FREE', None)
@@ -672,7 +672,7 @@ M4QEND      "]""]"
     return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  (?E{ast.AST.Section1.Options.YYGetDebug}("no"*)yyget_debug) {
+  (?E{xast.AST.Section1.Options.YYGetDebug}("no"*)yyget_debug) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_DEBUG', None)
@@ -681,7 +681,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYSetDebug}("no"*)yyset_debug) {
+  (?E{xast.AST.Section1.Options.YYSetDebug}("no"*)yyset_debug) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_DEBUG', None)
@@ -690,7 +690,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetExtra}("no"*)yyget_extra) {
+  (?E{xast.AST.Section1.Options.YYGetExtra}("no"*)yyget_extra) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_EXTRA', None)
@@ -699,7 +699,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYSetExtra}("no"*)yyset_extra) {
+  (?E{xast.AST.Section1.Options.YYSetExtra}("no"*)yyset_extra) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_EXTRA', None)
@@ -708,7 +708,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetLeng}("no"*)yyget_leng) {
+  (?E{xast.AST.Section1.Options.YYGetLeng}("no"*)yyget_leng) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LENG', None)
@@ -717,7 +717,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetText}("no"*)yyget_text) {
+  (?E{xast.AST.Section1.Options.YYGetText}("no"*)yyget_text) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_TEXT', None)
@@ -726,7 +726,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetLineNo}("no"*)yyget_lineno) {
+  (?E{xast.AST.Section1.Options.YYGetLineNo}("no"*)yyget_lineno) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LINENO', None)
@@ -735,7 +735,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYSetLineNo}("no"*)yyset_lineno) {
+  (?E{xast.AST.Section1.Options.YYSetLineNo}("no"*)yyset_lineno) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_LINENO', None)
@@ -744,7 +744,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetIn}("no"*)yyget_in) {
+  (?E{xast.AST.Section1.Options.YYGetIn}("no"*)yyget_in) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_IN', None)
@@ -753,7 +753,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYSetIn}("no"*)yyset_in) {
+  (?E{xast.AST.Section1.Options.YYSetIn}("no"*)yyset_in) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_IN', None)
@@ -762,7 +762,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetOut}("no"*)yyget_out) {
+  (?E{xast.AST.Section1.Options.YYGetOut}("no"*)yyget_out) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_OUT', None)
@@ -771,7 +771,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYSetOut}("no"*)yyset_out) {
+  (?E{xast.AST.Section1.Options.YYSetOut}("no"*)yyset_out) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_OUT', None)
@@ -780,7 +780,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetLVal}("no"*)yyget_lval) {
+  (?E{xast.AST.Section1.Options.YYGetLVal}("no"*)yyget_lval) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LVAL', None)
@@ -789,7 +789,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYSetLVal}("no"*)yyset_lval) {
+  (?E{xast.AST.Section1.Options.YYSetLVal}("no"*)yyset_lval) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_LVAL', None)
@@ -798,7 +798,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYGetLLoc}("no"*)yyget_lloc) {
+  (?E{xast.AST.Section1.Options.YYGetLLoc}("no"*)yyget_lloc) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LLOC', None)
@@ -807,7 +807,7 @@ M4QEND      "]""]"
     yy_element_token[0].value = option_sense
     return y_tab.TOK_OPTION_OTHER # Nick
   }
-  (?E{ast.AST.Section1.Options.YYSetLLoc}("no"*)yyset_lloc) {
+  (?E{xast.AST.Section1.Options.YYSetLLoc}("no"*)yyset_lloc) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_LLOC', None)
@@ -823,7 +823,7 @@ M4QEND      "]""]"
   yyclass              return y_tab.TOK_YYCLASS
   header(-file)?       return y_tab.TOK_HEADER_FILE
   tables-file          return y_tab.TOK_TABLES_FILE
-  (?E{ast.AST.Section1.Options.TablesVerify}("no"*)tables-verify) {
+  (?E{xast.AST.Section1.Options.TablesVerify}("no"*)tables-verify) {
     option_sense = (len(yy_groups[2]) & 2) == 0
     #tablesverify = option_sense
     #if not tablesext and option_sense:
@@ -832,7 +832,7 @@ M4QEND      "]""]"
     return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  (?E{ast.AST.String}\"(?E{ast.AST.Text}[^"\n]*)\") {
+  (?E{xast.AST.String}\"(?E{xast.AST.Text}[^"\n]*)\") {
     state.nmstr = yytext[1:-1]
     return y_tab.NAME
   }
@@ -870,8 +870,8 @@ M4QEND      "]""]"
     yy_push_state(CODEBLOCK)
     indented_code = True
     #add_action(yytext)
-    markup_push(ast.AST.Section1Or2.CodeBlock)
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Section1Or2.CodeBlock)
+    markup_push(xast.AST.Text)
   }
 
   ^{NOT_WS}.* {
@@ -889,8 +889,8 @@ M4QEND      "]""]"
       yy_push_state(CODEBLOCK)
       indented_code = True
       #add_action(yytext)
-      markup_push(ast.AST.Section1Or2.CodeBlock)
-      markup_push(ast.AST.Text)
+      markup_push(xast.AST.Section1Or2.CodeBlock)
+      markup_push(xast.AST.Text)
   }
 
   .                            #add_action(yytext)
@@ -916,9 +916,9 @@ M4QEND      "]""]"
     bracelevel = 1
     BEGIN(PERCENT_BRACE_ACTION)
     markup_flush(len(yytext) - 2)
-    markup_push(ast.AST.Section1Or2.CodeBlock)
+    markup_push(xast.AST.Section1Or2.CodeBlock)
     markup_flush(2)
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
 
   ^{OPTWS}"<" {
@@ -951,13 +951,13 @@ M4QEND      "]""]"
     bracelevel = 1
     BEGIN(PERCENT_BRACE_ACTION)
     markup_flush(len(yytext) - 2)
-    markup_push(ast.AST.Section2.Rule.Action)
+    markup_push(xast.AST.Section2.Rule.Action)
     doing_rule_action = True
     state.in_rule = False
     markup_flush(2)
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
-  {WS}(?E{ast.AST.Section2.Rule.Action, continued = True}"|".*{NL}) {
+  {WS}(?E{xast.AST.Section2.Rule.Action, continued = True}"|".*{NL}) {
     if state._sf_stk[-1] & 4:
       markup_yyless(yytext.index('|'))
     else:
@@ -990,8 +990,8 @@ M4QEND      "]""]"
         doing_rule_action = True
         state.in_rule = False
         markup_flush(len(yytext))
-        markup_push(ast.AST.Section2.Rule.Action)
-        markup_push(ast.AST.Text)
+        markup_push(xast.AST.Section2.Rule.Action)
+        markup_push(xast.AST.Text)
   }
 
   {OPTWS}{NL} {
@@ -1007,8 +1007,8 @@ M4QEND      "]""]"
         doing_rule_action = True
         state.in_rule = False
         markup_flush(len(yytext))
-        markup_push(ast.AST.Section2.Rule.Action)
-        markup_push(ast.AST.Text)
+        markup_push(xast.AST.Section2.Rule.Action)
+        markup_push(xast.AST.Text)
   }
 
   ^{OPTWS}"<<EOF>>" |
@@ -1125,7 +1125,7 @@ M4QEND      "]""]"
     BEGIN(CARETISBOL)
     return ord('>')
   }
-  (?E{ast.AST.Name}{SCNAME}) {
+  (?E{xast.AST.Name}{SCNAME}) {
     state.nmstr = yytext
     return y_tab.NAME
   }
@@ -1368,7 +1368,7 @@ M4QEND      "]""]"
   {OPTWS}"%}".* {
     global bracelevel
     bracelevel = 0
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
   }
 
   <ACTION>"/*" {
@@ -1402,10 +1402,10 @@ M4QEND      "]""]"
       markup_flush(len(yytext))
       markup_pop() # as below
       if doing_codeblock:
-        # ast.AST.Section1Or2.CodeBlock
+        # xast.AST.Section1Or2.CodeBlock
         doing_codeblock = False
       else:
-        # ast.AST.Section2.Rule.Action
+        # xast.AST.Section2.Rule.Action
         return ord('\n')
   }
 }
@@ -1444,8 +1444,8 @@ M4QEND      "]""]"
         doing_rule_action = False
         #add_action('\tYY_BREAK]' ']\n')
         markup_flush(len(yytext))
-        markup_pop() # ast.AST.Text
-        markup_pop() # ast.AST.Section2.Rule.Action
+        markup_pop() # xast.AST.Text
+        markup_pop() # xast.AST.Section2.Rule.Action
         return ord('\n')
   }
   .                            #add_action(yytext)
@@ -1476,8 +1476,8 @@ M4QEND      "]""]"
       markup_flush(len(yytext))
       if doing_rule_action:
         doing_rule_action = False # Nick added, error in the original?
-        markup_pop() # ast.AST.Text
-        markup_pop() # ast.AST.Section2.Rule.Action
+        markup_pop() # xast.AST.Text
+        markup_pop() # xast.AST.Section2.Rule.Action
         return '\n'
     else:
       BEGIN(ACTION)
similarity index 98%
rename from bootstrap_pilex/ast.py
rename to bootstrap_pilex/xast.py
index 6b46e89..17d57e6 100644 (file)
@@ -44,7 +44,7 @@ class Item(element.Element):
   # GENERATE END
   def post_process(
     self,
-    _ast,
+    _xast,
     section,
     name_to_start_condition,
     all_start_conditions,
@@ -241,7 +241,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         name_to_start_condition,
         all_start_conditions,
@@ -296,7 +296,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       name_to_start_condition,
       all_start_conditions,
       inclusive_start_conditions
@@ -305,7 +305,7 @@ class AST(element.Element):
       continued_action = False
       for i in self:
         continued_action = i.post_process(
-          _ast,
+          _xast,
           self,
           name_to_start_condition,
           all_start_conditions,
@@ -2307,7 +2307,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         name_to_start_condition,
         all_start_conditions,
@@ -2356,7 +2356,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         name_to_start_condition,
         all_start_conditions,
@@ -2367,11 +2367,11 @@ class AST(element.Element):
         for i in self:
           name = i.get_text()
           assert name not in name_to_start_condition
-          name_to_start_condition[name] = len(_ast.start_conditions)
-          all_start_conditions.add(len(_ast.start_conditions))
+          name_to_start_condition[name] = len(_xast.start_conditions)
+          all_start_conditions.add(len(_xast.start_conditions))
           if not self.exclusive:
-            inclusive_start_conditions.add(len(_ast.start_conditions))
-          _ast.start_conditions.append(
+            inclusive_start_conditions.add(len(_xast.start_conditions))
+          _xast.start_conditions.append(
             AST.StartCondition(
               name = name,
               exclusive = self.exclusive,
@@ -2956,7 +2956,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       name_to_start_condition,
       all_start_conditions,
       inclusive_start_conditions
@@ -3031,7 +3031,7 @@ class AST(element.Element):
       self.yywrap = True
       AST.Section1Or2.post_process(
         self,
-        _ast,
+        _xast,
         name_to_start_condition,
         all_start_conditions,
         inclusive_start_conditions
@@ -3199,7 +3199,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         name_to_start_condition,
         all_start_conditions,
@@ -3218,7 +3218,7 @@ class AST(element.Element):
             )
         for i in self[1:]:
           continued_action = i.post_process(
-            _ast,
+            _xast,
             section,
             name_to_start_condition,
             all_start_conditions,
@@ -3290,7 +3290,7 @@ class AST(element.Element):
         # GENERATE END
         def post_process(
           self,
-          _ast,
+          _xast,
           section,
           name_to_start_condition,
           all_start_conditions,
@@ -3303,18 +3303,18 @@ class AST(element.Element):
           assert not continued_action
           if len(start_conditions) == 0:
             for i in all_start_conditions:
-              if _ast.start_conditions[i].eof_action == 0:
-                _ast.start_conditions[i].eof_action = (
-                  len(_ast.eof_actions_text)
+              if _xast.start_conditions[i].eof_action == 0:
+                _xast.start_conditions[i].eof_action = (
+                  len(_xast.eof_actions_text)
                 )
           else:
             for i in start_conditions:
-              assert _ast.start_conditions[i].eof_action == 0
-              _ast.start_conditions[i].eof_action = (
-                len(_ast.eof_actions_text)
+              assert _xast.start_conditions[i].eof_action == 0
+              _xast.start_conditions[i].eof_action = (
+                len(_xast.eof_actions_text)
               )
           assert not action.continued
-          _ast.eof_actions_text.append(action[0])
+          _xast.eof_actions_text.append(action[0])
           return False # continued_action
  
       class FLexRule(element.Element):
@@ -3402,7 +3402,7 @@ class AST(element.Element):
         # GENERATE END
         def post_process(
           self,
-          _ast,
+          _xast,
           section,
           name_to_start_condition,
           all_start_conditions,
@@ -3418,23 +3418,23 @@ class AST(element.Element):
             inclusive_start_conditions
           ):
             if not self.bol:
-              _ast.start_conditions[i].rules.append(self)
-            _ast.start_conditions[i].bol_rules.append(self)
+              _xast.start_conditions[i].rules.append(self)
+            _xast.start_conditions[i].bol_rules.append(self)
           self.groups0 = []
           self[0].post_process(
             self.groups0,
-            caseless = _ast[0].caseless
+            caseless = _xast[0].caseless
           ) # regex
           self.groups1 = []
           self[1].post_process(
             self.groups1,
-            caseless = _ast[0].caseless
+            caseless = _xast[0].caseless
           ) # trailing context regex
-          self.action = len(_ast.actions_text)
+          self.action = len(_xast.actions_text)
           if action.continued:
             continued_action = True
           else:
-            _ast.actions_text.append(action[0])
+            _xast.actions_text.append(action[0])
             continued_action = False
             #def to_text(node):
             #  return ''.join(
@@ -3447,16 +3447,16 @@ class AST(element.Element):
             #  )
             #text = '{0:s}/{1:s}'.format(to_text(self[0]), to_text(self[1]))
             #element.set_text(
-            #  _ast.actions_text[-1],
+            #  _xast.actions_text[-1],
             #  0,
             #  'fprintf(stderr, "%d >>>%s<<< {0:s}\\n", yy_start, yytext);\n{1:s}'.format(
             #    text.replace('\\', '\\\\').replace('"', '\\"').replace('%', '%%'),
-            #    element.get_text(_ast.actions_text[-1], 0)
+            #    element.get_text(_xast.actions_text[-1], 0)
             #  )
             #)
-          _ast.flex_rules.append(self)
-          self.group_index = _ast.n_groups
-          _ast.n_groups += len(self.groups0) + 1 + len(self.groups1)
+          _xast.flex_rules.append(self)
+          self.group_index = _xast.n_groups
+          _xast.n_groups += len(self.groups0) + 1 + len(self.groups1)
           return continued_action
  
       # GENERATE ELEMENT() BEGIN
@@ -3483,7 +3483,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         name_to_start_condition,
         all_start_conditions,
@@ -3500,7 +3500,7 @@ class AST(element.Element):
               name_to_start_condition[i.get_text()]
             )
         return self[1].post_process(
-          _ast,
+          _xast,
           section,
           name_to_start_condition,
           all_start_conditions,
index 96ad587..994dba5 100644 (file)
@@ -43,7 +43,7 @@ class YYLTYPE:
     self.last_column = last_column
  
 # GENERATE SECTION1 BEGIN
-import ast
+import xast
 import regex
 import state
 
@@ -148,7 +148,7 @@ def yy_action1():
       children = [
         element.concatenate(
           yy_element_stack[-6:-3],
-          ast.AST.Section2
+          xast.AST.Section2
         )
       ]
     )
@@ -158,7 +158,7 @@ def yy_action1():
       children = [
         element.concatenate(
           yy_element_stack[-9:-5],
-          ast.AST.Section1
+          xast.AST.Section1
         )
       ]
     )
@@ -191,7 +191,7 @@ def yy_action3():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.StartConditions, exclusive = xcluflg
+          xast.AST.Section1.StartConditions, exclusive = xcluflg
         )
       ]
     )
@@ -204,7 +204,7 @@ def yy_action4():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.Options
+          xast.AST.Section1.Options
         )
       ]
     )
@@ -237,7 +237,7 @@ def yy_action8():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section3
+          xast.AST.Section3
         )
       ]
     )
@@ -285,7 +285,7 @@ def yy_action18():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1.Options.OutFile
+          xast.AST.Section1.Options.OutFile
         )
       ]
     )
@@ -299,7 +299,7 @@ def yy_action19():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1.Options.ExtraType
+          xast.AST.Section1.Options.ExtraType
         )
       ]
     )
@@ -312,7 +312,7 @@ def yy_action20():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1.Options.Prefix
+          xast.AST.Section1.Options.Prefix
         )
       ]
     )
@@ -327,7 +327,7 @@ def yy_action21():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1.Options.YYClass
+          xast.AST.Section1.Options.YYClass
         )
       ]
     )
@@ -340,7 +340,7 @@ def yy_action22():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1.Options.HeaderFile
+          xast.AST.Section1.Options.HeaderFile
         )
       ]
     )
@@ -353,7 +353,7 @@ def yy_action23():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1.Options.TablesFile
+          xast.AST.Section1.Options.TablesFile
         )
       ]
     )
@@ -370,7 +370,7 @@ def yy_action25():
       children = [
         element.concatenate(
           yy_element_stack[-7:],
-          ast.AST.Section2.Rule
+          xast.AST.Section2.Rule
         )
       ]
     )
@@ -383,7 +383,7 @@ def yy_action26():
       children = [
         element.concatenate(
           yy_element_stack[-7:],
-          ast.AST.Section2.CompoundRule
+          xast.AST.Section2.CompoundRule
         )
       ]
     )
@@ -414,7 +414,7 @@ def yy_action29():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section2.Rule.FLexRule, bol = True
+          xast.AST.Section2.Rule.FLexRule, bol = True
         )
       ]
     )
@@ -443,7 +443,7 @@ def yy_action30():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section2.Rule.FLexRule
+          xast.AST.Section2.Rule.FLexRule
         )
       ]
     )
@@ -468,7 +468,7 @@ def yy_action31():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section2.Rule.EOFRule
+          xast.AST.Section2.Rule.EOFRule
         )
       ]
     )
@@ -501,7 +501,7 @@ def yy_action34():
       children = [
         element.concatenate(
           yy_element_stack[-7:],
-          ast.AST.Section2.StartConditions
+          xast.AST.Section2.StartConditions
         )
       ]
     )
@@ -514,7 +514,7 @@ def yy_action35():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section2.StartConditions, wildcard = True
+          xast.AST.Section2.StartConditions, wildcard = True
         )
       ]
     )
@@ -544,7 +544,7 @@ def yy_action36():
       children = [
         element.concatenate(
           yy_element_stack[len(yy_element_stack):],
-          ast.AST.Section2.StartConditions
+          xast.AST.Section2.StartConditions
         )
       ]
     )
index 60b6bfe..ed093f2 100644 (file)
@@ -14,7 +14,7 @@
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 
-import ast
+import xast
 import numpy
 import os
 
@@ -31,14 +31,14 @@ escapes = {
 }
 
 def generate_bison(
-  _ast,
+  _xast,
   _element,
   home_dir,
   skel_file,
   out_file,
   defines_file = None
 ):
-  _lr1dfa = _ast.to_lr1().to_lalr1()
+  _lr1dfa = _xast.to_lr1().to_lalr1()
 
   # generate translate table for terminal symbols
   # this undoes yacc/bison's rather wasteful mapping of 0x00..0xff to literal
@@ -50,8 +50,8 @@ def generate_bison(
     2, # '$undefined'
     numpy.int16
   )
-  for i in _ast.symbols:
-    if i._type == ast.AST.Symbol.TYPE_TERMINAL:
+  for i in _xast.symbols:
+    if i._type == xast.AST.Symbol.TYPE_TERMINAL:
       for j in range(0, len(i.character_set), 2):
         translate_terminals[
           i.character_set[j]:i.character_set[j + 1]
@@ -69,8 +69,8 @@ def generate_bison(
     -1,
     numpy.int16
   )
-  for i in _ast.symbols:
-    if i._type == ast.AST.Symbol.TYPE_NONTERMINAL: 
+  for i in _xast.symbols:
+    if i._type == xast.AST.Symbol.TYPE_NONTERMINAL: 
       for j in range(0, len(i.character_set), 2):
         translate_nonterminals[
           i.character_set[j] - 1:i.character_set[j + 1] - 1
@@ -114,7 +114,7 @@ def generate_bison(
 #define YYPURE {0:d}
 /* GENERATE END */
 '''.format(
-                _ast[0].api_pure
+                _xast[0].api_pure
               ).replace('YY', type_prefix if is_header else 'YY').replace('yy', name_prefix if is_header else 'yy') # hack
             )
           elif line == '/* GENERATE TYPEPREFIX */\n':
@@ -128,17 +128,17 @@ def generate_bison(
                       [
                         '#define YY{0:s} {1:s}{2:s}\n'.format(
                           i,
-                          _ast[0].type_prefix,
+                          _xast[0].type_prefix,
                           i
                         )
                         for i in (
                           ['STYPE'] +
-                          (['LTYPE'] if _ast[0].locations else [])
+                          (['LTYPE'] if _xast[0].locations else [])
                         )
                       ]
                     )
                   )
-                if _ast[0].type_prefix != 'YY' else
+                if _xast[0].type_prefix != 'YY' else
                   ''
               )
             )
@@ -153,7 +153,7 @@ def generate_bison(
                       [
                         '#define yy{0:s} {1:s}{2:s}\n'.format(
                           i,
-                          _ast[0].name_prefix,
+                          _xast[0].name_prefix,
                           i
                         )
                         for i in (
@@ -161,15 +161,15 @@ def generate_bison(
                           ['parse', 'lex', 'error', 'debug', 'nerrs'] +
                           (
                             []
-                          if _ast[0].api_pure else
+                          if _xast[0].api_pure else
                             ['lval', 'char'] +
-                            (['lloc'] if _ast[0].locations else [])
+                            (['lloc'] if _xast[0].locations else [])
                           )
                         )
                       ]
                     )
                   )
-                if _ast[0].name_prefix != 'yy' else
+                if _xast[0].name_prefix != 'yy' else
                   ''
               )
             )
@@ -181,7 +181,7 @@ def generate_bison(
                 ''.join(
                   [
                     '{0:s}\n'.format(i.get_text())
-                    for i in _ast.top_text
+                    for i in _xast.top_text
                   ]
                 )
               )
@@ -194,7 +194,7 @@ def generate_bison(
                 ''.join(
                   [
                     '{0:s}\n'.format(i.get_text())
-                    for i in _ast.before_union_text
+                    for i in _xast.before_union_text
                   ]
                 )
               )
@@ -210,7 +210,7 @@ def generate_bison(
 #endif
 /* GENERATE END */
 '''.format(
-                int(_ast[0].error_verbose)
+                int(_xast[0].error_verbose)
               )
             )
           elif line == '/* GENERATE SECTION1REQUIRES */\n':
@@ -221,7 +221,7 @@ def generate_bison(
                 ''.join(
                   [
                     '{0:s}\n'.format(i.get_text())
-                    for i in _ast.requires_text
+                    for i in _xast.requires_text
                   ]
                 )
               )
@@ -237,7 +237,7 @@ extern int yydebug;
 #endif
 /* GENERATE END */
 '''.format(
-                int(_ast[0].debug)
+                int(_xast[0].debug)
               ).replace('YY', type_prefix).replace('yy', name_prefix) # hack
             )
           elif line == '/* GENERATE TOKENSEQUAL */\n':
@@ -248,9 +248,9 @@ extern int yydebug;
                 ','.join(
                   [
                     '\n    {0:s} = {1:d}'.format(i.name, i.character_set[0])
-                    for i in _ast.symbols[3:]
+                    for i in _xast.symbols[3:]
                     if (
-                      i._type == ast.AST.Symbol.TYPE_TERMINAL and
+                      i._type == xast.AST.Symbol.TYPE_TERMINAL and
                       len(i.name)
                     )
                   ]
@@ -265,9 +265,9 @@ extern int yydebug;
                 ''.join(
                   [
                     '#define {0:s} {1:d}\n'.format(i.name, i.character_set[0])
-                    for i in _ast.symbols[3:]
+                    for i in _xast.symbols[3:]
                     if (
-                      i._type == ast.AST.Symbol.TYPE_TERMINAL and
+                      i._type == xast.AST.Symbol.TYPE_TERMINAL and
                       len(i.name)
                     )
                   ]
@@ -291,11 +291,11 @@ typedef union YYSTYPE YYSTYPE;
                     ''.join(
                       [
                         '{0:s}\n'.format(i.get_text())
-                        for i in _ast.union_text
+                        for i in _xast.union_text
                       ]
                     )
                   )
-                if len(_ast.union_text) else
+                if len(_xast.union_text) else
                   '''typedef int YYSTYPE;
 '''
               ).replace('YY', type_prefix).replace('yy', name_prefix) # hack
@@ -318,7 +318,7 @@ struct YYLTYPE
 # define YYLTYPE_IS_TRIVIAL 1
 #endif
 '''
-                if _ast[0].locations else
+                if _xast[0].locations else
                   ''
               ).replace('YY', type_prefix).replace('yy', name_prefix) # hack
             )
@@ -330,7 +330,7 @@ struct YYLTYPE
                 ''.join(
                   [
                     '{0:s}\n'.format(i.get_text())
-                    for i in _ast.after_union_text
+                    for i in _xast.after_union_text
                   ]
                 )
               )
@@ -358,13 +358,13 @@ struct YYLTYPE
                     '\\\\x{0:02x}'.format(i.character_set[0])
                   )
                 )
-                for i in _ast.symbols
-                if i._type == ast.AST.Symbol.TYPE_TERMINAL
+                for i in _xast.symbols
+                if i._type == xast.AST.Symbol.TYPE_TERMINAL
               ] +
               [
                 '"{0:s}"'.format(i.name)
-                for i in _ast.symbols
-                if i._type == ast.AST.Symbol.TYPE_NONTERMINAL
+                for i in _xast.symbols
+                if i._type == xast.AST.Symbol.TYPE_NONTERMINAL
               ] +
               ['"$@{0:d}"'.format(i) for i in range(n_midrule_actions)] +
               ['YY_NULLPTR']
@@ -542,7 +542,7 @@ static const yytype_int16 yyr2[] =
                   ]
                 ),
                 # YYERROR_VERBOSE (strangely the defined value is repeated)
-                int(_ast[0].error_verbose),
+                int(_xast[0].error_verbose),
                 # yytname
                 ','.join(
                   ['\n  {0:s}'.format(', '.join(i)) for i in yytname_lines]
@@ -701,7 +701,7 @@ static const yytype_int16 yyr2[] =
                 ''.join(
                   [
                     '{0:s}\n'.format(i.get_text())
-                    for i in _ast.initial_action_text
+                    for i in _xast.initial_action_text
                   ]
                 ).replace('(yyval)', '(yylval').replace('(yyloc)', '(yylloc)') # hack
               )
@@ -731,7 +731,7 @@ static const yytype_int16 yyr2[] =
               '''/* GENERATE SECTION3 BEGIN */
 {0:s}/*GENERATE END */
 '''.format(
-                '' if len(_ast) < 3 else _ast[2].get_text()
+                '' if len(_xast) < 3 else _xast[2].get_text()
               )
             )
           else:
@@ -751,9 +751,9 @@ static const yytype_int16 yyr2[] =
   generate(
     skel_file,
     out_file,
-    _ast[0].type_prefix,
-    _ast[0].type_prefix,
-    _ast[0].name_prefix,
+    _xast[0].type_prefix,
+    _xast[0].type_prefix,
+    _xast[0].name_prefix,
     False
   )
   if defines_file is not None:
@@ -762,8 +762,8 @@ static const yytype_int16 yyr2[] =
         skel_file[:-2] if skel_file[-2:] == '.c' else skel_file
       ),
       defines_file,
-      _ast[0].type_prefix,
-      _ast[0].type_prefix,
-      _ast[0].name_prefix,
+      _xast[0].type_prefix,
+      _xast[0].type_prefix,
+      _xast[0].name_prefix,
       True
     )
index 1e6858a..41ad08a 100644 (file)
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 
-import ast
+import xast
 import os
 import wrap_repr
 
-def ast_text_to_python(ast_text, indent):
-  text = ast_text.get_text(True) # python
+def xast_text_to_python(xast_text, indent):
+  text = xast_text.get_text(True) # python
   text_strip = text.strip()
   if text_strip[:1] == '{' and text_strip[-1:] == '}':
     text = text_strip[1:-1]
@@ -48,14 +48,14 @@ def ast_text_to_python(ast_text, indent):
   return ''.join(lines)
 
 def generate_py(
-  _ast,
+  _xast,
   _element,
   home_dir,
   skel_file,
   out_file,
   defines_file = None
 ):
-  _lr1dfa = _ast.to_lr1().to_lalr1()
+  _lr1dfa = _xast.to_lr1().to_lalr1()
   assert _lr1dfa.eof_terminal == 0
   actions = [i for _, i in _lr1dfa.productions]
   #print('actions', actions)
@@ -82,20 +82,20 @@ def generate_py(
 '''.format(
               ''.join(
                 [
-                  ast_text_to_python(i, '')
-                  for i in _ast.requires_text
+                  xast_text_to_python(i, '')
+                  for i in _xast.requires_text
                 ]
               ),
               ''.join(
                 [
-                  ast_text_to_python(i, '')
-                  for i in _ast.before_union_text
+                  xast_text_to_python(i, '')
+                  for i in _xast.before_union_text
                 ]
               ),
               ''.join(
                 [
-                  ast_text_to_python(i, '')
-                  for i in _ast.after_union_text
+                  xast_text_to_python(i, '')
+                  for i in _xast.after_union_text
                 ]
               )
             )
@@ -108,9 +108,9 @@ def generate_py(
               ''.join(
                 [
                   '{0:s} = {1:d}\n'.format(i.name, i.character_set[0])
-                  for i in _ast.symbols[3:]
+                  for i in _xast.symbols[3:]
                   if (
-                    i._type == ast.AST.Symbol.TYPE_TERMINAL and
+                    i._type == xast.AST.Symbol.TYPE_TERMINAL and
                     len(i.name)
                   )
                 ]
@@ -124,8 +124,8 @@ YYDEBUG = {0:s}
 YYERROR_VERBOSE = {1:s}
 {2:s}{3:s}{4:s}# GENERATE END
 '''.format(
-              'True' if _ast[0].debug else 'False',
-              'True' if _ast[0].error_verbose else 'False',
+              'True' if _xast[0].debug else 'False',
+              'True' if _xast[0].error_verbose else 'False',
               ''.join(
                 [
                   '''def yy_action{0:d}():
@@ -164,7 +164,7 @@ YYERROR_VERBOSE = {1:s}
                           str(pos1) if pos1 else '',
                           str(pos0) if pos0 else 'len(yy_element_stack)',
                           str(pos1) if pos1 else '',
-                          ast_text_to_python(factory_text, '          ')
+                          xast_text_to_python(factory_text, '          ')
                         )
                         for pos0, pos1, factory_text in actions[i][1] # groups
                       ]
@@ -194,7 +194,7 @@ YYERROR_VERBOSE = {1:s}
                     (
                       '  pass\n'
                     if actions[i][4] is None else # last_action
-                      ast_text_to_python(actions[i][4], '  ')
+                      xast_text_to_python(actions[i][4], '  ')
                     )
                   )
                   for i in range(len(actions))
@@ -221,8 +221,8 @@ YYERROR_VERBOSE = {1:s}
 '''.format(
               ''.join(
                 [
-                  ast_text_to_python(i, '  ')
-                  for i in _ast.initial_action_text
+                  xast_text_to_python(i, '  ')
+                  for i in _xast.initial_action_text
                 ]
               ).replace('(yyval)', '(yylval').replace('(yyloc)', '(yylloc)') # hack
             )
@@ -232,7 +232,7 @@ YYERROR_VERBOSE = {1:s}
             '''# GENERATE SECTION3 BEGIN
 {0:s}# GENERATE END
 '''.format(
-              '' if len(_ast) < 3 else ast_text_to_python(_ast[2], '')
+              '' if len(_xast) < 3 else xast_text_to_python(_xast[2], '')
             )
           )
         else:
index 432d277..3759dad 100644 (file)
@@ -29,7 +29,7 @@ import element
 import sys
 
 # GENERATE SECTION1 BEGIN
-import ast
+import xast
 import state
 import y_tab
 
@@ -458,27 +458,27 @@ def yy_action69():
   token_start = y_tab.yylloc.start
   BEGIN(SC_ESCAPED_CHARACTER)
   markup_push(element.Element)
-  markup_push(ast.AST.Char)
+  markup_push(xast.AST.Char)
   markup_flush(len(yytext))
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action70():
   global token_start
   token_start = y_tab.yylloc.start
   BEGIN(SC_ESCAPED_STRING)
   markup_push(element.Element)
-  markup_push(ast.AST.String)
+  markup_push(xast.AST.String)
   markup_flush(len(yytext))
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action71():
   global code_start
   code_start = y_tab.yylloc.start
   BEGIN(SC_PROLOGUE)
   markup_push(element.Element)
-  markup_push(ast.AST.Section1.Prologue)
+  markup_push(xast.AST.Section1.Prologue)
   markup_flush(len(yytext))
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action72():
   global nesting, code_start
@@ -488,12 +488,12 @@ def yy_action72():
   BEGIN(SC_BRACED_CODE)
   markup_push(element.Element)
   # new way, includes braces, wrapped by <AST_Production_Action> later
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   markup_flush(len(yytext))
   # old way 
-  #markup_push(ast.AST.BracedCode)
+  #markup_push(xast.AST.BracedCode)
   #markup_flush(len(yytext))
-  #markup_push(ast.AST.Text)
+  #markup_push(xast.AST.Text)
   # to here
   raise YYContinue()
 def yy_action73():
@@ -502,9 +502,9 @@ def yy_action73():
   code_start = y_tab.yylloc.start
   BEGIN(SC_PREDICATE)
   markup_push(element.Element)
-  markup_push(ast.AST.BracedPredicate)
+  markup_push(xast.AST.BracedPredicate)
   markup_flush(len(yytext))
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action74():
   global nesting, code_start
@@ -514,7 +514,7 @@ def yy_action74():
   BEGIN(SC_ELEMENT_GROUP)
   markup_push(element.Element)
   markup_flush(len(yytext))
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action75():
   return ord(')')
@@ -531,9 +531,9 @@ def yy_action78():
   token_start = y_tab.yylloc.start
   BEGIN(SC_TAG)
   markup_push(element.Element)
-  markup_push(ast.AST.TagRef)
+  markup_push(xast.AST.TagRef)
   markup_flush(len(yytext))
-  markup_push(ast.AST.Text)
+  markup_push(xast.AST.Text)
   raise YYContinue()
 def yy_action79():
   global percent_percent_count
@@ -648,9 +648,9 @@ def yy_action95():
   y_tab.yylloc.start = token_start
   y_tab.yylval = gram_last_string
   BEGIN(INITIAL)
-  markup_pop() # ast.AST.Text
+  markup_pop() # xast.AST.Text
   markup_flush(len(yytext))
-  markup_pop() # ast.AST.String
+  markup_pop() # xast.AST.String
   markup_pop_token() # element.Element
   return y_tab.STRING
   raise YYContinue()
@@ -671,9 +671,9 @@ def yy_action97():
     y_tab.yylval = ord(gram_last_string[0])
   #del obstack_for_string[:]
   BEGIN(INITIAL)
-  markup_pop() # ast.AST.Text
+  markup_pop() # xast.AST.Text
   markup_flush(len(yytext))
-  markup_pop() # ast.AST.Char
+  markup_pop() # xast.AST.Char
   markup_pop_token() # element.Element
   return y_tab.CHAR
   raise YYContinue()
@@ -690,9 +690,9 @@ def yy_action99():
     y_tab.yylval = gram_last_string
     #del obstack_for_string[:]
     BEGIN(INITIAL)
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.TagRef
+    markup_pop() # xast.AST.TagRef
     markup_pop_token() # element.Element
     return y_tab.TAG
   obstack_for_string.append(yytext)
@@ -827,11 +827,11 @@ def yy_action126():
     BEGIN(INITIAL)
     # new way, includes braces, wrapped by <AST_Production_Action> later
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     # old way
-    #markup_pop() # ast.AST.Text
+    #markup_pop() # xast.AST.Text
     #markup_flush(len(yytext))
-    #markup_pop() # ast.AST.BracedCode
+    #markup_pop() # xast.AST.BracedCode
     # to here
     markup_pop_token() # element.Element
     return y_tab.BRACED_CODE
@@ -845,9 +845,9 @@ def yy_action127():
     y_tab.yylloc.start = code_start
     y_tab.yylval = gram_last_string
     BEGIN(INITIAL)
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.BracedPredicate
+    markup_pop() # xast.AST.BracedPredicate
     markup_pop_token() # element.Element
     return y_tab.BRACED_PREDICATE
   else:
@@ -864,7 +864,7 @@ def yy_action128():
     y_tab.yylval = gram_last_string
     #del obstack_for_string[:]
     BEGIN(INITIAL)
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     markup_flush(len(yytext))
     markup_pop_token() # element.Element
     return ord('(')
@@ -876,9 +876,9 @@ def yy_action129():
   y_tab.yylloc.start = code_start
   y_tab.yylval = gram_last_string
   BEGIN(INITIAL)
-  markup_pop() # ast.AST.Text
+  markup_pop() # xast.AST.Text
   markup_flush(len(yytext))
-  markup_pop() # ast.AST.Section1.Prologue
+  markup_pop() # xast.AST.Section1.Prologue
   markup_pop_token() # element.Element
   return y_tab.PROLOGUE
   raise YYContinue()
@@ -1579,7 +1579,7 @@ def yy_group5():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.ID
+    xast.AST.ID
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1609,7 +1609,7 @@ def yy_group12():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = int(yy_groups[2], 8)
+    xast.AST.Text.Escape, character = int(yy_groups[2], 8)
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1624,7 +1624,7 @@ def yy_group14():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = int(yy_groups[2], 16)
+    xast.AST.Text.Escape, character = int(yy_groups[2], 16)
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1639,7 +1639,7 @@ def yy_group16():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = 7
+    xast.AST.Text.Escape, character = 7
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1651,7 +1651,7 @@ def yy_group17():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = 8
+    xast.AST.Text.Escape, character = 8
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1663,7 +1663,7 @@ def yy_group18():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = 12
+    xast.AST.Text.Escape, character = 12
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1675,7 +1675,7 @@ def yy_group19():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = 10
+    xast.AST.Text.Escape, character = 10
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1687,7 +1687,7 @@ def yy_group20():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = 13
+    xast.AST.Text.Escape, character = 13
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1699,7 +1699,7 @@ def yy_group21():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = 9
+    xast.AST.Text.Escape, character = 9
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1711,7 +1711,7 @@ def yy_group22():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = 11
+    xast.AST.Text.Escape, character = 11
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1723,7 +1723,7 @@ def yy_group23():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = ord(yy_groups[2])
+    xast.AST.Text.Escape, character = ord(yy_groups[2])
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
@@ -1738,7 +1738,7 @@ def yy_group25():
     yy_group_stack[-1],
     yy_group_stack[-2],
     yy_element_stack.pop(),
-    ast.AST.Text.Escape, character = int(('' if yy_groups[3] is None else yy_groups[3]) + yy_groups[4], 16)
+    xast.AST.Text.Escape, character = int(('' if yy_groups[3] is None else yy_groups[3]) + yy_groups[4], 16)
   )
   yy_element_stack[-1].append(
     (yy_group_stack[-1], yy_group_stack[-2], yy_element)
index 01c8c3d..5b4006d 100644 (file)
@@ -29,7 +29,7 @@ import element
 import sys
 
 # GENERATE SECTION1 BEGIN
-import ast
+import xast
 
 sc_context = -1
 # GENERATE END
@@ -311,7 +311,7 @@ def yy_group0():
     yy_group_stack[-2],
     yy_element_stack.pop(),
     
-      ast.AST.Text.StackReference,
+      xast.AST.Text.StackReference,
       tag_name = '' if yy_groups[2] is None else yy_groups[2][1:-1],
       index = int(yy_groups[3])
     
@@ -333,7 +333,7 @@ def yy_group3():
     yy_group_stack[-2],
     yy_element_stack.pop(),
     
-      ast.AST.Text.StackLocation,
+      xast.AST.Text.StackLocation,
       index = int(yy_groups[2])
     
   )
@@ -351,7 +351,7 @@ def yy_group5():
     yy_group_stack[-2],
     yy_element_stack.pop(),
     
-      ast.AST.Text.ValueReference,
+      xast.AST.Text.ValueReference,
       tag_name = '' if yy_groups[2] is None else yy_groups[2][1:-1]
     
   )
@@ -369,7 +369,7 @@ def yy_group7():
     yy_group_stack[-2],
     yy_element_stack.pop(),
     
-      ast.AST.Text.ValueLocation
+      xast.AST.Text.ValueLocation
     
   )
   yy_element_stack[-1].append(
index 44dc2ed..e347ccb 100644 (file)
@@ -139,7 +139,7 @@ class LR1DFA:
     assert numpy.all(action_table != 0)
     action_table[action_table == 1] = len(self.states) << 1
     action_table[action_table == -1] = 0
-    mask = (action_table & 1).astype(numpy.bool)
+    mask = (action_table & 1).xastype(numpy.bool)
     action_table >>= 1
     action_table[mask] = -action_table[mask]
     assert numpy.all(goto_table != 0)
@@ -190,7 +190,7 @@ class LR1DFA:
                 -1,
                 dtype = numpy.int16
               )[numpy.newaxis, numpy.newaxis, :]
-            ).astype(numpy.int16),
+            ).xastype(numpy.int16),
             1
           )
         ],
@@ -212,7 +212,7 @@ class LR1DFA:
                 len(self.states),
                 dtype = numpy.int16
               )[numpy.newaxis, numpy.newaxis, :]
-            ).astype(numpy.int16),
+            ).xastype(numpy.int16),
             1
           )
         ],
index 1c151b5..012216b 100644 (file)
@@ -19,7 +19,7 @@
 
 %code requires
 {
-  import ast
+  import xast
   import element
   import lex_yy_code
   import state
 %%
 
 input
-  : %space (?E{ast.AST.Section1}prologue_declarations) "%%" %space (?E{ast.AST.Section2}grammar) epilogue.opt
+  : %space (?E{xast.AST.Section1}prologue_declarations) "%%" %space (?E{xast.AST.Section2}grammar) epilogue.opt
   ;
 
         /*------------------------------------.
@@ -251,48 +251,48 @@ prologue_declaration
   | "%{...%}"
   | %space (?E{
       (
-        ast.AST.Section1.PureParser
+        xast.AST.Section1.PureParser
       if $1 == 'api.pure' else
-        ast.AST.Section1.Locations
+        xast.AST.Section1.Locations
       if $1 == 'locations' else
-        ast.AST.Section1.Debug
+        xast.AST.Section1.Debug
       if $1 == 'parse.trace' else
         element.Element
       )
     }"%<flag>")
-  | %space (?E{ast.AST.Section1.Define}"%define" variable value)
-  | %space (?E{ast.AST.Section1.Defines}"%defines")
-  | %space (?E{ast.AST.Section1.Defines}"%defines" STRING)
-  | %space (?E{ast.AST.Section1.ErrorVerbose}"%error-verbose")
-  | %space (?E{ast.AST.Section1.Expect, value = $2}"%expect" INT)
-  | %space (?E{ast.AST.Section1.ExpectRR, value = $2}"%expect-rr" INT)
-  | %space (?E{ast.AST.Section1.FilePrefix}"%file-prefix" STRING)
-  | %space (?E{ast.AST.Section1.GLRParser}"%glr-parser")
-  | %space (?E{ast.AST.Section1.InitialAction}"%initial-action" "{...}")
+  | %space (?E{xast.AST.Section1.Define}"%define" variable value)
+  | %space (?E{xast.AST.Section1.Defines}"%defines")
+  | %space (?E{xast.AST.Section1.Defines}"%defines" STRING)
+  | %space (?E{xast.AST.Section1.ErrorVerbose}"%error-verbose")
+  | %space (?E{xast.AST.Section1.Expect, value = $2}"%expect" INT)
+  | %space (?E{xast.AST.Section1.ExpectRR, value = $2}"%expect-rr" INT)
+  | %space (?E{xast.AST.Section1.FilePrefix}"%file-prefix" STRING)
+  | %space (?E{xast.AST.Section1.GLRParser}"%glr-parser")
+  | %space (?E{xast.AST.Section1.InitialAction}"%initial-action" "{...}")
     {
       lex_yy_code.yyin = None
       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(ast.AST.Text)
-      assert isinstance(yy_element_stack[-1][0], ast.AST.Section1.InitialAction)
-      assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+      lex_yy_code.yylex(xast.AST.Text)
+      assert isinstance(yy_element_stack[-1][0], xast.AST.Section1.InitialAction)
+      assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
       tail = element.get_text(yy_element_stack[-1][0], 1)
       yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
       element.set_text(yy_element_stack[-1][0], 1, tail)
     }
-  | %space (?E{ast.AST.Section1.Language}"%language" STRING)
-  | %space (?E{ast.AST.Section1.NamePrefix}"%name-prefix" STRING)
-  | %space (?E{ast.AST.Section1.Lines, value = False}"%no-lines")
-  | %space (?E{ast.AST.Section1.NonDeterministicParser}"%nondeterministic-parser")
-  | %space (?E{ast.AST.Section1.Output}"%output" STRING)
-  | %space (?E{ast.AST.Section1.Param}"%param" params)
-  | %space (?E{ast.AST.Section1.Require}"%require" STRING)
-  | %space (?E{ast.AST.Section1.Skeleton}"%skeleton" STRING)
-  | %space (?E{ast.AST.Section1.TokenTable}"%token-table")
-  | %space (?E{ast.AST.Section1.Verbose}"%verbose")
-  | %space (?E{ast.AST.Section1.YACC}"%yacc")
+  | %space (?E{xast.AST.Section1.Language}"%language" STRING)
+  | %space (?E{xast.AST.Section1.NamePrefix}"%name-prefix" STRING)
+  | %space (?E{xast.AST.Section1.Lines, value = False}"%no-lines")
+  | %space (?E{xast.AST.Section1.NonDeterministicParser}"%nondeterministic-parser")
+  | %space (?E{xast.AST.Section1.Output}"%output" STRING)
+  | %space (?E{xast.AST.Section1.Param}"%param" params)
+  | %space (?E{xast.AST.Section1.Require}"%require" STRING)
+  | %space (?E{xast.AST.Section1.Skeleton}"%skeleton" STRING)
+  | %space (?E{xast.AST.Section1.TokenTable}"%token-table")
+  | %space (?E{xast.AST.Section1.Verbose}"%verbose")
+  | %space (?E{xast.AST.Section1.YACC}"%yacc")
   | /*FIXME: Err?  What is this horror doing here? */ ";"
   ;
 
@@ -309,30 +309,30 @@ grammar_declaration
   : precedence_declaration
   | symbol_declaration
   /* ) ) should be )) */
-  | %space (?E{ast.AST.Section1Or2.Start}"%start" %space (?E{ast.AST.SymbolRef}symbol) )
-  | %space (?E{ast.AST.Section1Or2.CodeProps, _type = $1}code_props_type "{...}" generic_symlist)
+  | %space (?E{xast.AST.Section1Or2.Start}"%start" %space (?E{xast.AST.SymbolRef}symbol) )
+  | %space (?E{xast.AST.Section1Or2.CodeProps, _type = $1}code_props_type "{...}" generic_symlist)
     {
       lex_yy_code.yyin = None
       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(ast.AST.Text)
-      assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.CodeProps)
-      assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+      lex_yy_code.yylex(xast.AST.Text)
+      assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.CodeProps)
+      assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
       tail = element.get_text(yy_element_stack[-1][0], 1)
       yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
       element.set_text(yy_element_stack[-1][0], 1, tail)
     }
-  | %space (?E{ast.AST.Section1Or2.DefaultPrec, value = True}"%default-prec")
-  | %space (?E{ast.AST.Section1Or2.DefaultPrec}"%no-default-prec")
+  | %space (?E{xast.AST.Section1Or2.DefaultPrec, value = True}"%default-prec")
+  | %space (?E{xast.AST.Section1Or2.DefaultPrec}"%no-default-prec")
   /* the BracedCode should be removed altogether, put here for compatibility */
-  | %space (?E{ast.AST.Section1Or2.Code}"%code" (?E{ast.AST.ID}) %space (?E{ast.AST.BracedCode}"{...}") )
+  | %space (?E{xast.AST.Section1Or2.Code}"%code" (?E{xast.AST.ID}) %space (?E{xast.AST.BracedCode}"{...}") )
     {
       # most egregious (leftover from when we used to run code scanner on it):
-      assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.Code)
-      assert isinstance(yy_element_stack[-1][0][1], ast.AST.BracedCode)
-      assert isinstance(yy_element_stack[-1][0][1][0], ast.AST.Text)
+      assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.Code)
+      assert isinstance(yy_element_stack[-1][0][1], xast.AST.BracedCode)
+      assert isinstance(yy_element_stack[-1][0][1][0], xast.AST.Text)
       element.set_text(
         yy_element_stack[-1][0][1][0],
         0,
@@ -350,12 +350,12 @@ grammar_declaration
       )
     }
   /* the BracedCode should be removed altogether, put here for compatibility */
-  | %space (?E{ast.AST.Section1Or2.Code}"%code" ID %space (?E{ast.AST.BracedCode}"{...}") )
+  | %space (?E{xast.AST.Section1Or2.Code}"%code" ID %space (?E{xast.AST.BracedCode}"{...}") )
     {
       # most egregious (leftover from when we used to run code scanner on it):
-      assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.Code)
-      assert isinstance(yy_element_stack[-1][0][1], ast.AST.BracedCode)
-      assert isinstance(yy_element_stack[-1][0][1][0], ast.AST.Text)
+      assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.Code)
+      assert isinstance(yy_element_stack[-1][0][1], xast.AST.BracedCode)
+      assert isinstance(yy_element_stack[-1][0][1][0], xast.AST.Text)
       element.set_text(
         yy_element_stack[-1][0][1][0],
         0,
@@ -400,18 +400,18 @@ code_props_type
 %token PERCENT_UNION "%union";
 
 union_name
-  : (?E{ast.AST.ID}%empty)
+  : (?E{xast.AST.ID}%empty)
   | ID
   ;
 
 grammar_declaration
   /* the BracedCode should be removed altogether, put here for compatibility */
-  : %space (?E{ast.AST.Section1Or2.Union}"%union" union_name %space (?E{ast.AST.BracedCode}"{...}") )
+  : %space (?E{xast.AST.Section1Or2.Union}"%union" union_name %space (?E{xast.AST.BracedCode}"{...}") )
     {
       # most egregious (leftover from when we used to run code scanner on it):
-      assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.Union)
-      assert isinstance(yy_element_stack[-1][0][1], ast.AST.BracedCode)
-      assert isinstance(yy_element_stack[-1][0][1][0], ast.AST.Text)
+      assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.Union)
+      assert isinstance(yy_element_stack[-1][0][1], xast.AST.BracedCode)
+      assert isinstance(yy_element_stack[-1][0][1][0], xast.AST.Text)
       element.set_text(
         yy_element_stack[-1][0][1][0],
         0,
@@ -431,13 +431,13 @@ grammar_declaration
   ;
 
 symbol_declaration
-  : %space (?E{ast.AST.Section1Or2.NTerm}"%nterm" symbol_defs.1)
-  | %space (?E{ast.AST.Section1Or2.Token}"%token" symbol_defs.1)
-  | %space (?E{ast.AST.Section1Or2.Type}"%type" TAG symbols.1)
+  : %space (?E{xast.AST.Section1Or2.NTerm}"%nterm" symbol_defs.1)
+  | %space (?E{xast.AST.Section1Or2.Token}"%token" symbol_defs.1)
+  | %space (?E{xast.AST.Section1Or2.Type}"%type" TAG symbols.1)
   ;
 
 precedence_declaration
-  : %space (?E{ast.AST.Section1Or2.Precedence, _type = ($1 & 3) - 1}precedence_declarator tag.opt symbols.prec)
+  : %space (?E{xast.AST.Section1Or2.Precedence, _type = ($1 & 3) - 1}precedence_declarator tag.opt symbols.prec)
   ;
 
 precedence_declarator
@@ -471,14 +471,14 @@ symbols.prec
   ;
 
 symbol.prec
-  : %space (?E{ast.AST.SymbolRef}symbol)
-  | %space (?E{ast.AST.SymbolRef, user_token = $2}symbol INT)
+  : %space (?E{xast.AST.SymbolRef}symbol)
+  | %space (?E{xast.AST.SymbolRef, user_token = $2}symbol INT)
   ;
 
 /* One or more symbols to be %typed. */
 symbols.1
-  : %space (?E{ast.AST.SymbolRef}symbol)
-  | symbols.1 %space (?E{ast.AST.SymbolRef}symbol)
+  : %space (?E{xast.AST.SymbolRef}symbol)
+  | symbols.1 %space (?E{xast.AST.SymbolRef}symbol)
   ;
 
 generic_symlist
@@ -487,7 +487,7 @@ generic_symlist
   ;
 
 generic_symlist_item
-  : %space (?E{ast.AST.SymbolRef}symbol)
+  : %space (?E{xast.AST.SymbolRef}symbol)
   | tag
   ;
 
@@ -500,10 +500,10 @@ tag
 /* One token definition.  */
 symbol_def
   : TAG
-  | %space (?E{ast.AST.SymbolRef}id)
-  | %space (?E{ast.AST.SymbolRef, user_token = $2}id INT)
-  | %space (?E{ast.AST.SymbolRef}id string_as_id)
-  | %space (?E{ast.AST.SymbolRef, user_token = $2}id INT string_as_id)
+  | %space (?E{xast.AST.SymbolRef}id)
+  | %space (?E{xast.AST.SymbolRef, user_token = $2}id INT)
+  | %space (?E{xast.AST.SymbolRef}id string_as_id)
+  | %space (?E{xast.AST.SymbolRef, user_token = $2}id INT string_as_id)
   ;
 
 /* One or more symbol definitions. */
@@ -533,12 +533,12 @@ rules_or_grammar_declaration
   ;
 
 rules
-  : %space (?E{ast.AST.Section2.Rules}(?E{ast.AST.SymbolRef}id_colon) named_ref.opt rhses.1)
+  : %space (?E{xast.AST.Section2.Rules}(?E{xast.AST.SymbolRef}id_colon) named_ref.opt rhses.1)
   ;
 
 rhses.1
-  : %space (?E{ast.AST.Production}rhs)
-  | rhses.1 "|" %space (?E{ast.AST.Production}rhs)
+  : %space (?E{xast.AST.Production}rhs)
+  | rhses.1 "|" %space (?E{xast.AST.Production}rhs)
   | rhses.1 ";"
   ;
 
@@ -557,17 +557,17 @@ rhs
       yy_element_stack[-1] = lex_yy.yy_element_space
       lex_yy.yy_element_space = element.Element()
     }
-  | rhs %space (?E{ast.AST.Production.SymbolRef}(?E{ast.AST.SymbolRef}symbol) named_ref.opt)
-  | rhs %space (?E{ast.AST.Production.Action}"{...}" named_ref.opt)
+  | rhs %space (?E{xast.AST.Production.SymbolRef}(?E{xast.AST.SymbolRef}symbol) named_ref.opt)
+  | rhs %space (?E{xast.AST.Production.Action}"{...}" named_ref.opt)
     {
       lex_yy_code.yyin = None
       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_RULE_ACTION # CODE_PROPS_RULE_ACTION
-      lex_yy_code.yylex(ast.AST.Text)
-      assert isinstance(yy_element_stack[-1][0], ast.AST.Production.Action)
-      assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+      lex_yy_code.yylex(xast.AST.Text)
+      assert isinstance(yy_element_stack[-1][0], xast.AST.Production.Action)
+      assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
       tail = element.get_text(yy_element_stack[-1][0], 1)
       yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
       element.set_text(yy_element_stack[-1][0], 1, tail)
@@ -576,28 +576,28 @@ rhs
     {
       #grammar_current_rule_action_append($2, @2, None, True)
     }
-  | rhs %space (?E{ast.AST.Production.Empty}"%empty")
+  | rhs %space (?E{xast.AST.Production.Empty}"%empty")
   /* ) ) should be )) */
-  | rhs %space (?E{ast.AST.Production.Prec}"%prec" %space (?E{ast.AST.SymbolRef}symbol) )
-  | rhs %space (?E{ast.AST.Production.DPrec, value = $3}"%dprec" INT)
-  | rhs %space (?E{ast.AST.Production.Merge}"%merge" TAG)
+  | rhs %space (?E{xast.AST.Production.Prec}"%prec" %space (?E{xast.AST.SymbolRef}symbol) )
+  | rhs %space (?E{xast.AST.Production.DPrec, value = $3}"%dprec" INT)
+  | rhs %space (?E{xast.AST.Production.Merge}"%merge" TAG)
   /* Nick extra rules for element groups */
-  | rhs %space (?E{ast.AST.Production.GroupElement}'(' rhs ')')
+  | rhs %space (?E{xast.AST.Production.GroupElement}'(' rhs ')')
     {
       lex_yy_code.yyin = None
       lex_yy_code.yy_buffer_stack = [lex_yy_code.YYBufferState()]
       lex_yy_code.yytext = '' # fool unput()
       lex_yy_code.unput($2[4:-1])
       lex_yy_code.sc_context = lex_yy_code.SC_RULE_ACTION # CODE_PROPS_RULE_ACTION
-      lex_yy_code.yylex(ast.AST.Text)
-      assert isinstance(yy_element_stack[-1][0], ast.AST.Production.GroupElement)
-      assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+      lex_yy_code.yylex(xast.AST.Text)
+      assert isinstance(yy_element_stack[-1][0], xast.AST.Production.GroupElement)
+      assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
       tail = element.get_text(yy_element_stack[-1][0], 1)
       yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
       element.set_text(yy_element_stack[-1][0], 1, tail)
     }
   /* Nick added %space */
-  | rhs %space (?E{ast.AST.Production.Space}"%space")
+  | rhs %space (?E{xast.AST.Production.Space}"%space")
   ;
 
 named_ref.opt
@@ -672,7 +672,7 @@ string_as_id
 
 epilogue.opt
   : %empty
-  | "%%" (?E{ast.AST.Section3}EPILOGUE %space)
+  | "%%" (?E{xast.AST.Section3}EPILOGUE %space)
   ;
 
 %%
index d5cb728..377af8b 100755 (executable)
@@ -16,7 +16,7 @@
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 
-import ast
+import xast
 import element
 import generate_bison
 import generate_py
@@ -66,21 +66,21 @@ in_file = args[0]
 
 with open(in_file) as fin:
   if in_file[-4:] == '.xml':
-    _ast = element.deserialize(fin, ast.factory)
+    _xast = element.deserialize(fin, xast.factory)
   else:
     import lex_yy
     import state
     import y_tab
     state.infilename = in_file
     lex_yy.yyin = fin
-    _ast = y_tab.yyparse(ast.AST)
-#element.serialize(_ast, 'a.xml', 'utf-8')
-#_ast = element.deserialize('a.xml', ast.factory, 'utf-8')
-_ast.post_process()
-#element.serialize(_ast, 'b.xml', 'utf-8')
-#_ast = element.deserialize('b.xml', ast.factory, 'utf-8')
+    _xast = y_tab.yyparse(xast.AST)
+#element.serialize(_xast, 'a.xml', 'utf-8')
+#_xast = element.deserialize('a.xml', xast.factory, 'utf-8')
+_xast.post_process()
+#element.serialize(_xast, 'b.xml', 'utf-8')
+#_xast = element.deserialize('b.xml', xast.factory, 'utf-8')
 (generate_py.generate_py if python else generate_bison.generate_bison)(
-  _ast,
+  _xast,
   _element,
   home_dir,
   skel_file,
index 244c649..7ba3679 100644 (file)
@@ -20,7 +20,7 @@
 %option debug nodefault noinput nounput noyywrap never-interactive
 
 %{
-  import ast
+  import xast
 
   sc_context = -1
 %}
@@ -101,12 +101,12 @@ id        {letter}(?:{letter}|[-0-9])*
 <SC_RULE_ACTION>
 {
   (?E{
-    ast.AST.Text.StackReference,
+    xast.AST.Text.StackReference,
     tag_name = '' if yy_groups[2] is None else yy_groups[2][1:-1],
     index = int(yy_groups[3])
   }"$"("<"{tag}">")?(-?[0-9]+|{id}|"["{id}"]"))
   (?E{
-    ast.AST.Text.StackLocation,
+    xast.AST.Text.StackLocation,
     index = int(yy_groups[2])
   }"@"(-?[0-9]+|{id}|"["{id}"]"))
 }
@@ -114,11 +114,11 @@ id        {letter}(?:{letter}|[-0-9])*
 <SC_RULE_ACTION,SC_SYMBOL_ACTION>
 {
   (?E{
-    ast.AST.Text.ValueReference,
+    xast.AST.Text.ValueReference,
     tag_name = '' if yy_groups[2] is None else yy_groups[2][1:-1]
   }"$"("<"{tag}">")?"$")
   (?E{
-    ast.AST.Text.ValueLocation
+    xast.AST.Text.ValueLocation
   }"@$")
 }
 
index e6863a3..3ffb505 100644 (file)
@@ -20,7 +20,7 @@
 %option debug nodefault noinput noyywrap never-interactive
 
 %{
-  import ast
+  import xast
   import state
   import y_tab
 
@@ -249,7 +249,7 @@ eqopt    ([[:space:]]*=)?
   "|"                          return y_tab.PIPE
   ";"                          return y_tab.SEMICOLON
 
-  (?E{ast.AST.ID}{id}) {
+  (?E{xast.AST.ID}{id}) {
     global id_loc, bracketed_id_str
     y_tab.yylval = yytext
     id_loc = y_tab.yylloc
@@ -277,9 +277,9 @@ eqopt    ([[:space:]]*=)?
     token_start = y_tab.yylloc.start
     BEGIN(SC_ESCAPED_CHARACTER)
     markup_push(element.Element)
-    markup_push(ast.AST.Char)
+    markup_push(xast.AST.Char)
     markup_flush(len(yytext))
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
 
   /* Strings. */
@@ -288,9 +288,9 @@ eqopt    ([[:space:]]*=)?
     token_start = y_tab.yylloc.start
     BEGIN(SC_ESCAPED_STRING)
     markup_push(element.Element)
-    markup_push(ast.AST.String)
+    markup_push(xast.AST.String)
     markup_flush(len(yytext))
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
 
   /* Prologue. */
@@ -299,9 +299,9 @@ eqopt    ([[:space:]]*=)?
     code_start = y_tab.yylloc.start
     BEGIN(SC_PROLOGUE)
     markup_push(element.Element)
-    markup_push(ast.AST.Section1.Prologue)
+    markup_push(xast.AST.Section1.Prologue)
     markup_flush(len(yytext))
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
 
   /* Code in between braces.  */
@@ -313,12 +313,12 @@ eqopt    ([[:space:]]*=)?
     BEGIN(SC_BRACED_CODE)
     markup_push(element.Element)
     # new way, includes braces, wrapped by <AST_Production_Action> later
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
     markup_flush(len(yytext))
     # old way 
-    #markup_push(ast.AST.BracedCode)
+    #markup_push(xast.AST.BracedCode)
     #markup_flush(len(yytext))
-    #markup_push(ast.AST.Text)
+    #markup_push(xast.AST.Text)
     # to here
   }
 
@@ -329,9 +329,9 @@ eqopt    ([[:space:]]*=)?
     code_start = y_tab.yylloc.start
     BEGIN(SC_PREDICATE)
     markup_push(element.Element)
-    markup_push(ast.AST.BracedPredicate)
+    markup_push(xast.AST.BracedPredicate)
     markup_flush(len(yytext))
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
 
   /* Nick extra rules for element groups */
@@ -343,15 +343,15 @@ eqopt    ([[:space:]]*=)?
     BEGIN(SC_ELEMENT_GROUP)
     markup_push(element.Element)
     markup_flush(len(yytext))
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
   ")"                          return ord(')')
 
   /* A type. */
-  "(?E{ast.AST.TagRef}<(?E{ast.AST.Text}*)>)" {
+  "(?E{xast.AST.TagRef}<(?E{xast.AST.Text}*)>)" {
     return y_tab.TAG_ANY
   }
-  "(?E{ast.AST.TagRef}<(?E{ast.AST.Text})>)" {
+  "(?E{xast.AST.TagRef}<(?E{xast.AST.Text})>)" {
     return y_tab.TAG_NONE
   }
   "<" {
@@ -360,9 +360,9 @@ eqopt    ([[:space:]]*=)?
     token_start = y_tab.yylloc.start
     BEGIN(SC_TAG)
     markup_push(element.Element)
-    markup_push(ast.AST.TagRef)
+    markup_push(xast.AST.TagRef)
     markup_flush(len(yytext))
-    markup_push(ast.AST.Text)
+    markup_push(xast.AST.Text)
   }
 
   "%%" {
@@ -563,9 +563,9 @@ eqopt    ([[:space:]]*=)?
     y_tab.yylloc.start = token_start
     y_tab.yylval = gram_last_string
     BEGIN(INITIAL)
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.String
+    markup_pop() # xast.AST.String
     markup_pop_token() # element.Element
     return y_tab.STRING
   }
@@ -594,9 +594,9 @@ eqopt    ([[:space:]]*=)?
       y_tab.yylval = ord(gram_last_string[0])
     #del obstack_for_string[:]
     BEGIN(INITIAL)
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.Char
+    markup_pop() # xast.AST.Char
     markup_pop_token() # element.Element
     return y_tab.CHAR
   }
@@ -622,9 +622,9 @@ eqopt    ([[:space:]]*=)?
       y_tab.yylval = gram_last_string
       #del obstack_for_string[:]
       BEGIN(INITIAL)
-      markup_pop() # ast.AST.Text
+      markup_pop() # xast.AST.Text
       markup_flush(len(yytext))
-      markup_pop() # ast.AST.TagRef
+      markup_pop() # xast.AST.TagRef
       markup_pop_token() # element.Element
       return y_tab.TAG
     obstack_for_string.append(yytext)
@@ -646,7 +646,7 @@ eqopt    ([[:space:]]*=)?
 
 <SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>
 {
-  (?E{ast.AST.Text.Escape, character = int(yy_groups[2], 8)}\\([0-7]{1,3})) {
+  (?E{xast.AST.Text.Escape, character = int(yy_groups[2], 8)}\\([0-7]{1,3})) {
     c = int(yytext + 1, 8)
     if not c or 0x7f * 2 + 1 < c:
       state.complain(y_tab.yylloc, state.complaint, 'invalid number after \\-escape: {0:s}'.format(yytext[1:]))
@@ -654,7 +654,7 @@ eqopt    ([[:space:]]*=)?
       obstack_for_string.append(chr(c))
   }
 
-  (?E{ast.AST.Text.Escape, character = int(yy_groups[2], 16)}\\x([0-9abcdefABCDEF]+)) {
+  (?E{xast.AST.Text.Escape, character = int(yy_groups[2], 16)}\\x([0-9abcdefABCDEF]+)) {
     c = int(yytext + 2, 16)
     if not c or 0x7f * 2 + 1 < c:
       state.complain(y_tab.yylloc, state.complaint, 'invalid number after \\-escape: {0:s}'.format(yytext[1:]))
@@ -662,34 +662,34 @@ eqopt    ([[:space:]]*=)?
       obstack_for_string.append(chr(c))
   }
 
-  (?E{ast.AST.Text.Escape, character = 7}\\a) {
+  (?E{xast.AST.Text.Escape, character = 7}\\a) {
     obstack_for_string.append('\a')
   }
-  (?E{ast.AST.Text.Escape, character = 8}\\b) {
+  (?E{xast.AST.Text.Escape, character = 8}\\b) {
     obstack_for_string.append('\b')
   }
-  (?E{ast.AST.Text.Escape, character = 12}\\f) {
+  (?E{xast.AST.Text.Escape, character = 12}\\f) {
     obstack_for_string.append('\f')
   }
-  (?E{ast.AST.Text.Escape, character = 10}\\n) {
+  (?E{xast.AST.Text.Escape, character = 10}\\n) {
     obstack_for_string.append('\n')
   }
-  (?E{ast.AST.Text.Escape, character = 13}\\r) {
+  (?E{xast.AST.Text.Escape, character = 13}\\r) {
     obstack_for_string.append('\r')
   }
-  (?E{ast.AST.Text.Escape, character = 9}\\t) {
+  (?E{xast.AST.Text.Escape, character = 9}\\t) {
     obstack_for_string.append('\t')
   }
-  (?E{ast.AST.Text.Escape, character = 11}\\v) {
+  (?E{xast.AST.Text.Escape, character = 11}\\v) {
     obstack_for_string.append('\v')
   }
 
   /* \\[\"\'?\\] would be shorter, but it confuses xgettext.  */
-  (?E{ast.AST.Text.Escape, character = ord(yy_groups[2])}\\("\""|"'"|"?"|"\\")) {
+  (?E{xast.AST.Text.Escape, character = ord(yy_groups[2])}\\("\""|"'"|"?"|"\\")) {
     obstack_for_string.append(yytext[1])
   }
  
-  (?E{ast.AST.Text.Escape, character = int(('' if yy_groups[3] is None else yy_groups[3]) + yy_groups[4], 16)}\\(u|U([0-9abcdefABCDEF]{4}))([0-9abcdefABCDEF]{4})) {
+  (?E{xast.AST.Text.Escape, character = int(('' if yy_groups[3] is None else yy_groups[3]) + yy_groups[4], 16)}\\(u|U([0-9abcdefABCDEF]{4}))([0-9abcdefABCDEF]{4})) {
     c = convert_ucn_to_byte(yytext)
     if c <= 0:
       state.complain(y_tab.yylloc, state.complaint, 'invalid number after \\-escape: {0:s}'.format(yytext[1:]))
@@ -814,11 +814,11 @@ eqopt    ([[:space:]]*=)?
       BEGIN(INITIAL)
       # new way, includes braces, wrapped by <AST_Production_Action> later
       markup_flush(len(yytext))
-      markup_pop() # ast.AST.Text
+      markup_pop() # xast.AST.Text
       # old way
-      #markup_pop() # ast.AST.Text
+      #markup_pop() # xast.AST.Text
       #markup_flush(len(yytext))
-      #markup_pop() # ast.AST.BracedCode
+      #markup_pop() # xast.AST.BracedCode
       # to here
       markup_pop_token() # element.Element
       return y_tab.BRACED_CODE
@@ -836,9 +836,9 @@ eqopt    ([[:space:]]*=)?
       y_tab.yylloc.start = code_start
       y_tab.yylval = gram_last_string
       BEGIN(INITIAL)
-      markup_pop() # ast.AST.Text
+      markup_pop() # xast.AST.Text
       markup_flush(len(yytext))
-      markup_pop() # ast.AST.BracedPredicate
+      markup_pop() # xast.AST.BracedPredicate
       markup_pop_token() # element.Element
       return y_tab.BRACED_PREDICATE
     else:
@@ -860,7 +860,7 @@ eqopt    ([[:space:]]*=)?
       y_tab.yylval = gram_last_string
       #del obstack_for_string[:]
       BEGIN(INITIAL)
-      markup_pop() # ast.AST.Text
+      markup_pop() # xast.AST.Text
       markup_flush(len(yytext))
       markup_pop_token() # element.Element
       return ord('(')
@@ -880,9 +880,9 @@ eqopt    ([[:space:]]*=)?
     y_tab.yylloc.start = code_start
     y_tab.yylval = gram_last_string
     BEGIN(INITIAL)
-    markup_pop() # ast.AST.Text
+    markup_pop() # xast.AST.Text
     markup_flush(len(yytext))
-    markup_pop() # ast.AST.Section1.Prologue
+    markup_pop() # xast.AST.Section1.Prologue
     markup_pop_token() # element.Element
     return y_tab.PROLOGUE
   }
similarity index 95%
rename from bootstrap_piyacc/ast.py
rename to bootstrap_piyacc/xast.py
index 7dd0fde..9cd7f89 100644 (file)
@@ -44,7 +44,7 @@ class Item(element.Element):
   # GENERATE END
   def post_process(
     self,
-    _ast,
+    _xast,
     section,
     character_to_symbol,
     name_to_symbol,
@@ -309,7 +309,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         production,
         character_to_symbol,
@@ -323,7 +323,7 @@ class AST(element.Element):
         raise NotImplementedError
       def add_to_symbols(
         self,
-        _ast,
+        _xast,
         production,
         last_action,
         _lr1,
@@ -333,7 +333,7 @@ class AST(element.Element):
         return last_action
       def add_to_groups(
         self,
-        _ast,
+        _xast,
         production,
         groups,
         first_action,
@@ -367,7 +367,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         production,
         character_to_symbol,
@@ -378,12 +378,12 @@ class AST(element.Element):
         has_space,
         last_grouped_pos
       ):
-        _ast.n_productions += int(last_action) # midrule action production
+        _xast.n_productions += int(last_action) # midrule action production
         production.n_symbols += int(last_action) # midrule action symbol
         return True, has_space, last_grouped_pos
       def add_to_symbols(
         self,
-        _ast,
+        _xast,
         production,
         last_action,
         _lr1,
@@ -419,7 +419,7 @@ class AST(element.Element):
         return self[0]
       def add_to_groups(
         self,
-        _ast,
+        _xast,
         production,
         groups,
         first_action,
@@ -489,7 +489,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         production,
         character_to_symbol,
@@ -565,7 +565,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         production,
         character_to_symbol,
@@ -578,7 +578,7 @@ class AST(element.Element):
       ):
         assert production.precedence_terminal == -1
         _, production.precedence_terminal = self[0].post_process(
-          _ast,
+          _xast,
           section,
           character_to_symbol,
           name_to_symbol,
@@ -637,7 +637,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         production,
         character_to_symbol,
@@ -648,10 +648,10 @@ class AST(element.Element):
         has_space,
         last_grouped_pos
       ):
-        _ast.n_productions += int(last_action) # midrule action production
+        _xast.n_productions += int(last_action) # midrule action production
         production.n_symbols += int(last_action) + 1 # midrule action symbol
         _, self.symbol = self[0].post_process(
-          _ast,
+          _xast,
           section,
           character_to_symbol,
           name_to_symbol,
@@ -661,13 +661,13 @@ class AST(element.Element):
           -1, # _tag
           -1 # precedence
         )
-        if _ast.symbols[self.symbol]._type == AST.Symbol.TYPE_TERMINAL:
+        if _xast.symbols[self.symbol]._type == AST.Symbol.TYPE_TERMINAL:
           production.last_terminal = self.symbol
         self.has_space = has_space
         return False, False, last_grouped_pos
       def add_to_symbols(
         self,
-        _ast,
+        _xast,
         production,
         last_action,
         _lr1,
@@ -690,19 +690,19 @@ class AST(element.Element):
             )
           )
         symbols.append(
-          (_ast.symbols[self.symbol].character_set, [])
-        if _ast.symbols[self.symbol]._type == AST.Symbol.TYPE_TERMINAL else
-          ([], _ast.symbols[self.symbol].character_set)
+          (_xast.symbols[self.symbol].character_set, [])
+        if _xast.symbols[self.symbol]._type == AST.Symbol.TYPE_TERMINAL else
+          ([], _xast.symbols[self.symbol].character_set)
         )
         tag_names.append(
           ''
-        if _ast.symbols[self.symbol]._tag == -1 else
-          _ast.tags[_ast.symbols[self.symbol]._tag].name
+        if _xast.symbols[self.symbol]._tag == -1 else
+          _xast.tags[_xast.symbols[self.symbol]._tag].name
         )
         return None
       def add_to_groups(
         self,
-        _ast,
+        _xast,
         production,
         groups,
         first_action,
@@ -736,7 +736,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         production,
         character_to_symbol,
@@ -749,7 +749,7 @@ class AST(element.Element):
       ):
         for i in self[1:]:
           last_action, has_space, last_grouped_pos = i.post_process(
-            _ast,
+            _xast,
             section,
             production,
             character_to_symbol,
@@ -764,7 +764,7 @@ class AST(element.Element):
         return last_action, has_space, last_grouped_pos
       def add_to_symbols(
         self,
-        _ast,
+        _xast,
         production,
         last_action,
         _lr1,
@@ -784,7 +784,7 @@ class AST(element.Element):
             i.offset = -production.n_symbols
         for i in self[1:]:
           last_action = i.add_to_symbols(
-            _ast,
+            _xast,
             production,
             last_action,
             _lr1,
@@ -794,7 +794,7 @@ class AST(element.Element):
         return last_action
       def add_to_groups(
         self,
-        _ast,
+        _xast,
         production,
         groups,
         first_action,
@@ -804,7 +804,7 @@ class AST(element.Element):
         pos1 = pos
         for i in self[:0:-1]:
           first_action, pos, last_grouped_pos = i.add_to_groups(
-            _ast,
+            _xast,
             production,
             groups,
             first_action,
@@ -840,7 +840,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         production,
         character_to_symbol,
@@ -855,7 +855,7 @@ class AST(element.Element):
         return last_action, True, last_grouped_pos
       def add_to_groups(
         self,
-        _ast,
+        _xast,
         production,
         groups,
         first_action,
@@ -949,7 +949,7 @@ class AST(element.Element):
 
     def post_process(
       self,
-      _ast,
+      _xast,
       section,
       lhs_nonterminal,
       character_to_symbol,
@@ -968,7 +968,7 @@ class AST(element.Element):
       last_grouped_pos = 0
       for i in self:
         last_action, has_space, last_grouped_pos = i.post_process(
-          _ast,
+          _xast,
           section,
           self,
           character_to_symbol,
@@ -986,21 +986,21 @@ class AST(element.Element):
       #print('last_grouped_pos', last_grouped_pos)
       #print('self.n_symbols', self.n_symbols)
 
-      i = _ast.symbols[self.lhs_nonterminal]
-      if len(i.character_set) and i.character_set[-1] == _ast.n_productions:
-        i.character_set[-1] = _ast.n_productions + 1
+      i = _xast.symbols[self.lhs_nonterminal]
+      if len(i.character_set) and i.character_set[-1] == _xast.n_productions:
+        i.character_set[-1] = _xast.n_productions + 1
       else:
-        i.character_set.extend([_ast.n_productions, _ast.n_productions + 1])
-      _ast.n_productions += 1
-      _ast.productions.append(self)
+        i.character_set.extend([_xast.n_productions, _xast.n_productions + 1])
+      _xast.n_productions += 1
+      _xast.productions.append(self)
 
-    def add_to_lr1(self, _ast, _lr1):
+    def add_to_lr1(self, _xast, _lr1):
       last_action = None
       symbols = []
       tag_names = []
       for i in self:
         last_action = i.add_to_symbols(
-          _ast,
+          _xast,
           self,
           last_action,
           _lr1,
@@ -1017,8 +1017,8 @@ class AST(element.Element):
           ):
             i.tag_name = (
               ''
-            if _ast.symbols[self.lhs_nonterminal]._tag == -1 else
-              _ast.tags[_ast.symbols[self.lhs_nonterminal]._tag].name
+            if _xast.symbols[self.lhs_nonterminal]._tag == -1 else
+              _xast.tags[_xast.symbols[self.lhs_nonterminal]._tag].name
             )
 
       # go backwards collecting negative indices of element group start/end
@@ -1029,7 +1029,7 @@ class AST(element.Element):
       last_grouped_pos = pos # says last position where a group has started
       for i in self[::-1]:
         first_action, pos, last_grouped_pos = i.add_to_groups(
-          _ast,
+          _xast,
           self,
           groups,
           first_action,
@@ -1053,9 +1053,9 @@ class AST(element.Element):
       )
 
       precedence = (
-        _ast.symbols[self.precedence_terminal].precedence
+        _xast.symbols[self.precedence_terminal].precedence
       if self.precedence_terminal != -1 else
-        _ast.symbols[self.last_terminal].precedence
+        _xast.symbols[self.last_terminal].precedence
       if self.last_terminal != -1 else
         -1
       )
@@ -1091,7 +1091,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1101,14 +1101,14 @@ class AST(element.Element):
         name = self[0].get_text()
         if len(name) == 0: # do the same as Section1.Prologue
           (
-            _ast.before_union_text
-          if len(_ast.union_text) == 0 else
-            _ast.after_union_text
+            _xast.before_union_text
+          if len(_xast.union_text) == 0 else
+            _xast.after_union_text
           ).append(self[1][0])
         elif name == 'top':
-          _ast.top_text.append(self[1][0])
+          _xast.top_text.append(self[1][0])
         elif name == 'requires':
-          _ast.requires_text.append(self[1][0])
+          _xast.requires_text.append(self[1][0])
         else:
           assert False
  
@@ -1149,7 +1149,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1158,7 +1158,7 @@ class AST(element.Element):
       ):
         for i in self[1:]:
           _, j = i.post_process(
-            _ast,
+            _xast,
             section,
             character_to_symbol,
             name_to_symbol,
@@ -1168,7 +1168,7 @@ class AST(element.Element):
             -1, # _tag
             -1 # precedence
           )
-          tag_or_symbol = _ast.symbols[j] if j >= 0 else _ast.tags[~j]
+          tag_or_symbol = _xast.symbols[j] if j >= 0 else _xast.tags[~j]
           assert tag_or_symbol.code_props[self._type] is None
           tag_or_symbol.code_props[self._type] = self[0]
 
@@ -1221,7 +1221,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1231,7 +1231,7 @@ class AST(element.Element):
         _tag = -1
         for i in self:
           _tag, _ = i.post_process(
-            _ast,
+            _xast,
             section,
             character_to_symbol,
             name_to_symbol,
@@ -1279,7 +1279,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1289,7 +1289,7 @@ class AST(element.Element):
         _tag = -1
         for i in self:
           _tag, _ = i.post_process(
-            _ast,
+            _xast,
             section,
             character_to_symbol,
             name_to_symbol,
@@ -1297,9 +1297,9 @@ class AST(element.Element):
             name_to_tag,
             AST.Symbol.TYPE_TERMINAL, # _type
             _tag,
-            len(_ast.associativities) # precedence
+            len(_xast.associativities) # precedence
           )
-        _ast.associativities.append(self._type)
+        _xast.associativities.append(self._type)
 
     class Start(Item):
       # GENERATE ELEMENT() BEGIN
@@ -1326,15 +1326,15 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
         string_to_symbol,
         name_to_tag
       ):
-        _, _ast.start_nonterminal = self[0].post_process(
-          _ast,
+        _, _xast.start_nonterminal = self[0].post_process(
+          _xast,
           section,
           character_to_symbol,
           name_to_symbol,
@@ -1370,7 +1370,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1380,7 +1380,7 @@ class AST(element.Element):
         _tag = -1
         for i in self:
           _tag, _ = i.post_process(
-            _ast,
+            _xast,
             section,
             character_to_symbol,
             name_to_symbol,
@@ -1416,7 +1416,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1426,7 +1426,7 @@ class AST(element.Element):
         _tag = -1
         for i in self:
           _tag, _ = i.post_process(
-            _ast,
+            _xast,
             section,
             character_to_symbol,
             name_to_symbol,
@@ -1462,7 +1462,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1471,9 +1471,9 @@ class AST(element.Element):
       ):
         name = self[0].get_text()
         if len(name):
-          assert len(_ast.union_name) == 0
-          _ast.union_name = name
-        _ast.union_text.append(self[1][0])
+          assert len(_xast.union_name) == 0
+          _xast.union_name = name
+        _xast.union_text.append(self[1][0])
 
     # GENERATE ELEMENT() BEGIN
     def __init__(
@@ -1499,7 +1499,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       character_to_symbol,
       name_to_symbol,
       string_to_symbol,
@@ -1507,7 +1507,7 @@ class AST(element.Element):
     ):
       for i in self:
         i.post_process(
-          _ast,
+          _xast,
           self,
           character_to_symbol,
           name_to_symbol,
@@ -1541,7 +1541,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1575,7 +1575,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1655,7 +1655,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1690,7 +1690,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1736,7 +1736,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1854,7 +1854,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1862,7 +1862,7 @@ class AST(element.Element):
         name_to_tag
       ):
         assert isinstance(self[0], AST.Text) # temporary
-        _ast.initial_action_text.append(self[0])
+        _xast.initial_action_text.append(self[0])
 
     class Language(Item):
       # GENERATE ELEMENT() BEGIN
@@ -1937,7 +1937,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -1971,7 +1971,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -2077,7 +2077,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -2085,9 +2085,9 @@ class AST(element.Element):
         name_to_tag
       ):
         (
-          _ast.before_union_text
-        if len(_ast.union_text) == 0 else
-          _ast.after_union_text
+          _xast.before_union_text
+        if len(_xast.union_text) == 0 else
+          _xast.after_union_text
         ).append(self[0])
 
     class PureParser(Item):
@@ -2115,7 +2115,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -2221,7 +2221,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -2362,7 +2362,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       character_to_symbol,
       name_to_symbol,
       string_to_symbol,
@@ -2380,7 +2380,7 @@ class AST(element.Element):
       self.verbose = False
       AST.Section1Or2.post_process(
         self,
-        _ast,
+        _xast,
         character_to_symbol,
         name_to_symbol,
         string_to_symbol,
@@ -2433,7 +2433,7 @@ class AST(element.Element):
       # GENERATE END
       def post_process(
         self,
-        _ast,
+        _xast,
         section,
         character_to_symbol,
         name_to_symbol,
@@ -2441,7 +2441,7 @@ class AST(element.Element):
         name_to_tag
       ):
         _, lhs_nonterminal = self[0].post_process(
-          _ast,
+          _xast,
           section,
           character_to_symbol,
           name_to_symbol,
@@ -2451,11 +2451,11 @@ class AST(element.Element):
           -1, # _tag
           -1 # precedence
         )
-        if _ast.first_nonterminal == -1:
-          _ast.first_nonterminal = lhs_nonterminal
+        if _xast.first_nonterminal == -1:
+          _xast.first_nonterminal = lhs_nonterminal
         for i in self[1:]:
           i.post_process(
-            _ast,
+            _xast,
             section,
             lhs_nonterminal,
             character_to_symbol,
@@ -2536,7 +2536,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       section,
       character_to_symbol,
       name_to_symbol,
@@ -2573,7 +2573,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       section,
       character_to_symbol,
       name_to_symbol,
@@ -2587,9 +2587,9 @@ class AST(element.Element):
       if name in name_to_tag:
         _tag = name_to_tag[name]
       else:
-        _tag = len(_ast.tags)
+        _tag = len(_xast.tags)
         name_to_tag[name] = _tag
-        _ast.tags.append(
+        _xast.tags.append(
           AST.Tag(name = name, code_props = [None, None])
         )
       return (_tag, ~_tag)
@@ -2631,7 +2631,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       section,
       character_to_symbol,
       name_to_symbol,
@@ -2647,9 +2647,9 @@ class AST(element.Element):
         if character in character_to_symbol:
           symbol = character_to_symbol[character]
         else:
-          symbol = len(_ast.symbols)
+          symbol = len(_xast.symbols)
           character_to_symbol[character] = symbol
-          _ast.symbols.append(
+          _xast.symbols.append(
             AST.Symbol(
               code_props = [None, None],
               _type = AST.Symbol.TYPE_TERMINAL,
@@ -2668,16 +2668,16 @@ class AST(element.Element):
           # it have internal token number 0 (and apparently they don't)
           symbol = 0
           name_to_symbol[name] = symbol
-          assert _ast.symbols[symbol].name == '$end'
-          _ast.symbols[symbol] = AST.Symbol(
+          assert _xast.symbols[symbol].name == '$end'
+          _xast.symbols[symbol] = AST.Symbol(
             name = name,
             code_props = [None, None],
             character_set = []
           )
         else:
-          symbol = len(_ast.symbols)
+          symbol = len(_xast.symbols)
           name_to_symbol[name] = symbol
-          _ast.symbols.append(
+          _xast.symbols.append(
             AST.Symbol(
               name = name,
               code_props = [None, None],
@@ -2692,8 +2692,8 @@ class AST(element.Element):
 
       # insert information from the SymbolRef element
       if self.user_token != -1:
-        assert len(_ast.symbols[symbol].character_set) == 0
-        _ast.symbols[symbol].character_set = (
+        assert len(_xast.symbols[symbol].character_set) == 0
+        _xast.symbols[symbol].character_set = (
           [self.user_token, self.user_token + 1]
         )
       if len(self) >= 2:
@@ -2703,16 +2703,16 @@ class AST(element.Element):
 
       # insert information from the calling contexxt
       if _type != -1:
-        if _ast.symbols[symbol]._type == -1:
-          _ast.symbols[symbol]._type = _type
+        if _xast.symbols[symbol]._type == -1:
+          _xast.symbols[symbol]._type = _type
         else:
-          assert _ast.symbols[symbol]._type == _type
+          assert _xast.symbols[symbol]._type == _type
       if _tag != -1:
-        assert _ast.symbols[symbol]._tag == -1
-        _ast.symbols[symbol]._tag = _tag
+        assert _xast.symbols[symbol]._tag == -1
+        _xast.symbols[symbol]._tag = _tag
       if precedence != -1:
-        assert _ast.symbols[symbol].precedence == -1
-        _ast.symbols[symbol].precedence = precedence
+        assert _xast.symbols[symbol].precedence == -1
+        _xast.symbols[symbol].precedence = precedence
 
       return (_tag, symbol)
 
@@ -3080,7 +3080,7 @@ class AST(element.Element):
     # GENERATE END
     def post_process(
       self,
-      _ast,
+      _xast,
       character_to_symbol,
       name_to_symbol,
       string_to_symbol,
index 1893cab..e8cd643 100644 (file)
@@ -43,7 +43,7 @@ class YYLTYPE:
     self.last_column = last_column
  
 # GENERATE SECTION1 BEGIN
-import ast
+import xast
 import element
 import lex_yy_code
 import state
@@ -143,7 +143,7 @@ def yy_action1():
       children = [
         element.concatenate(
           yy_element_stack[-3:-2],
-          ast.AST.Section2
+          xast.AST.Section2
         )
       ]
     )
@@ -153,7 +153,7 @@ def yy_action1():
       children = [
         element.concatenate(
           yy_element_stack[-7:-6],
-          ast.AST.Section1
+          xast.AST.Section1
         )
       ]
     )
@@ -188,11 +188,11 @@ def yy_action6():
         element.concatenate(
           yy_element_stack[-1:],
           (
-            ast.AST.Section1.PureParser
+            xast.AST.Section1.PureParser
           if (yystack[-2][1]) == 'api.pure' else
-            ast.AST.Section1.Locations
+            xast.AST.Section1.Locations
           if (yystack[-2][1]) == 'locations' else
-            ast.AST.Section1.Debug
+            xast.AST.Section1.Debug
           if (yystack[-2][1]) == 'parse.trace' else
             element.Element
           )
@@ -208,7 +208,7 @@ def yy_action7():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1.Define
+          xast.AST.Section1.Define
         )
       ]
     )
@@ -221,7 +221,7 @@ def yy_action8():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.Defines
+          xast.AST.Section1.Defines
         )
       ]
     )
@@ -234,7 +234,7 @@ def yy_action9():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.Defines
+          xast.AST.Section1.Defines
         )
       ]
     )
@@ -247,7 +247,7 @@ def yy_action10():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.ErrorVerbose
+          xast.AST.Section1.ErrorVerbose
         )
       ]
     )
@@ -260,7 +260,7 @@ def yy_action11():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.Expect, value = (yystack[-2][1])
+          xast.AST.Section1.Expect, value = (yystack[-2][1])
         )
       ]
     )
@@ -273,7 +273,7 @@ def yy_action12():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.ExpectRR, value = (yystack[-2][1])
+          xast.AST.Section1.ExpectRR, value = (yystack[-2][1])
         )
       ]
     )
@@ -286,7 +286,7 @@ def yy_action13():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.FilePrefix
+          xast.AST.Section1.FilePrefix
         )
       ]
     )
@@ -299,7 +299,7 @@ def yy_action14():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.GLRParser
+          xast.AST.Section1.GLRParser
         )
       ]
     )
@@ -312,7 +312,7 @@ def yy_action15():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.InitialAction
+          xast.AST.Section1.InitialAction
         )
       ]
     )
@@ -322,9 +322,9 @@ def yy_action15():
   lex_yy_code.yytext = '' # fool unput()
   lex_yy_code.unput((yystack[-2][1]))
   lex_yy_code.sc_context = lex_yy_code.SC_SYMBOL_ACTION # CODE_PROPS_SYMBOL_ACTION
-  lex_yy_code.yylex(ast.AST.Text)
-  assert isinstance(yy_element_stack[-1][0], ast.AST.Section1.InitialAction)
-  assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+  lex_yy_code.yylex(xast.AST.Text)
+  assert isinstance(yy_element_stack[-1][0], xast.AST.Section1.InitialAction)
+  assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
   tail = element.get_text(yy_element_stack[-1][0], 1)
   yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
   element.set_text(yy_element_stack[-1][0], 1, tail)
@@ -335,7 +335,7 @@ def yy_action16():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.Language
+          xast.AST.Section1.Language
         )
       ]
     )
@@ -348,7 +348,7 @@ def yy_action17():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.NamePrefix
+          xast.AST.Section1.NamePrefix
         )
       ]
     )
@@ -361,7 +361,7 @@ def yy_action18():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.Lines, value = False
+          xast.AST.Section1.Lines, value = False
         )
       ]
     )
@@ -374,7 +374,7 @@ def yy_action19():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.NonDeterministicParser
+          xast.AST.Section1.NonDeterministicParser
         )
       ]
     )
@@ -387,7 +387,7 @@ def yy_action20():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.Output
+          xast.AST.Section1.Output
         )
       ]
     )
@@ -400,7 +400,7 @@ def yy_action21():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.Param
+          xast.AST.Section1.Param
         )
       ]
     )
@@ -413,7 +413,7 @@ def yy_action22():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.Require
+          xast.AST.Section1.Require
         )
       ]
     )
@@ -426,7 +426,7 @@ def yy_action23():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1.Skeleton
+          xast.AST.Section1.Skeleton
         )
       ]
     )
@@ -439,7 +439,7 @@ def yy_action24():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.TokenTable
+          xast.AST.Section1.TokenTable
         )
       ]
     )
@@ -452,7 +452,7 @@ def yy_action25():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.Verbose
+          xast.AST.Section1.Verbose
         )
       ]
     )
@@ -465,7 +465,7 @@ def yy_action26():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1.YACC
+          xast.AST.Section1.YACC
         )
       ]
     )
@@ -493,7 +493,7 @@ def yy_action32():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -503,7 +503,7 @@ def yy_action32():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1Or2.Start
+          xast.AST.Section1Or2.Start
         )
       ]
     )
@@ -516,7 +516,7 @@ def yy_action33():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1Or2.CodeProps, _type = (yystack[-4][1])
+          xast.AST.Section1Or2.CodeProps, _type = (yystack[-4][1])
         )
       ]
     )
@@ -526,9 +526,9 @@ def yy_action33():
   lex_yy_code.yytext = '' # fool unput()
   lex_yy_code.unput((yystack[-3][1]))
   lex_yy_code.sc_context = lex_yy_code.SC_SYMBOL_ACTION # CODE_PROPS_SYMBOL_ACTION
-  lex_yy_code.yylex(ast.AST.Text)
-  assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.CodeProps)
-  assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+  lex_yy_code.yylex(xast.AST.Text)
+  assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.CodeProps)
+  assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
   tail = element.get_text(yy_element_stack[-1][0], 1)
   yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
   element.set_text(yy_element_stack[-1][0], 1, tail)
@@ -539,7 +539,7 @@ def yy_action34():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1Or2.DefaultPrec, value = True
+          xast.AST.Section1Or2.DefaultPrec, value = True
         )
       ]
     )
@@ -552,7 +552,7 @@ def yy_action35():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Section1Or2.DefaultPrec
+          xast.AST.Section1Or2.DefaultPrec
         )
       ]
     )
@@ -565,7 +565,7 @@ def yy_action36():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.BracedCode
+          xast.AST.BracedCode
         )
       ]
     )
@@ -575,7 +575,7 @@ def yy_action36():
       children = [
         element.concatenate(
           yy_element_stack[-2:-2],
-          ast.AST.ID
+          xast.AST.ID
         )
       ]
     )
@@ -585,15 +585,15 @@ def yy_action36():
       children = [
         element.concatenate(
           yy_element_stack[-4:],
-          ast.AST.Section1Or2.Code
+          xast.AST.Section1Or2.Code
         )
       ]
     )
   ]
   # most egregious (leftover from when we used to run code scanner on it):
-  assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.Code)
-  assert isinstance(yy_element_stack[-1][0][1], ast.AST.BracedCode)
-  assert isinstance(yy_element_stack[-1][0][1][0], ast.AST.Text)
+  assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.Code)
+  assert isinstance(yy_element_stack[-1][0][1], xast.AST.BracedCode)
+  assert isinstance(yy_element_stack[-1][0][1][0], xast.AST.Text)
   element.set_text(
     yy_element_stack[-1][0][1][0],
     0,
@@ -616,7 +616,7 @@ def yy_action37():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.BracedCode
+          xast.AST.BracedCode
         )
       ]
     )
@@ -626,15 +626,15 @@ def yy_action37():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1Or2.Code
+          xast.AST.Section1Or2.Code
         )
       ]
     )
   ]
   # most egregious (leftover from when we used to run code scanner on it):
-  assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.Code)
-  assert isinstance(yy_element_stack[-1][0][1], ast.AST.BracedCode)
-  assert isinstance(yy_element_stack[-1][0][1][0], ast.AST.Text)
+  assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.Code)
+  assert isinstance(yy_element_stack[-1][0][1], xast.AST.BracedCode)
+  assert isinstance(yy_element_stack[-1][0][1][0], xast.AST.Text)
   element.set_text(
     yy_element_stack[-1][0][1][0],
     0,
@@ -663,7 +663,7 @@ def yy_action40():
       children = [
         element.concatenate(
           yy_element_stack[len(yy_element_stack):],
-          ast.AST.ID
+          xast.AST.ID
         )
       ]
     )
@@ -682,7 +682,7 @@ def yy_action42():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.BracedCode
+          xast.AST.BracedCode
         )
       ]
     )
@@ -692,15 +692,15 @@ def yy_action42():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1Or2.Union
+          xast.AST.Section1Or2.Union
         )
       ]
     )
   ]
   # most egregious (leftover from when we used to run code scanner on it):
-  assert isinstance(yy_element_stack[-1][0], ast.AST.Section1Or2.Union)
-  assert isinstance(yy_element_stack[-1][0][1], ast.AST.BracedCode)
-  assert isinstance(yy_element_stack[-1][0][1][0], ast.AST.Text)
+  assert isinstance(yy_element_stack[-1][0], xast.AST.Section1Or2.Union)
+  assert isinstance(yy_element_stack[-1][0][1], xast.AST.BracedCode)
+  assert isinstance(yy_element_stack[-1][0][1][0], xast.AST.Text)
   element.set_text(
     yy_element_stack[-1][0][1][0],
     0,
@@ -723,7 +723,7 @@ def yy_action43():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1Or2.NTerm
+          xast.AST.Section1Or2.NTerm
         )
       ]
     )
@@ -736,7 +736,7 @@ def yy_action44():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section1Or2.Token
+          xast.AST.Section1Or2.Token
         )
       ]
     )
@@ -749,7 +749,7 @@ def yy_action45():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1Or2.Type
+          xast.AST.Section1Or2.Type
         )
       ]
     )
@@ -762,7 +762,7 @@ def yy_action46():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section1Or2.Precedence, _type = ((yystack[-4][1]) & 3) - 1
+          xast.AST.Section1Or2.Precedence, _type = ((yystack[-4][1]) & 3) - 1
         )
       ]
     )
@@ -802,7 +802,7 @@ def yy_action55():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -815,7 +815,7 @@ def yy_action56():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.SymbolRef, user_token = (yystack[-2][1])
+          xast.AST.SymbolRef, user_token = (yystack[-2][1])
         )
       ]
     )
@@ -828,7 +828,7 @@ def yy_action57():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -841,7 +841,7 @@ def yy_action58():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -860,7 +860,7 @@ def yy_action61():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -888,7 +888,7 @@ def yy_action67():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -901,7 +901,7 @@ def yy_action68():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.SymbolRef, user_token = (yystack[-2][1])
+          xast.AST.SymbolRef, user_token = (yystack[-2][1])
         )
       ]
     )
@@ -914,7 +914,7 @@ def yy_action69():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -927,7 +927,7 @@ def yy_action70():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.SymbolRef, user_token = (yystack[-3][1])
+          xast.AST.SymbolRef, user_token = (yystack[-3][1])
         )
       ]
     )
@@ -961,7 +961,7 @@ def yy_action78():
       children = [
         element.concatenate(
           yy_element_stack[-5:-4],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -971,7 +971,7 @@ def yy_action78():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Section2.Rules
+          xast.AST.Section2.Rules
         )
       ]
     )
@@ -984,7 +984,7 @@ def yy_action79():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Production
+          xast.AST.Production
         )
       ]
     )
@@ -997,7 +997,7 @@ def yy_action80():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Production
+          xast.AST.Production
         )
       ]
     )
@@ -1025,7 +1025,7 @@ def yy_action83():
       children = [
         element.concatenate(
           yy_element_stack[-3:-2],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -1035,7 +1035,7 @@ def yy_action83():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Production.SymbolRef
+          xast.AST.Production.SymbolRef
         )
       ]
     )
@@ -1048,7 +1048,7 @@ def yy_action84():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Production.Action
+          xast.AST.Production.Action
         )
       ]
     )
@@ -1058,9 +1058,9 @@ def yy_action84():
   lex_yy_code.yytext = '' # fool unput()
   lex_yy_code.unput((yystack[-3][1]))
   lex_yy_code.sc_context = lex_yy_code.SC_RULE_ACTION # CODE_PROPS_RULE_ACTION
-  lex_yy_code.yylex(ast.AST.Text)
-  assert isinstance(yy_element_stack[-1][0], ast.AST.Production.Action)
-  assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+  lex_yy_code.yylex(xast.AST.Text)
+  assert isinstance(yy_element_stack[-1][0], xast.AST.Production.Action)
+  assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
   tail = element.get_text(yy_element_stack[-1][0], 1)
   yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
   element.set_text(yy_element_stack[-1][0], 1, tail)
@@ -1074,7 +1074,7 @@ def yy_action86():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Production.Empty
+          xast.AST.Production.Empty
         )
       ]
     )
@@ -1087,7 +1087,7 @@ def yy_action87():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.SymbolRef
+          xast.AST.SymbolRef
         )
       ]
     )
@@ -1097,7 +1097,7 @@ def yy_action87():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Production.Prec
+          xast.AST.Production.Prec
         )
       ]
     )
@@ -1110,7 +1110,7 @@ def yy_action88():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Production.DPrec, value = (yystack[-2][1])
+          xast.AST.Production.DPrec, value = (yystack[-2][1])
         )
       ]
     )
@@ -1123,7 +1123,7 @@ def yy_action89():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Production.Merge
+          xast.AST.Production.Merge
         )
       ]
     )
@@ -1136,7 +1136,7 @@ def yy_action90():
       children = [
         element.concatenate(
           yy_element_stack[-5:],
-          ast.AST.Production.GroupElement
+          xast.AST.Production.GroupElement
         )
       ]
     )
@@ -1146,9 +1146,9 @@ def yy_action90():
   lex_yy_code.yytext = '' # fool unput()
   lex_yy_code.unput((yystack[-4][1])[4:-1])
   lex_yy_code.sc_context = lex_yy_code.SC_RULE_ACTION # CODE_PROPS_RULE_ACTION
-  lex_yy_code.yylex(ast.AST.Text)
-  assert isinstance(yy_element_stack[-1][0], ast.AST.Production.GroupElement)
-  assert isinstance(yy_element_stack[-1][0][0], ast.AST.Text)
+  lex_yy_code.yylex(xast.AST.Text)
+  assert isinstance(yy_element_stack[-1][0], xast.AST.Production.GroupElement)
+  assert isinstance(yy_element_stack[-1][0][0], xast.AST.Text)
   tail = element.get_text(yy_element_stack[-1][0], 1)
   yy_element_stack[-1][0][0] = lex_yy_code.yy_element_space
   element.set_text(yy_element_stack[-1][0], 1, tail)
@@ -1159,7 +1159,7 @@ def yy_action91():
       children = [
         element.concatenate(
           yy_element_stack[-1:],
-          ast.AST.Production.Space
+          xast.AST.Production.Space
         )
       ]
     )
@@ -1232,7 +1232,7 @@ def yy_action107():
       children = [
         element.concatenate(
           yy_element_stack[-3:],
-          ast.AST.Section3
+          xast.AST.Section3
         )
       ]
     )
diff --git a/fix_bootstrap.sh b/fix_bootstrap.sh
new file mode 100755 (executable)
index 0000000..2da176f
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# note that both ast and _ast are reserved module names in recent Python
+# so we will use x prefix for disambiguation instead of _ as we usually do
+
+for i in bootstrap_pilex bootstrap_piyacc
+do
+  sed -e 's/ast/xast/g; s/\([A-Za-z]\)xast/\1ast/g' -i $i/*.py $i/*.l $i/*.y
+  git mv $i/ast.py $i/xast.py
+done