# special exception.
import bisect
-import element
import sys
+from ndcode.piyacc import element
+
+# this can be redefined in SECTION1
+def YY_AT_BOL():
+ return yy_buffer_stack[-1].at_bol
+
+def yy_set_bol(at_bol):
+ yy_buffer_stack[-1].at_bol = at_bol
+
+def YY_USER_ACTION():
+ pass
+
+def YY_RULE_START():
+ # note that this should also be done after yyless() and REJECT(),
+ # and state should be saved in case they result in a null string,
+ # however, it doesn't seem to be in flex, maintain compatibility:
+ if len(yytext):
+ yy_set_bol(yytext[-1] == '\n')
+ YY_USER_ACTION()
# GENERATE SECTION1
yytext = yy_group_text[:yy_group_stack[-1]]
yytext_len = yy_group_stack[-1]
del yy_group_stack[-2:]
- # note that this should also be done after yyless() and REJECT(),
- # and state should be saved in case they result in a null string,
- # however, it doesn't seem to be in flex, maintain compatibility:
- if len(yytext):
- yy_buffer_stack[-1].at_bol = yytext[-1] == '\n'
+ YY_RULE_START()
yy_element_stack.append([])
def yy_group_end():
def yy_group_end_element():
yy_element_stack.append([])
-def yy_group_element(pos0, pos1, stack, factory, *args, **kwargs):
- _element = factory(*args, **kwargs)
+def yy_group_element(pos0, pos1, stack, _class, *args, **kwargs):
+ _element = _class(*args, **kwargs)
del _element.text[:]
for pos2, pos3, i in reversed(stack):
_element.text.append(yy_group_text[pos0:pos2])
global yystart
yystart = yystart_stack.pop()
-def YY_AT_BOL():
- return yy_buffer_stack[-1].at_bol
-
-def yy_set_bol(at_bol):
- yy_buffer_stack[-1].at_bol = at_bol
-
# GENERATE SECTION2
-def yylex(factory = element.Element, *args, **kwargs):
+def yylex(_class = element.Element, *args, **kwargs):
global \
yyin, \
yy_threads0, \
# GENERATE SECTION2INITIAL
- yy_element_space = factory(*args, **kwargs)
- yy_element_token = factory(*args, **kwargs)
+ yy_element_space = _class(*args, **kwargs)
+ yy_element_token = _class(*args, **kwargs)
while True:
while yytext_len:
block = yy_buffer_stack[-1].next
0,
yytext_len,
yy_element_stack.pop(),
- factory,
+ _class,
*args,
**kwargs
)