From: thurston Date: Wed, 25 Apr 2007 15:52:18 +0000 (+0000) Subject: Bug fix: when fhold was used in scanner pattern actions which get executed on X-Git-Tag: 2.0_alpha~312 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0016603a23275c179d0b81dd3628f431207f1a50;p=external%2Fragel.git Bug fix: when fhold was used in scanner pattern actions which get executed on the last character of the pattern (pattern matches which do not require any lookahead), fhold was modifying p instead of tokend. This was fixed and the patact.rl test was modified to cover the case. git-svn-id: http://svn.complang.org/ragel/trunk@195 052ea7fc-9027-0410-9066-f65837a77df0 --- diff --git a/ragel/xmlcodegen.cpp b/ragel/xmlcodegen.cpp index ede4d94..eba7e32 100644 --- a/ragel/xmlcodegen.cpp +++ b/ragel/xmlcodegen.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005, 2006 Adrian Thurston + * Copyright 2005-2007 Adrian Thurston */ /* This file is part of Ragel. @@ -206,26 +206,20 @@ void XMLCodeGen::writeText( InlineItem *item ) out << ""; } +bool isLmItem( InlineItem *context ) +{ + return context != 0 && ( + context->type == InlineItem::LmOnLast || + context->type == InlineItem::LmOnNext || + context->type == InlineItem::LmOnLagBehind || + context->type == InlineItem::LmSwitch ); +} + void XMLCodeGen::writeCtrlFlow( InlineItem *item, InlineItem *context ) { - if ( context != 0 ) { + if ( isLmItem( context ) ) { out << ""; - - switch ( context->type ) { - case InlineItem::LmOnLast: - out << ""; - break; - case InlineItem::LmOnNext: - out << ""; - break; - case InlineItem::LmOnLagBehind: - out << ""; - break; - case InlineItem::LmSwitch: - out << ""; - break; - default: break; - } + out << ""; } switch ( item->type ) { @@ -256,16 +250,13 @@ void XMLCodeGen::writeCtrlFlow( InlineItem *item, InlineItem *context ) default: break; } - if ( context != 0 ) + if ( isLmItem( context ) ) out << ""; } void XMLCodeGen::writePtrMod( InlineItem *item, InlineItem *context ) { - if ( context != 0 && ( context->type == InlineItem::LmOnNext || - context->type == InlineItem::LmOnLagBehind || - context->type == InlineItem::LmSwitch ) ) - { + if ( isLmItem( context ) ) { switch ( item->type ) { case InlineItem::Hold: out << ""; diff --git a/ragel/xmlcodegen.h b/ragel/xmlcodegen.h index 99b9853..6c80ac7 100644 --- a/ragel/xmlcodegen.h +++ b/ragel/xmlcodegen.h @@ -1,5 +1,5 @@ /* - * Copyright 2005, 2006 Adrian Thurston + * Copyright 2005-2007 Adrian Thurston */ /* This file is part of Ragel. diff --git a/test/patact.rl b/test/patact.rl index c15d93d..d523fa5 100644 --- a/test/patact.rl +++ b/test/patact.rl @@ -29,6 +29,10 @@ int val; '!';# => { prints "immdiate\n"; fgoto exec_test; }; *|; + semi := |* + ';' => { prints "in semi\n"; fgoto main; }; + *|; + main := |* [a-z]+ => { prints "word (w/lbh)\n"; fhold; fgoto other; }; [a-z]+ ' foil' => { prints "word (c/lbh)\n"; }; @@ -36,6 +40,7 @@ int val; '22' => { prints "num (w/switch)\n"; }; [0-9]+ => { prints "num (w/switch)\n"; fhold; fgoto other;}; [0-9]+ ' foil' => {prints "num (c/switch)\n"; }; + ';' => { prints "going to semi\n"; fhold; fgoto semi;}; '!' => { prints "immdiate\n"; fgoto exec_test; }; *|; }%% @@ -46,6 +51,7 @@ int val; "!abcd foix\n" "!abcd\nanother\n" "!123 foix\n" +";" _____INPUT_____ */ /* _____OUTPUT_____ word (w/lbh) @@ -87,5 +93,8 @@ space word space ACCEPT +going to semi +in semi +ACCEPT _____OUTPUT_____ */