From: thurston Date: Mon, 24 Sep 2007 19:47:14 +0000 (+0000) Subject: Added an override for the eof variable. X-Git-Tag: 2.0_alpha~242 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b114f4b3ca65e721a361bac36b6c6111c30cbec0;p=external%2Fragel.git Added an override for the eof variable. git-svn-id: http://svn.complang.org/ragel/trunk@287 052ea7fc-9027-0410-9066-f65837a77df0 --- diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp index 26fb13c..0dcb238 100644 --- a/ragel/parsedata.cpp +++ b/ragel/parsedata.cpp @@ -433,6 +433,7 @@ ParseData::ParseData( char *fileName, char *sectionName, postPopExpr(0), pExpr(0), peExpr(0), + eofExpr(0), csExpr(0), topExpr(0), stackExpr(0), @@ -876,6 +877,8 @@ bool ParseData::setVariable( char *var, InlineList *inlineList ) pExpr = inlineList; else if ( strcmp( var, "pe" ) == 0 ) peExpr = inlineList; + else if ( strcmp( var, "eof" ) == 0 ) + eofExpr = inlineList; else if ( strcmp( var, "cs" ) == 0 ) csExpr = inlineList; else if ( strcmp( var, "data" ) == 0 ) diff --git a/ragel/parsedata.h b/ragel/parsedata.h index 6394abf..257076b 100644 --- a/ragel/parsedata.h +++ b/ragel/parsedata.h @@ -268,6 +268,7 @@ struct ParseData /* Overriding variables. */ InlineList *pExpr; InlineList *peExpr; + InlineList *eofExpr; InlineList *csExpr; InlineList *topExpr; InlineList *stackExpr; diff --git a/ragel/xmlcodegen.cpp b/ragel/xmlcodegen.cpp index 096e382..3645c38 100644 --- a/ragel/xmlcodegen.cpp +++ b/ragel/xmlcodegen.cpp @@ -649,6 +649,12 @@ void XMLCodeGen::writeXML() writeInlineList( pd->peExpr ); out << "\n"; } + + if ( pd->eofExpr != 0 ) { + out << " "; + writeInlineList( pd->eofExpr ); + out << "\n"; + } if ( pd->csExpr != 0 ) { out << " "; diff --git a/redfsm/gendata.cpp b/redfsm/gendata.cpp index 22dc5f9..0123564 100644 --- a/redfsm/gendata.cpp +++ b/redfsm/gendata.cpp @@ -48,6 +48,7 @@ CodeGenData::CodeGenData( ostream &out ) postPopExpr(0), pExpr(0), peExpr(0), + eofExpr(0), csExpr(0), topExpr(0), stackExpr(0), diff --git a/redfsm/gendata.h b/redfsm/gendata.h index 52a5406..ebd8d95 100644 --- a/redfsm/gendata.h +++ b/redfsm/gendata.h @@ -107,6 +107,7 @@ struct CodeGenData /* Overriding variables. */ InlineList *pExpr; InlineList *peExpr; + InlineList *eofExpr; InlineList *csExpr; InlineList *topExpr; InlineList *stackExpr; diff --git a/redfsm/xmlparse.kh b/redfsm/xmlparse.kh index ebb98e9..e220fc0 100644 --- a/redfsm/xmlparse.kh +++ b/redfsm/xmlparse.kh @@ -115,7 +115,7 @@ struct Parser token TAG_write, TAG_access, TAG_break, TAG_arg, TAG_cs_expr; - token TAG_p_expr, TAG_pe_expr, TAG_cs_expr, TAG_top_expr, + token TAG_p_expr, TAG_pe_expr, TAG_eof_expr, TAG_cs_expr, TAG_top_expr, TAG_stack_expr, TAG_act_expr, TAG_tokstart_expr, TAG_tokend_expr, TAG_data_expr, TAG_prepush, TAG_postpop; }%% diff --git a/redfsm/xmlparse.kl b/redfsm/xmlparse.kl index b9d167f..ca0bc4d 100644 --- a/redfsm/xmlparse.kl +++ b/redfsm/xmlparse.kl @@ -165,6 +165,7 @@ ragel_def_item: tag_export_list; ragel_def_item: tag_machine; ragel_def_item: tag_p_expr; ragel_def_item: tag_pe_expr; +ragel_def_item: tag_eof_expr; ragel_def_item: tag_cs_expr; ragel_def_item: tag_top_expr; ragel_def_item: tag_stack_expr; @@ -220,6 +221,8 @@ tag_p_expr: TAG_p_expr inline_list '/' TAG_p_expr final { cgd->pExpr = $2->inlineList; }; tag_pe_expr: TAG_pe_expr inline_list '/' TAG_pe_expr final { cgd->peExpr = $2->inlineList; }; +tag_eof_expr: TAG_eof_expr inline_list '/' TAG_eof_expr + final { cgd->eofExpr = $2->inlineList; }; tag_cs_expr: TAG_cs_expr inline_list '/' TAG_cs_expr final { cgd->csExpr = $2->inlineList; }; tag_top_expr: TAG_top_expr inline_list '/' TAG_top_expr diff --git a/redfsm/xmltags.gperf b/redfsm/xmltags.gperf index 754001f..cc175e7 100644 --- a/redfsm/xmltags.gperf +++ b/redfsm/xmltags.gperf @@ -81,6 +81,7 @@ exports, TAG_exports ex, TAG_ex p_expr, TAG_p_expr pe_expr, TAG_pe_expr +eof_expr, TAG_eof_expr cs_expr, TAG_cs_expr top_expr, TAG_top_expr stack_expr, TAG_stack_expr diff --git a/rlgen-cd/fsmcodegen.cpp b/rlgen-cd/fsmcodegen.cpp index a9bff77..317c08d 100644 --- a/rlgen-cd/fsmcodegen.cpp +++ b/rlgen-cd/fsmcodegen.cpp @@ -174,13 +174,13 @@ string FsmCodeGen::PE() string FsmCodeGen::EOFV() { ostringstream ret; -// if ( peExpr == 0 ) + if ( eofExpr == 0 ) ret << "eof"; -// else { -// ret << "("; -// INLINE_LIST( ret, peExpr, 0, false ); -// ret << ")"; -// } + else { + ret << "("; + INLINE_LIST( ret, eofExpr, 0, false ); + ret << ")"; + } return ret.str(); } diff --git a/rlgen-java/javacodegen.cpp b/rlgen-java/javacodegen.cpp index a8d5529..6f90b05 100644 --- a/rlgen-java/javacodegen.cpp +++ b/rlgen-java/javacodegen.cpp @@ -1259,13 +1259,13 @@ string JavaTabCodeGen::PE() string JavaTabCodeGen::EOFV() { ostringstream ret; -// if ( peExpr == 0 ) + if ( eofExpr == 0 ) ret << "eof"; -// else { -// ret << "("; -// INLINE_LIST( ret, peExpr, 0, false ); -// ret << ")"; -// } + else { + ret << "("; + INLINE_LIST( ret, eofExpr, 0, false ); + ret << ")"; + } return ret.str(); } diff --git a/rlgen-ruby/ruby-codegen.cpp b/rlgen-ruby/ruby-codegen.cpp index ad19a38..bccee3d 100644 --- a/rlgen-ruby/ruby-codegen.cpp +++ b/rlgen-ruby/ruby-codegen.cpp @@ -130,13 +130,13 @@ string RubyCodeGen::PE() string RubyCodeGen::EOFV() { ostringstream ret; -// if ( peExpr == 0 ) + if ( eofExpr == 0 ) ret << "eof"; -// else { -// //ret << "("; -// INLINE_LIST( ret, peExpr, 0, false ); -// //ret << ")"; -// } + else { + //ret << "("; + INLINE_LIST( ret, eofExpr, 0, false ); + //ret << ")"; + } return ret.str(); } diff --git a/test/element1.rl b/test/element1.rl index 221710f..6f25500 100644 --- a/test/element1.rl +++ b/test/element1.rl @@ -39,6 +39,7 @@ struct Fsm alphtype int; getkey fpc->key; + variable eof eof_marker; action a1 {} action a2 {} @@ -61,7 +62,7 @@ int Fsm::execute( LangEl *data, int len ) { LangEl *p = data; LangEl *pe = data + len; - LangEl *eof = pe; + LangEl *eof_marker = pe; %% write exec; if ( cs == Fsm_error )