Added an override for the eof variable.
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Mon, 24 Sep 2007 19:47:14 +0000 (19:47 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Mon, 24 Sep 2007 19:47:14 +0000 (19:47 +0000)
git-svn-id: http://svn.complang.org/ragel/trunk@287 052ea7fc-9027-0410-9066-f65837a77df0

12 files changed:
ragel/parsedata.cpp
ragel/parsedata.h
ragel/xmlcodegen.cpp
redfsm/gendata.cpp
redfsm/gendata.h
redfsm/xmlparse.kh
redfsm/xmlparse.kl
redfsm/xmltags.gperf
rlgen-cd/fsmcodegen.cpp
rlgen-java/javacodegen.cpp
rlgen-ruby/ruby-codegen.cpp
test/element1.rl

index 26fb13c..0dcb238 100644 (file)
@@ -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 )
index 6394abf..257076b 100644 (file)
@@ -268,6 +268,7 @@ struct ParseData
        /* Overriding variables. */
        InlineList *pExpr;
        InlineList *peExpr;
+       InlineList *eofExpr;
        InlineList *csExpr;
        InlineList *topExpr;
        InlineList *stackExpr;
index 096e382..3645c38 100644 (file)
@@ -649,6 +649,12 @@ void XMLCodeGen::writeXML()
                writeInlineList( pd->peExpr );
                out << "</pe_expr>\n";
        }
+
+       if ( pd->eofExpr != 0 ) {
+               out << "  <eof_expr>";
+               writeInlineList( pd->eofExpr );
+               out << "</eof_expr>\n";
+       }
        
        if ( pd->csExpr != 0 ) {
                out << "  <cs_expr>";
index 22dc5f9..0123564 100644 (file)
@@ -48,6 +48,7 @@ CodeGenData::CodeGenData( ostream &out )
        postPopExpr(0),
        pExpr(0),
        peExpr(0),
+       eofExpr(0),
        csExpr(0),
        topExpr(0),
        stackExpr(0),
index 52a5406..ebd8d95 100644 (file)
@@ -107,6 +107,7 @@ struct CodeGenData
        /* Overriding variables. */
        InlineList *pExpr;
        InlineList *peExpr;
+       InlineList *eofExpr;
        InlineList *csExpr;
        InlineList *topExpr;
        InlineList *stackExpr;
index ebb98e9..e220fc0 100644 (file)
@@ -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;
        }%%
index b9d167f..ca0bc4d 100644 (file)
@@ -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
index 754001f..cc175e7 100644 (file)
@@ -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
index a9bff77..317c08d 100644 (file)
@@ -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();
 }
 
index a8d5529..6f90b05 100644 (file)
@@ -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();
 }
 
index ad19a38..bccee3d 100644 (file)
@@ -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();
 }
 
index 221710f..6f25500 100644 (file)
@@ -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 )