Fix a typo in non-groups Python skeleton (introduced with last commit), remove some...
authorNick Downing <nick@ndcode.org>
Tue, 17 May 2022 07:22:35 +0000 (17:22 +1000)
committerNick Downing <nick@ndcode.org>
Tue, 17 May 2022 07:22:35 +0000 (17:22 +1000)
ndcode/pilex/generate_flex.py
ndcode/pilex/generate_py.py
ndcode/pilex/skel/skel_py.py

index 2e37688..bca58bc 100644 (file)
@@ -32,6 +32,11 @@ def generate_flex(_ast, _element, groups, home_dir, skel_file, out_file):
       [(-1, -1) for j in range(len(_ast.flex_rules[i].groups1))]
     )
 
+  # add group for default rule
+  group_ref_data.append(
+    (len(_ast.flex_rules) * 2, len(_ast.flex_rules) * 2 + 1)
+  )
+
   _nfa = _ast.to_nfa(group_ref_data)
 
   # end of buffer expression (do here because only necessary for flex)
index 7f29bc8..b5dbc3e 100644 (file)
@@ -70,6 +70,11 @@ def generate_py(_ast, _element, groups, home_dir, skel_file, out_file):
         [(-1, -1) for j in range(len(_ast.flex_rules[i].groups1))]
       )
 
+    # add group for default rule
+    group_ref_data.append(
+      (len(_ast.flex_rules) * 2, len(_ast.flex_rules) * 2 + 1)
+    )
+
     _nfa = _ast.to_nfa(group_ref_data)
 
     # end of buffer expression (do here because only necessary for flex)
index da776b7..888303f 100644 (file)
@@ -122,7 +122,7 @@ def yycommit():
   # we leave yytext == 0 afterwards, so double commit is OK
   # (double commit occurs if user calls the unput function)
   global yytext_len
-  print('commit', yytext_len)
+  #print('commit', yytext_len)
   while yytext_len:
     block = yy_buffer_stack[-1].next
     while block is None or block.pos >= len(block.text):
@@ -205,7 +205,7 @@ def yylex():
     del yy_state_buf[:]
 
     # yy_match:
-    print('yy_match')
+    #print('yy_match')
     while True:
       # try to get a character
       while block is None or block_pos >= len(block.text):
@@ -261,7 +261,7 @@ def yylex():
         # character available
         yy_state_buf.append(yy_current_state)
         yy_c = ord(block.text[block_pos])
-        print('yy_c', yy_c)
+        #print('yy_c', yy_c)
         while yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state:
           yy_current_state = yy_def[yy_current_state];
         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -285,7 +285,7 @@ def yylex():
     i = yy_state_ptr - len(match)
     if i:
       match += block.text[block_pos - i:block_pos]
-    assert len(match) = yy_state_ptr
+    assert len(match) == yy_state_ptr
 
     # yy_find_action:
     # the following variables are used to handle trailing context