Switched to the latest kelbt syntax. Like Ragel, this syntax is based on write
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Thu, 25 Jan 2007 02:40:53 +0000 (02:40 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Thu, 25 Jan 2007 02:40:53 +0000 (02:40 +0000)
statements embedded in the host code which explicitly specify which portions of
the machine to write out.

git-svn-id: http://svn.complang.org/ragel/trunk@12 052ea7fc-9027-0410-9066-f65837a77df0

ragel/rlparse.kh
ragel/rlparse.kl
rlcodegen/xmlparse.kh
rlcodegen/xmlparse.kl

index fe983fa..f1649d6 100644 (file)
@@ -26,7 +26,7 @@
 #include "avltree.h"
 #include "parsedata.h"
 
-extern char *lelNames[];
+extern char *Parser_lelNames[];
 
 struct LangEl;
 
@@ -93,10 +93,13 @@ struct Parser
        # semi is sent as a token in the code block rather than as a generic
        # symbol.
        token TK_Semi;
-
-       interface;
        }%%
 
+       %%{ write instance_data; }%%
+
+       void init();
+       int parseLangEl( int type, const Token *token );
+
        Parser( char *fileName, char *sectionName, InputLoc &sectionLoc )
                : sectionName(sectionName)
        {
@@ -119,4 +122,6 @@ struct Parser
        NameRefList nameRefList;
 };
 
+%%{ write token_defs; }%%
+
 #endif
index 1a4838e..ab43218 100644 (file)
@@ -1342,6 +1342,23 @@ state_ref_names:
 
 }%%
 
+%%{
+       write types;
+       write data;
+}%%
+
+
+void Parser::init()
+{
+       %%{ write init; }%%
+}
+
+int Parser::parseLangEl( int type, const Token *token )
+{
+       %%{ write exec; }%%
+       return errCount == 0 ? 0 : -1;
+}
+
 void Parser::tryMachineDef( InputLoc &loc, char *name, 
                JoinOrLm *joinOrLm, bool isInstance )
 {
@@ -1377,9 +1394,9 @@ ostream &Parser::parser_error( int tokId, Token &token )
        cerr << token.loc.fileName << ":" << token.loc.line << ":" << token.loc.col << ": ";
        cerr << "at token ";
        if ( tokId < 128 )
-               cerr << "\"" << lelNames[tokId] << "\"";
+               cerr << "\"" << Parser_lelNames[tokId] << "\"";
        else 
-               cerr << lelNames[tokId];
+               cerr << Parser_lelNames[tokId];
        if ( token.data != 0 )
                cerr << " with data \"" << token.data << "\"";
        cerr << ": ";
@@ -1393,7 +1410,7 @@ int Parser::token( InputLoc &loc, int tokId, char *tokstart, int toklen )
        token.data = tokstart;
        token.length = toklen;
        token.loc = loc;
-       int res = parseLangEl( tokId, token );
+       int res = parseLangEl( tokId, &token );
        if ( res < 0 ) {
                parser_error(tokId, token) << "parse error" << endl;
                exit(1);
index 287cadd..3dadb12 100644 (file)
@@ -70,10 +70,13 @@ struct Parser
                        TAG_set_tokend, TAG_get_tokend, TAG_init_tokstart,
                        TAG_set_tokstart, TAG_write, TAG_curstate, TAG_access, TAG_break,
                        TAG_option;
-
-               interface;
        }%%
 
+       %%{ write instance_data; }%%
+
+       void init();
+       int parseLangEl( int type, const Token *token );
+
        Parser( char *fileName )
                : fileName(fileName), sourceFileName(0) { }
 
@@ -104,4 +107,6 @@ struct Parser
        CodeGenMap codeGenMap;
 };
 
+%%{ write token_defs; }%%
+
 #endif /* _XMLPARSE_H */
index 7b996bb..c395061 100644 (file)
@@ -782,6 +782,23 @@ tag_cond_space: TAG_cond_space '/' TAG_cond_space
 
 }%%
 
+%%{
+       write types;
+       write data;
+}%%
+
+void Parser::init()
+{
+       %%{ write init; }%%
+}
+
+int Parser::parseLangEl( int type, const Token *token )
+{
+       %%{ write exec; }%%
+       return errCount == 0 ? 0 : -1;
+}
+
+
 unsigned long readLength( char *td )
 {
        return strtoul( td, 0, 10 );
@@ -848,7 +865,7 @@ ostream &Parser::parser_error( int tokId, Token &token )
 
 int Parser::token( int tokenId, Token &tok )
 {
-       int res = parseLangEl( tokenId, tok );
+       int res = parseLangEl( tokenId, &tok );
        if ( res < 0 ) {
                parser_error( tokenId, tok ) << "parse error" << endl;
                exit(1);