From: thurston Date: Thu, 25 Jan 2007 02:40:53 +0000 (+0000) Subject: Switched to the latest kelbt syntax. Like Ragel, this syntax is based on write X-Git-Tag: 2.0_alpha~473 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6299a652d19d3f0b5e90fe7fe3cd3425e7ed9243;p=external%2Fragel.git Switched to the latest kelbt syntax. Like Ragel, this syntax is based on write 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 --- diff --git a/ragel/rlparse.kh b/ragel/rlparse.kh index fe983fa..f1649d6 100644 --- a/ragel/rlparse.kh +++ b/ragel/rlparse.kh @@ -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 §ionLoc ) : sectionName(sectionName) { @@ -119,4 +122,6 @@ struct Parser NameRefList nameRefList; }; +%%{ write token_defs; }%% + #endif diff --git a/ragel/rlparse.kl b/ragel/rlparse.kl index 1a4838e..ab43218 100644 --- a/ragel/rlparse.kl +++ b/ragel/rlparse.kl @@ -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); diff --git a/rlcodegen/xmlparse.kh b/rlcodegen/xmlparse.kh index 287cadd..3dadb12 100644 --- a/rlcodegen/xmlparse.kh +++ b/rlcodegen/xmlparse.kh @@ -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 */ diff --git a/rlcodegen/xmlparse.kl b/rlcodegen/xmlparse.kl index 7b996bb..c395061 100644 --- a/rlcodegen/xmlparse.kl +++ b/rlcodegen/xmlparse.kl @@ -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);