/*
- * Copyright 2005, 2006 Adrian Thurston <thurston@cs.queensu.ca>
+ * Copyright 2005-2007 Adrian Thurston <thurston@cs.queensu.ca>
*/
/* This file is part of Ragel.
out << "</text>";
}
+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 << "<sub_action>";
-
- switch ( context->type ) {
- case InlineItem::LmOnLast:
- out << "<exec><get_tokend></get_tokend></exec>";
- break;
- case InlineItem::LmOnNext:
- out << "<exec><get_tokend></get_tokend></exec>";
- break;
- case InlineItem::LmOnLagBehind:
- out << "<exec><get_tokend></get_tokend></exec>";
- break;
- case InlineItem::LmSwitch:
- out << "<exec><get_tokend></get_tokend></exec>";
- break;
- default: break;
- }
+ out << "<exec><get_tokend></get_tokend></exec>";
}
switch ( item->type ) {
default: break;
}
- if ( context != 0 )
+ if ( isLmItem( context ) )
out << "</sub_action>";
}
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 << "<holdte></holdte>";
'!';# => { 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"; };
'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; };
*|;
}%%
"!abcd foix\n"
"!abcd\nanother\n"
"!123 foix\n"
+";"
_____INPUT_____ */
/* _____OUTPUT_____
word (w/lbh)
word
space
ACCEPT
+going to semi
+in semi
+ACCEPT
_____OUTPUT_____ */