<CODEBLOCK>{
^"%}".*{NL} {
state.linenum += 1
- piece_insert(markup_stack.pop(), '<AST_Text>')
- piece_append('</AST_Text>')
- piece_flush(len(yytext))
yy_pop_state()
#add_action(']' ']')
#if not indented_code:
# line_directive_out(None, 0)
+ piece_insert(markup_stack.pop(), '<AST_Text>')
+ piece_append('</AST_Text>')
+ piece_flush(len(yytext))
piece_insert(markup_stack.pop(), '<AST_Section1Or2_CodeBlock>')
piece_append('</AST_Section1Or2_CodeBlock>')
}
state.linenum += 1
#add_action(yytext)
if indented_code:
- piece_flush(len(yytext))
- piece_insert(markup_stack.pop(), '<AST_Text>')
- piece_append('</AST_Text>')
yy_pop_state()
#add_action(']' ']')
#if not indented_code:
# line_directive_out(None, 0)
+ piece_flush(len(yytext))
+ piece_insert(markup_stack.pop(), '<AST_Text>')
+ piece_append('</AST_Text>')
piece_insert(markup_stack.pop(), '<AST_Section1Or2_CodeBlock>')
piece_append('</AST_Section1Or2_CodeBlock>')
}
{WS}"%{" {
global bracelevel, doing_rule_action
+ if not state.in_rule:
+ state.synerr('action outside rule')
bracelevel = 1
BEGIN(PERCENT_BRACE_ACTION)
piece_flush(len(yytext) - 2)
markup_stack.append(len(piece)) # <AST_Section2_Rule_Action>
- assert state.in_rule # should do error message here
doing_rule_action = True
state.in_rule = False
piece_flush(2)
}
{WS}"|".*{NL} {
if state._sf_stk[-1] & 4:
- amt = int(strchr(yytext, ord('|')) - yytext)
- yyless(amt)
+ yyless(yytext.index('|'))
else:
#add_action(']' ']')
continued_action = True
doing_rule_action = True
state.in_rule = False
piece_flush(len(yytext))
- piece_append('<AST_Section2_Rule_Action><AST_Text>')
+ markup_stack.append(len(piece)) # <AST_Section2_Rule_Action>
+ markup_stack.append(len(piece)) # <AST_Text>
}
{OPTWS}{NL} {
doing_rule_action = True
state.in_rule = False
piece_flush(len(yytext))
- piece_append('<AST_Section2_Rule_Action><AST_Text>')
+ markup_stack.append(len(piece)) # <AST_Section2_Rule_Action>
+ markup_stack.append(len(piece)) # <AST_Text>
}
^{OPTWS}"<<EOF>>" |
if bracelevel <= 0 or doing_codeblock and indented_code:
#if doing_rule_action:
# add_action('\tYY_BREAK]' ']\n')
- piece_flush(len(yytext))
doing_rule_action = False
BEGIN(SECT2)
+ piece_flush(len(yytext))
if doing_codeblock:
piece_insert(markup_stack.pop(), '<AST_Section1Or2_CodeBlock>')
piece_append('</AST_Section1Or2_CodeBlock>')
if bracelevel <= 0:
BEGIN(SECT2)
if doing_rule_action:
+ doing_rule_action = False
#add_action('\tYY_BREAK]' ']\n')
piece_flush(len(yytext))
- piece_append('</AST_Text></AST_Section2_Rule_Action>')
- doing_rule_action = False
+ piece_insert(markup_stack.pop(), '<AST_Text>')
+ piece_append('</AST_Text>')
+ piece_insert(markup_stack.pop(), '<AST_Section2_Rule_Action>')
+ piece_append('</AST_Section2_Rule_Action>')
return ord('\n')
}
. #add_action(yytext)
BEGIN(SECT2)
piece_flush(len(yytext))
if doing_rule_action:
- piece_append('</AST_Text></AST_Section2_Rule_Action>')
doing_rule_action = False # Nick added, error in the original?
+ piece_insert(markup_stack.pop(), '<AST_Text>')
+ piece_append('</AST_Text>')
+ piece_insert(markup_stack.pop(), '<AST_Section2_Rule_Action>')
+ piece_append('</AST_Section2_Rule_Action>')
return '\n'
else:
BEGIN(ACTION)