yy_push_state(CODEBLOCK)
indented_code = True
#add_action(yytext)
- markup_push() # ast.AST.Section1Or2.CodeBlock
- markup_push() # ast.AST.Text
+ markup_push(ast.AST.Section1Or2.CodeBlock)
+ markup_push(ast.AST.Text)
}
^"/*" {
#add_action('/*[' '[')
#add_action('[' '[')
yy_push_state(CODEBLOCK)
indented_code = False
- markup_push() # ast.AST.Section1Or2.CodeBlock
+ markup_push(ast.AST.Section1Or2.CodeBlock)
markup_flush(len(yytext))
- markup_push() # ast.AST.Text
+ markup_push(ast.AST.Text)
}
^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
global brace_start_line, brace_depth
#add_action(']' ']')
#if not indented_code:
# line_directive_out(None, 0)
- markup_pop(ast.AST.Text)
+ markup_pop() # ast.AST.Text
markup_flush(len(yytext))
- markup_pop(ast.AST.Section1Or2.CodeBlock)
+ markup_pop() # ast.AST.Section1Or2.CodeBlock
}
[^\n%\[\]]* #add_action(yytext)
. #add_action(yytext)
#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() # ast.AST.Text
+ markup_pop() # ast.AST.Section1Or2.CodeBlock
}
}
yy_push_state(CODEBLOCK)
indented_code = True
#add_action(yytext)
- markup_push() # ast.AST.Section1Or2.CodeBlock
- markup_push() # ast.AST.Text
+ markup_push(ast.AST.Section1Or2.CodeBlock)
+ markup_push(ast.AST.Text)
}
^{NOT_WS}.* {
yy_push_state(CODEBLOCK)
indented_code = True
#add_action(yytext)
- markup_push() # ast.AST.Section1Or2.CodeBlock
- markup_push() # ast.AST.Text
+ markup_push(ast.AST.Section1Or2.CodeBlock)
+ markup_push(ast.AST.Text)
}
. #add_action(yytext)
bracelevel = 1
BEGIN(PERCENT_BRACE_ACTION)
markup_flush(len(yytext) - 2)
- markup_push() # ast.AST.Section1Or2.CodeBlock
+ markup_push(ast.AST.Section1Or2.CodeBlock)
markup_flush(2)
- markup_push() # ast.AST.Text
+ markup_push(ast.AST.Text)
}
^{OPTWS}"<" {
bracelevel = 1
BEGIN(PERCENT_BRACE_ACTION)
markup_flush(len(yytext) - 2)
- markup_push() # ast.AST.Section2.Rule.Action
+ markup_push(ast.AST.Section2.Rule.Action)
doing_rule_action = True
state.in_rule = False
markup_flush(2)
- markup_push() # ast.AST.Text
+ markup_push(ast.AST.Text)
}
{WS}(?E{ast.AST.Section2.Rule.Action, continued = True}"|".*{NL}) {
if state._sf_stk[-1] & 4:
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(ast.AST.Section2.Rule.Action)
+ markup_push(ast.AST.Text)
}
{OPTWS}{NL} {
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(ast.AST.Section2.Rule.Action)
+ markup_push(ast.AST.Text)
}
^{OPTWS}"<<EOF>>" |
yy_push_state(ACTION_GROUP)
bracelevel = 1
markup_flush(len(yytext))
- markup_push() # regex.RegexGroupAction.Text
+ markup_push(regex.RegexGroupAction.Text)
}
"E{" {
global bracelevel
yy_push_state(ELEMENT_GROUP)
bracelevel = 1
markup_flush(len(yytext))
- markup_push() # RegexGroupElement.Text
+ markup_push(regex.RegexGroupElement.Text)
}
":" {
BEGIN(SECT2)
{OPTWS}"%}".* {
global bracelevel
bracelevel = 0
- markup_pop(ast.AST.Text)
+ markup_pop() # ast.AST.Text
}
<ACTION>"/*" {
doing_rule_action = False
BEGIN(SECT2)
markup_flush(len(yytext))
+ markup_pop() # as below
if doing_codeblock:
- markup_pop(ast.AST.Section1Or2.CodeBlock)
+ # ast.AST.Section1Or2.CodeBlock
doing_codeblock = False
else:
- markup_pop(ast.AST.Section2.Rule.Action)
+ # ast.AST.Section2.Rule.Action
return ord('\n')
}
}
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() # ast.AST.Text
+ markup_pop() # ast.AST.Section2.Rule.Action
return ord('\n')
}
. #add_action(yytext)
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() # ast.AST.Text
+ markup_pop() # ast.AST.Section2.Rule.Action
return '\n'
else:
BEGIN(ACTION)
bracelevel -= 1
if bracelevel == 0:
yy_pop_state()
- markup_pop(regex.RegexGroupAction.Text)
+ markup_pop() # regex.RegexGroupAction.Text
return y_tab.TOK_ACTION_GROUP
}
}
bracelevel -= 1
if bracelevel == 0:
yy_pop_state()
- markup_pop(regex.RegexGroupElement.Text)
+ markup_pop() # regex.RegexGroupElement.Text
return y_tab.TOK_ELEMENT_GROUP
}
}
element.get_text(yy_element_token, 0)[:n]
)
-def markup_push():
+def markup_push(factory, *args, **kwargs):
global yy_element_space
markup_stack.append(yy_element_space)
- yy_element_space = element.Element('root')
+ yy_element_space = factory(*args, **kwargs)
-def markup_pop(factory, *args, **kwargs):
+def markup_pop():
global yy_element_space
_element = markup_stack.pop()
- _element.append(
- factory(
- text = element.get_text(yy_element_space, 0),
- children = yy_element_space[:],
- *args,
- **kwargs
- )
- )
+ _element.append(yy_element_space)
+ #element.set_text(_element, len(_element), '')
yy_element_space = _element