Make pilex.py standalone, fix accidentally deleted line of code which made the '...
authorNick Downing <nick@ndcode.org>
Sun, 20 Jan 2019 09:46:13 +0000 (20:46 +1100)
committerNick Downing <nick@ndcode.org>
Sun, 20 Jan 2019 09:46:13 +0000 (20:46 +1100)
bootstrap/n.sh
bootstrap/scan.l
n.sh
pilex.py
scan.l

index 4d9d97b..4208f2f 100755 (executable)
@@ -3,6 +3,7 @@ if ! test -d out
 then
   mkdir out
   ../../bootstrap_flex.git/src/flex -o /dev/null ../tests/cal.l 2>out/cal.l.xml.ok
+  ../../bootstrap_flex.git/src/flex -o /dev/null ../tests_ast/cal_py.l 2>out/cal_py.l.xml.ok
   ../../bootstrap_flex.git/src/flex -o /dev/null ../../bootstrap_flex.git/src/scan.l 2>out/scan.l.xml.ok
   ../../bootstrap_flex.git/src/flex ../../bootstrap_bison.git/src/scan-code.l 2>out/scan-code.l.xml.ok
   rm lex.yy.c
@@ -13,6 +14,8 @@ then
 fi
 ./markup.py <../tests/cal.l >out/cal.l.xml
 diff -q out/cal.l.xml.ok out/cal.l.xml
+./markup.py <../tests_ast/cal_py.l >out/cal_py.l.xml
+diff -q out/cal_py.l.xml.ok out/cal_py.l.xml
 ./markup.py <../../bootstrap_flex.git/src/scan.l >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
index e45cc38..bc407f2 100644 (file)
@@ -1816,12 +1816,12 @@ M4QEND      "]""]"
     <CODEBLOCK,ACTION>{
     "reject" {
       #add_action(yytext)
-      if all_upper(yytext):
+      if yytext.isupper():
         reject = True
     }
     "yymore" {
       #add_action(yytext)
-      if all_lower(yytext):
+      if yytext.islower():
         yymore_used = True
     }
   }
diff --git a/n.sh b/n.sh
index b72211f..b751478 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -3,6 +3,7 @@ if ! test -d out
 then
   mkdir out
   bootstrap/markup.py <tests/cal.l |./reserialize.py >out/cal.l.xml.ok
+  bootstrap/markup.py <tests_ast/cal_py.l |./reserialize.py >out/cal_py.l.xml.ok
   bootstrap/markup.py <../bootstrap_flex.git/src/scan.l |./reserialize.py >out/scan.l.xml.ok
   bootstrap/markup.py <../bootstrap_bison.git/src/scan-code.l |./reserialize.py >out/scan-code.l.xml.ok
   bootstrap/markup.py <../bootstrap_bison.git/src/scan-gram.l |./reserialize.py >out/scan-gram.l.xml.ok
@@ -10,6 +11,8 @@ then
 fi
 ./markup.py <tests/cal.l >out/cal.l.xml
 diff -q out/cal.l.xml.ok out/cal.l.xml
+./markup.py <tests_ast/cal_py.l >out/cal_py.l.xml
+diff -q out/cal_py.l.xml.ok out/cal_py.l.xml
 ./markup.py <../bootstrap_flex.git/src/scan.l >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
index c3be236..96b69a1 100755 (executable)
--- a/pilex.py
+++ b/pilex.py
@@ -44,7 +44,15 @@ if len(args) < 1:
 in_file = args[0]
 
 with open(in_file) as fin:
-  _ast = element.deserialize(fin, ast.factory)
+  if in_file[-4:] == '.xml':
+    _ast = element.deserialize(fin, ast.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()
diff --git a/scan.l b/scan.l
index f4392d7..4c9411b 100644 (file)
--- a/scan.l
+++ b/scan.l
@@ -1177,6 +1177,7 @@ M4QEND      "]""]"
     BEGIN(SECT2)
     yy_push_state(ELEMENT_GROUP)
     bracelevel = 1
+    markup_flush(len(yytext))
     markup_push() # RegexGroupElement.Text
   }
   ":" {
@@ -1378,12 +1379,12 @@ M4QEND      "]""]"
     <CODEBLOCK,ACTION>{
     "reject" {
       #add_action(yytext)
-      if all_upper(yytext):
+      if yytext.isupper():
         reject = True
     }
     "yymore" {
       #add_action(yytext)
-      if all_lower(yytext):
+      if yytext.islower():
         yymore_used = True
     }
   }