Modify the parser/scanner interface to remove markup_action(), markup_option()
authorNick Downing <nick@ndcode.org>
Sat, 19 Jan 2019 12:41:05 +0000 (23:41 +1100)
committerNick Downing <nick@ndcode.org>
Sat, 19 Jan 2019 12:41:05 +0000 (23:41 +1100)
bootstrap/n.sh
bootstrap/parse.y
bootstrap/scan.l

index 3804e33..4d9d97b 100755 (executable)
@@ -12,12 +12,12 @@ then
   rm lex.yy.c
 fi
 ./markup.py <../tests/cal.l >out/cal.l.xml
-diff --unified out/cal.l.xml.ok out/cal.l.xml
+diff -q out/cal.l.xml.ok out/cal.l.xml
 ./markup.py <../../bootstrap_flex.git/src/scan.l >out/scan.l.xml
-diff --unified out/scan.l.xml.ok out/scan.l.xml
+diff -q out/scan.l.xml.ok out/scan.l.xml
 ./markup.py <../../bootstrap_bison.git/src/scan-code.l >out/scan-code.l.xml
-diff --unified out/scan-code.l.xml.ok out/scan-code.l.xml
+diff -q out/scan-code.l.xml.ok out/scan-code.l.xml
 ./markup.py <../../bootstrap_bison.git/src/scan-gram.l >out/scan-gram.l.xml
-diff --unified out/scan-gram.l.xml.ok out/scan-gram.l.xml
+diff -q out/scan-gram.l.xml.ok out/scan-gram.l.xml
 ./markup.py <../../bootstrap_bison.git/src/scan-skel.l >out/scan-skel.l.xml
-diff --unified out/scan-skel.l.xml.ok out/scan-skel.l.xml
+diff -q out/scan-skel.l.xml.ok out/scan-skel.l.xml
index cc071f3..8f50edd 100644 (file)
@@ -15,6 +15,9 @@
 /* Nick extra rules for action groups */
 %token TOK_ACTION_GROUP TOK_ELEMENT_GROUP
 
+/* Nick temporary, until options processing moved fully into parser */
+%token TOK_OPTION_OTHER
+
 /*
  *POSIX and AT&T lex place the
  * precedence of the repeat operator, {}, below that of concatenation.
@@ -196,6 +199,8 @@ option
       insert_after(2, '</AST_Section1_Options_TablesFile>')
       insert_before(0, '<AST_Section1_Options_TablesFile>')
     }
+  /* Nick */
+  | TOK_OPTION_OTHER
   ;
 
 sect2
index 7095c1b..e766394 100644 (file)
@@ -12,7 +12,7 @@
   didadef = False
   indented_code = False
   doing_rule_action = False
-  option_sense = False
+  #option_sense = False
 
   doing_codeblock = False
   brace_depth = 0
@@ -309,414 +309,942 @@ M4QEND      "]""]"
   }
 }
 
-
+ /* Nick added ("no"*) prefix to all, instead of it being a separate rule */
 <OPTION>{
-  {NL} {
+  ("no"*){NL} {
     state.linenum += 1
     BEGIN(INITIAL)
   }
-  {WS} {
-    global option_sense
-    option_sense = True
+  ("no"*){WS} {
+    #global option_sense
+    #option_sense = True
   }
 
-  "="                          return ord('=')
+  ("no"*)"="                   return ord('=')
 
-  no {
+  /*no {
     global option_sense
     option_sense = not option_sense
-  }
+  }*/
 
-  7bit {
+  ("no"*)7bit {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #csize = 128 if option_sense else 256
-    markup_option('SevenBit', option_sense)
+    piece_append(
+      '<AST_Section1_Options_SevenBit{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_SevenBit>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  8bit {
+  ("no"*)8bit {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #csize = 256 if option_sense else 128
-    markup_option('SevenBit', not option_sense)
+    piece_append(
+      '<AST_Section1_Options_SevenBit{0:s}>'.format(
+        ' value="true"' if not option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_SevenBit>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  align {
+  ("no"*)align {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #long_align = option_sense
-    markup_option('Align', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Align{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Align>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  always-interactive {
+  ("no"*)always-interactive {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_ALWAYS_INTERACTIVE', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_ALWAYS_INTERACTIVE')
     #interactive = option_sense
-    markup_option('AlwaysInteractive', option_sense)
+    piece_append(
+      '<AST_Section1_Options_AlwaysInteractive{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_AlwaysInteractive>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  array {
+  ("no"*)array {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #yytext_is_array = option_sense
-    markup_option('Array', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Array{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Array>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  backup {
+  ("no"*)backup {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #backing_up_report = option_sense
-    markup_option('Backup', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Backup{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Backup>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  batch {
+  ("no"*)batch {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #interactive = not option_sense
-    markup_option('Interactive', not option_sense)
+    piece_append(
+      '<AST_Section1_Options_Interactive{0:s}>'.format(
+        ' value="true"' if not option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Interactive>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  bison-bridge {
+  ("no"*)bison-bridge {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #bison_bridge_lval = option_sense
-    markup_option('BisonBridge', option_sense)
+    piece_append(
+      '<AST_Section1_Options_BisonBridge{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_BisonBridge>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  bison-locations {
+  ("no"*)bison-locations {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if bison_bridge_lloc = option_sense:
     #  bison_bridge_lval = True
-    markup_option('BisonLocations', option_sense)
+    piece_append(
+      '<AST_Section1_Options_BisonLocations{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_BisonLocations>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
   "c++" {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #C_plus_plus = option_sense
-    markup_option('CPlusPlus', option_sense)
+    piece_append(
+      '<AST_Section1_Options_CPlusPlus{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_CPlusPlus>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  caseful|case-sensitive {
+  ("no"*)caseful|case-sensitive {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     if not option_sense:
       state._sf_stk[-1] |= 1
     else:
       state._sf_stk[-1] &= ~1
-    markup_option('Caseless', not option_sense)
+    piece_append(
+      '<AST_Section1_Options_Caseless{0:s}>'.format(
+        ' value="true"' if not option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Caseless>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  caseless|case-insensitive {
+  ("no"*)caseless|case-insensitive {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     if option_sense:
       state._sf_stk[-1] |= 1
     else:
       state._sf_stk[-1] &= ~1
-    markup_option('Caseless', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Caseless{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Caseless>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  debug {
+  ("no"*)debug {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #ddebug = option_sense
-    markup_option('Debug', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Debug{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Debug>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  default {
+  ("no"*)default {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #spprdflt = not option_sense
-    markup_option('Default', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Default{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Default>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  ecs {
+  ("no"*)ecs {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #useecs = option_sense
-    markup_option('ECS', option_sense)
+    piece_append(
+      '<AST_Section1_Options_ECS{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_ECS>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  fast {
+  ("no"*)fast {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #useecs = usemecs = False
     #use_read = fullspd = True
-    markup_option('Fast', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Fast{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Fast>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  full {
+  ("no"*)full {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #useecs = usemecs = False
     #use_read = fulltbl = True
-    markup_option('Full', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Full{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Full>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  input {
+  ("no"*)input {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  action_define('YY_NO_INPUT', 1)
-    markup_option('Input', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Input{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Input>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  interactive {
+  ("no"*)interactive {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #interactive = option_sense
-    markup_option('Interactive', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Interactive{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Interactive>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  lex-compat {
+  ("no"*)lex-compat {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     state.lex_compat = option_sense
-    markup_option('LexCompat', option_sense)
+    piece_append(
+      '<AST_Section1_Options_LexCompat{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_LexCompat>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  posix-compat {
+  ("no"*)posix-compat {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     state.posix_compat = option_sense
-    markup_option('PosixCompat', option_sense)
+    piece_append(
+      '<AST_Section1_Options_PosixCompat{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_PosixCompat>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  line {
+  ("no"*)line {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #gen_line_dirs = option_sense
-    markup_option('Line', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Line{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Line>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  main {
+  ("no"*)main {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_MAIN', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_MAIN')
     #if option_sense:
     #  do_yywrap = False
-    markup_option('Main', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Main{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Main>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  meta-ecs {
+  ("no"*)meta-ecs {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #usemecs = option_sense
-    markup_option('MetaECS', option_sense)
+    piece_append(
+      '<AST_Section1_Options_MetaECS{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_MetaECS>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  never-interactive {
+  ("no"*)never-interactive {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NEVER_INTERACTIVE', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NEVER_INTERACTIVE')
     #interactive = not option_sense
-    markup_option('NeverInteractive', option_sense)
+    piece_append(
+      '<AST_Section1_Options_NeverInteractive{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_NeverInteractive>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  perf-report {
+  ("no"*)perf-report {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #performance_report += 1 if option_sense else -1
-    markup_option('PerfReport', option_sense)
+    piece_append(
+      '<AST_Section1_Options_PerfReport{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_PerfReport>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  pointer {
+  ("no"*)pointer {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #yytext_is_array = not option_sense
-    markup_option('Array', not option_sense)
+    piece_append(
+      '<AST_Section1_Options_Array{0:s}>'.format(
+        ' value="true"' if not option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Array>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  read {
+  ("no"*)read {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #use_read = option_sense
-    markup_option('Read', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Read{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Read>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  reentrant {
+  ("no"*)reentrant {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #reentrant = option_sense
-    markup_option('Reentrant', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Reentrant{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Reentrant>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  reject {
+  ("no"*)reject {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #reject_really_used = option_sense
-    markup_option('Reject', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Reject{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Reject>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  stack {
+  ("no"*)stack {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_STACK_USED', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_STACK_USED')
-    markup_option('Stack', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Stack{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Stack>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  stdinit {
+  ("no"*)stdinit {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #do_stdinit = option_sense
-    markup_option('StdInit', option_sense)
+    piece_append(
+      '<AST_Section1_Options_StdInit{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_StdInit>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  stdout {
+  ("no"*)stdout {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #use_stdout = option_sense
-    markup_option('StdOut', option_sense)
+    piece_append(
+      '<AST_Section1_Options_StdOut{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_StdOut>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  unistd {
+  ("no"*)unistd {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  action_define('YY_NO_UNISTD_H', 1)
-    markup_option('UniStd', option_sense)
+    piece_append(
+      '<AST_Section1_Options_UniStd{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_UniStd>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  unput {
+  ("no"*)unput {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_UNPUT', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_UNPUT')
-    markup_option('Unput', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Unput{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Unput>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  verbose {
+  ("no"*)verbose {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #printstats = option_sense
-    markup_option('Verbose', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Verbose{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Verbose>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  warn {
+  ("no"*)warn {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #nowarn = not option_sense
-    markup_option('Warn', option_sense)
+    piece_append(
+      '<AST_Section1_Options_Warn{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_Warn>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yylineno {
+  ("no"*)yylineno {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #do_yylineno = option_sense
     #if option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_USE_LINENO', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_USE_LINENO')
-    markup_option('YYLineNo', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYLineNo{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYLineNo>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yymore {
+  ("no"*)yymore {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #yymore_really_used = option_sense
-    markup_option('YYMore', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYMore{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYMore>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yywrap {
+  ("no"*)yywrap {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #do_yywrap = option_sense
-    markup_option('YYWrap', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYWrap{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYWrap>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  yy_push_state {
+  ("no"*)yy_push_state {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_PUSH_STATE', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_PUSH_STATE')
-    markup_option('YYPushState', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYPushState{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYPushState>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yy_pop_state {
+  ("no"*)yy_pop_state {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_POP_STATE', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_POP_STATE')
-    markup_option('YYPopState', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYPopState{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYPopState>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yy_top_state {
+  ("no"*)yy_top_state {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_TOP_STATE', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_TOP_STATE')
-    markup_option('YYTopState', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYTopState{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYTopState>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  yy_scan_buffer {
+  ("no"*)yy_scan_buffer {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SCAN_BUFFER', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SCAN_BUFFER')
-    markup_option('YYScanBuffer', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYScanBuffer{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYScanBuffer>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yy_scan_bytes {
+  ("no"*)yy_scan_bytes {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SCAN_BYTES', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SCAN_BYTES')
-    markup_option('YYScanBytes', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYScanBytes{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYScanBytes>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yy_scan_string {
+  ("no"*)yy_scan_string {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SCAN_STRING', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SCAN_STRING')
-    markup_option('YYScanString', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYScanString{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYScanString>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  yyalloc {
+  ("no"*)yyalloc {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_FLEX_ALLOC', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_FLEX_ALLOC')
-    markup_option('YYAlloc', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYAlloc{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYAlloc>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyrealloc {
+  ("no"*)yyrealloc {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_FLEX_REALLOC', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_FLEX_REALLOC')
-    markup_option('YYRealloc', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYRealloc{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYRealloc>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyfree {
+  ("no"*)yyfree {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_FLEX_FREE', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_FLEX_FREE')
-    markup_option('YYFree', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYFree{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYFree>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
 
-  yyget_debug {
+  ("no"*)yyget_debug {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_DEBUG', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_DEBUG')
-    markup_option('YYGetDebug', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetDebug{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetDebug>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyset_debug {
+  ("no"*)yyset_debug {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_DEBUG', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SET_DEBUG')
-    markup_option('YYSetDebug', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYSetDebug{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYSetDebug>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_extra {
+  ("no"*)yyget_extra {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_EXTRA', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_EXTRA')
-    markup_option('YYGetExtra', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetExtra{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetExtra>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyset_extra {
+  ("no"*)yyset_extra {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_EXTRA', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SET_EXTRA')
-    markup_option('YYSetExtra', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYSetExtra{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYSetExtra>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_leng {
+  ("no"*)yyget_leng {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LENG', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_LENG')
-    markup_option('YYGetLeng', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetLeng{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetLeng>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_text {
+  ("no"*)yyget_text {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_TEXT', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_TEXT')
-    markup_option('YYGetText', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetText{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetText>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_lineno {
+  ("no"*)yyget_lineno {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LINENO', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_LINENO')
-    markup_option('YYGetLineNo', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetLineNo{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetLineNo>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyset_lineno {
+  ("no"*)yyset_lineno {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_LINENO', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SET_LINENO')
-    markup_option('YYSetLineNo', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYSetLineNo{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYSetLineNo>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_in {
+  ("no"*)yyget_in {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_IN', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_IN')
-    markup_option('YYGetIn', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetIn{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetIn>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyset_in {
+  ("no"*)yyset_in {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_IN', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SET_IN')
-    markup_option('YYSetIn', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYSetIn{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYSetIn>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_out {
+  ("no"*)yyget_out {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_OUT', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_OUT')
-    markup_option('YYGetOut', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetOut{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetOut>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyset_out {
+  ("no"*)yyset_out {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_OUT', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SET_OUT')
-    markup_option('YYSetOut', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYSetOut{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYSetOut>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_lval {
+  ("no"*)yyget_lval {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LVAL', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_LVAL')
-    markup_option('YYGetLVal', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetLVal{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetLVal>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyset_lval {
+  ("no"*)yyset_lval {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_LVAL', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SET_LVAL')
-    markup_option('YYSetLVal', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYSetLVal{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYSetLVal>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyget_lloc {
+  ("no"*)yyget_lloc {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_GET_LLOC', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_GET_LLOC')
-    markup_option('YYGetLLoc', option_sense)
+    piece_append(
+      '<AST_Section1_Options_YYGetLLoc{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYGetLLoc>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
-  yyset_lloc {
+  ("no"*)yyset_lloc {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #if not option_sense:
     #  buf_m4_define(&m4defs_buf, 'M4' '_YY_NO_SET_LLOC', None)
     #else:
     #  buf_m4_undefine(&m4defs_buf, 'M4' '_YY_NO_SET_LLOC')
-    markup_option('YYSetLLoc', option_sense)
-  }
-
-  extra-type                   return y_tab.TOK_EXTRA_TYPE
-  outfile                      return y_tab.TOK_OUTFILE
-  prefix                       return y_tab.TOK_PREFIX
-  yyclass                      return y_tab.TOK_YYCLASS
-  header(-file)?               return y_tab.TOK_HEADER_FILE
-  tables-file                  return y_tab.TOK_TABLES_FILE
-  tables-verify {
+    piece_append(
+      '<AST_Section1_Options_YYSetLLoc{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_YYSetLLoc>')
+    return y_tab.TOK_OPTION_OTHER # Nick
+  }
+
+  ("no"*)extra-type            return y_tab.TOK_EXTRA_TYPE
+  ("no"*)outfile                       return y_tab.TOK_OUTFILE
+  ("no"*)prefix                        return y_tab.TOK_PREFIX
+  ("no"*)yyclass                       return y_tab.TOK_YYCLASS
+  ("no"*)header(-file)?                return y_tab.TOK_HEADER_FILE
+  ("no"*)tables-file           return y_tab.TOK_TABLES_FILE
+  ("no"*)tables-verify {
+    option_sense = (len(yy_groups[1]) & 2) == 0
     #tablesverify = option_sense
     #if not tablesext and option_sense:
     #  tablesext = True
-    markup_option('TablesVerify', option_sense)
+    piece_append(
+      '<AST_Section1_Options_TablesVerify{0:s}>'.format(
+        ' value="true"' if option_sense else ''
+      )
+    )
+    piece_flush(len(yytext))
+    piece_append('</AST_Section1_Options_TablesVerify>')
+    return y_tab.TOK_OPTION_OTHER # Nick
   }
 
 
-  \"[^"\n]*\" {
+  ("no"*)\"[^"\n]*\" {
     state.nmstr = yytext[1:-1]
     piece_pack()
     piece_append('<AST_String>"<AST_Text>')
@@ -726,7 +1254,7 @@ M4QEND      "]""]"
     return ~y_tab.NAME
   }
 
-  (([a-mo-z]|n[a-np-z])[[:alpha:]\-+]*)|. {
+  ("no"*)(([a-mo-z]|n[a-np-z])[[:alpha:]\-+]*)|. {
     state.synerr('unrecognized %option: {0:s}'.format(yytext))
     BEGIN(RECOVER)
   }
@@ -842,15 +1370,11 @@ M4QEND      "]""]"
     BEGIN(PERCENT_BRACE_ACTION)
     piece_flush(len(yytext) - 2)
     piece_append('<AST_Section2_Rule_Action>')
-    if state.in_rule:
-      doing_rule_action = True
-      state.in_rule = False
-      piece_pack()
-      piece_escape(yytext[:2])
-      piece_pack()
-      piece_append('<AST_Text>')
-      return ~ord('\n')
-    abort()
+    assert state.in_rule # should do error message here
+    doing_rule_action = True
+    state.in_rule = False
+    piece_flush(2)
+    piece_append('<AST_Text>')
   }
   {WS}"|".*{NL} {
     if state._sf_stk[-1] & 4:
@@ -864,12 +1388,10 @@ M4QEND      "]""]"
       while i < len(yytext) and yytext[i] in '\t ':
         i += 1
       piece_flush(i)
-      piece_pack()
       piece_append('<AST_Section2_Rule_Action continued="true">')
-      piece_escape(yytext)
+      piece_flush(len(yytext))
       piece_append('</AST_Section2_Rule_Action>')
-      piece_pack()
-      return ~ord('\n')
+      return ord('\n')
   }
 
   ^{WS}"/*" {
@@ -894,11 +1416,8 @@ M4QEND      "]""]"
       if state.in_rule:
         doing_rule_action = True
         state.in_rule = False
-        piece_pack()
-        piece_escape(yytext)
-        piece_pack()
+        piece_flush(len(yytext))
         piece_append('<AST_Section2_Rule_Action><AST_Text>')
-        return ~ord('\n')
   }
 
   {OPTWS}{NL} {
@@ -913,11 +1432,8 @@ M4QEND      "]""]"
       if state.in_rule:
         doing_rule_action = True
         state.in_rule = False
-        piece_pack()
-        piece_escape(yytext)
-        piece_pack()
+        piece_flush(len(yytext))
         piece_append('<AST_Section2_Rule_Action><AST_Text>')
-        return ~ord('\n')
   }
 
   ^{OPTWS}"<<EOF>>" |
@@ -1334,12 +1850,14 @@ M4QEND      "]""]"
       #if doing_rule_action:
       #  add_action('\tYY_BREAK]' ']\n')
       piece_flush(len(yytext))
+      doing_rule_action = False
+      BEGIN(SECT2)
       if doing_codeblock:
         piece_append('</AST_Section1Or2_CodeBlock>')
+        doing_codeblock = False
       else:
-        markup_action('</AST_Section2_Rule_Action>')
-      doing_rule_action = doing_codeblock = False
-      BEGIN(SECT2)
+        piece_append('</AST_Section2_Rule_Action>')
+        return ord('\n')
   }
 }
 
@@ -1372,12 +1890,13 @@ M4QEND      "]""]"
     state.linenum += 1
     #add_action(yytext)
     if bracelevel <= 0:
+      BEGIN(SECT2)
       if doing_rule_action:
         #add_action('\tYY_BREAK]' ']\n')
         piece_flush(len(yytext))
-        markup_action('</AST_Text></AST_Section2_Rule_Action>')
-      doing_rule_action = False
-      BEGIN(SECT2)
+        piece_append('</AST_Text></AST_Section2_Rule_Action>')
+        doing_rule_action = False
+        return ord('\n')
   }
   .                            #add_action(yytext)
 }
@@ -1406,7 +1925,9 @@ M4QEND      "]""]"
       BEGIN(SECT2)
       piece_flush(len(yytext))
       if doing_rule_action:
-        markup_action('</AST_Text></AST_Section2_Rule_Action>')
+        piece_append('</AST_Text></AST_Section2_Rule_Action>')
+        doing_rule_action = False # Nick added, error in the original?
+        return '\n'
     else:
       BEGIN(ACTION)
   }
@@ -1558,30 +2079,3 @@ def flexscan():
   piece_escape(yytext)
   piece_pack()
   return result
-
-def markup_action(text):
-  global piece0
-  piece0 -= 1
-  assert piece[piece0][-20:] == '</AST_Section2_Rule>'
-  piece[piece0] = piece[piece0][:-20]
-  piece_append(text)
-  piece_append('</AST_Section2_Rule>')
-  piece_pack()
-
-def markup_option(name, sense):
-  global piece0
-  i = len(piece) - 1
-  while i >= piece0 and piece[i] == 'no':
-    i -= 1
-  piece_insert(
-    i + 1,
-    '<AST_Section1_Options_{0:s}{1:s}>'.format(
-      name,
-      ' value="true"' if sense else ''
-    )
-  )
-  piece_flush(len(yytext))
-  piece_append('</AST_Section1_Options_{0:s}>'.format(name))
-  piece0 -= 1
-  piece_pack()
-