130fdf1140b8d1ce93f3821d986fa165552023440lgao/* 230fdf1140b8d1ce93f3821d986fa165552023440lgao * antlr.g -- PCCTS Version 1.xx ANTLR 330fdf1140b8d1ce93f3821d986fa165552023440lgao * 430fdf1140b8d1ce93f3821d986fa165552023440lgao * Parse an antlr input grammar and build a syntax-diagram. 530fdf1140b8d1ce93f3821d986fa165552023440lgao * 630fdf1140b8d1ce93f3821d986fa165552023440lgao * Written in itself (needs at least 1.06 to work) 730fdf1140b8d1ce93f3821d986fa165552023440lgao * 830fdf1140b8d1ce93f3821d986fa165552023440lgao * SOFTWARE RIGHTS 930fdf1140b8d1ce93f3821d986fa165552023440lgao * 1030fdf1140b8d1ce93f3821d986fa165552023440lgao * We reserve no LEGAL rights to the Purdue Compiler Construction Tool 1130fdf1140b8d1ce93f3821d986fa165552023440lgao * Set (PCCTS) -- PCCTS is in the public domain. An individual or 1230fdf1140b8d1ce93f3821d986fa165552023440lgao * company may do whatever they wish with source code distributed with 1330fdf1140b8d1ce93f3821d986fa165552023440lgao * PCCTS or the code generated by PCCTS, including the incorporation of 1430fdf1140b8d1ce93f3821d986fa165552023440lgao * PCCTS, or its output, into commerical software. 1530fdf1140b8d1ce93f3821d986fa165552023440lgao * 1630fdf1140b8d1ce93f3821d986fa165552023440lgao * We encourage users to develop software with PCCTS. However, we do ask 1730fdf1140b8d1ce93f3821d986fa165552023440lgao * that credit is given to us for developing PCCTS. By "credit", 1830fdf1140b8d1ce93f3821d986fa165552023440lgao * we mean that if you incorporate our source code into one of your 1930fdf1140b8d1ce93f3821d986fa165552023440lgao * programs (commercial product, research project, or otherwise) that you 2030fdf1140b8d1ce93f3821d986fa165552023440lgao * acknowledge this fact somewhere in the documentation, research report, 2130fdf1140b8d1ce93f3821d986fa165552023440lgao * etc... If you like PCCTS and have developed a nice tool with the 2230fdf1140b8d1ce93f3821d986fa165552023440lgao * output, please mention that you developed it using PCCTS. In 2330fdf1140b8d1ce93f3821d986fa165552023440lgao * addition, we ask that this header remain intact in our source code. 2430fdf1140b8d1ce93f3821d986fa165552023440lgao * As long as these guidelines are kept, we expect to continue enhancing 2530fdf1140b8d1ce93f3821d986fa165552023440lgao * this system and expect to make other tools available as they are 2630fdf1140b8d1ce93f3821d986fa165552023440lgao * completed. 2730fdf1140b8d1ce93f3821d986fa165552023440lgao * 2830fdf1140b8d1ce93f3821d986fa165552023440lgao * ANTLR 1.33 2930fdf1140b8d1ce93f3821d986fa165552023440lgao * Terence Parr 3030fdf1140b8d1ce93f3821d986fa165552023440lgao * Parr Research Corporation 3130fdf1140b8d1ce93f3821d986fa165552023440lgao * with Purdue University and AHPCRC, University of Minnesota 3230fdf1140b8d1ce93f3821d986fa165552023440lgao * 1989-1995 3330fdf1140b8d1ce93f3821d986fa165552023440lgao */ 3430fdf1140b8d1ce93f3821d986fa165552023440lgao 3530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ 3630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 10-Apr-97 MR1 Replace #if logic with #include "pcctscfg.h" */ 3730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ 3830fdf1140b8d1ce93f3821d986fa165552023440lgao 3930fdf1140b8d1ce93f3821d986fa165552023440lgao#header << 4030fdf1140b8d1ce93f3821d986fa165552023440lgao #include "pcctscfg.h" 4130fdf1140b8d1ce93f3821d986fa165552023440lgao #include "set.h" 4230fdf1140b8d1ce93f3821d986fa165552023440lgao #include <ctype.h> 4330fdf1140b8d1ce93f3821d986fa165552023440lgao #include "syn.h" 4430fdf1140b8d1ce93f3821d986fa165552023440lgao #include "hash.h" 4530fdf1140b8d1ce93f3821d986fa165552023440lgao #include "generic.h" 4630fdf1140b8d1ce93f3821d986fa165552023440lgao #define zzcr_attr(attr,tok,t) 4730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 4830fdf1140b8d1ce93f3821d986fa165552023440lgao 4930fdf1140b8d1ce93f3821d986fa165552023440lgao<< 5030fdf1140b8d1ce93f3821d986fa165552023440lgao 5130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */ 5230fdf1140b8d1ce93f3821d986fa165552023440lgao#if defined(__TURBOC__) 5330fdf1140b8d1ce93f3821d986fa165552023440lgao#pragma warn -aus /* unused assignment of 'xxx' */ 5430fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 5530fdf1140b8d1ce93f3821d986fa165552023440lgao 5630fdf1140b8d1ce93f3821d986fa165552023440lgao 5730fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 5830fdf1140b8d1ce93f3821d986fa165552023440lgaostatic void chkToken(char *, char *, char *, int); 5930fdf1140b8d1ce93f3821d986fa165552023440lgao#else 6030fdf1140b8d1ce93f3821d986fa165552023440lgaostatic void chkToken(); 6130fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 6230fdf1140b8d1ce93f3821d986fa165552023440lgao 6330fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 6430fdf1140b8d1ce93f3821d986fa165552023440lgaostatic int isDLGmaxToken(char *Token); /* MR3 */ 6530fdf1140b8d1ce93f3821d986fa165552023440lgao#else 6630fdf1140b8d1ce93f3821d986fa165552023440lgaostatic int isDLGmaxToken(); /* MR3 */ 6730fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 6830fdf1140b8d1ce93f3821d986fa165552023440lgao 6930fdf1140b8d1ce93f3821d986fa165552023440lgaostatic int class_nest_level = 0; 7030fdf1140b8d1ce93f3821d986fa165552023440lgao 7130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR20 G. Hobbelt extern definitions moved to antlr.h */ 7230fdf1140b8d1ce93f3821d986fa165552023440lgao 7330fdf1140b8d1ce93f3821d986fa165552023440lgao>> 7430fdf1140b8d1ce93f3821d986fa165552023440lgao 7530fdf1140b8d1ce93f3821d986fa165552023440lgao#lexaction << 7630fdf1140b8d1ce93f3821d986fa165552023440lgao/* maintained, but not used for now */ 7730fdf1140b8d1ce93f3821d986fa165552023440lgaoset AST_nodes_refd_in_actions = set_init; 7830fdf1140b8d1ce93f3821d986fa165552023440lgaoint inAlt = 0; 7930fdf1140b8d1ce93f3821d986fa165552023440lgaoset attribsRefdFromAction = set_init; /* MR20 */ 8030fdf1140b8d1ce93f3821d986fa165552023440lgaoint UsedOldStyleAttrib = 0; 8130fdf1140b8d1ce93f3821d986fa165552023440lgaoint UsedNewStyleLabel = 0; 8230fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 8330fdf1140b8d1ce93f3821d986fa165552023440lgaochar *inline_set(char *); 8430fdf1140b8d1ce93f3821d986fa165552023440lgao#else 8530fdf1140b8d1ce93f3821d986fa165552023440lgaochar *inline_set(); 8630fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 8730fdf1140b8d1ce93f3821d986fa165552023440lgao 8830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */ 8930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 in DLG action */ 9030fdf1140b8d1ce93f3821d986fa165552023440lgao 9130fdf1140b8d1ce93f3821d986fa165552023440lgaoint tokenActionActive=0; /* MR1 */ 9230fdf1140b8d1ce93f3821d986fa165552023440lgao 9330fdf1140b8d1ce93f3821d986fa165552023440lgao>> 9430fdf1140b8d1ce93f3821d986fa165552023440lgao 9530fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass STRINGS 9630fdf1140b8d1ce93f3821d986fa165552023440lgao#token QuotedTerm "\"" << zzmode(START); >> 9730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << 9830fdf1140b8d1ce93f3821d986fa165552023440lgao zzline++; 9930fdf1140b8d1ce93f3821d986fa165552023440lgao warn("eoln found in string"); 10030fdf1140b8d1ce93f3821d986fa165552023440lgao zzskip(); 10130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 10230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\(\n|\r|\r\n)" << zzline++; zzmore(); >> 10330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\~[]" << zzmore(); >> 10430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r\"\\]+" << zzmore(); >> 10530fdf1140b8d1ce93f3821d986fa165552023440lgao 10630fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass ACTION_STRINGS 10730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\"" << zzmode(ACTIONS); zzmore(); >> 10830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << 10930fdf1140b8d1ce93f3821d986fa165552023440lgao zzline++; 11030fdf1140b8d1ce93f3821d986fa165552023440lgao warn("eoln found in string (in user action)"); 11130fdf1140b8d1ce93f3821d986fa165552023440lgao zzskip(); 11230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 11330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\(\n|\r|\r\n)" << zzline++; zzmore(); >> 11430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\~[]" << zzmore(); >> 11530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r\"\\]+" << zzmore(); >> 11630fdf1140b8d1ce93f3821d986fa165552023440lgao 11730fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass ACTION_CHARS 11830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "'" << zzmode(ACTIONS); zzmore(); >> 11930fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << 12030fdf1140b8d1ce93f3821d986fa165552023440lgao zzline++; 12130fdf1140b8d1ce93f3821d986fa165552023440lgao warn("eoln found in char literal (in user action)"); 12230fdf1140b8d1ce93f3821d986fa165552023440lgao zzskip(); 12330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 12430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\~[]" << zzmore(); >> 12530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r'\\]+" << zzmore(); >> 12630fdf1140b8d1ce93f3821d986fa165552023440lgao 12730fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass ACTION_COMMENTS 12830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*/" << zzmode(ACTIONS); zzmore(); >> 12930fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*" << zzmore(); >> 13030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzmore(); DAWDLE; >> 13130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r\*]+" << zzmore(); >> 13230fdf1140b8d1ce93f3821d986fa165552023440lgao 13330fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass TOK_DEF_COMMENTS 13430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*/" << zzmode(PARSE_ENUM_FILE); 13530fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); >> 13630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*" << zzmore(); >> 13730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzmore(); DAWDLE; >> 13830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r\*]+" << zzmore(); >> 13930fdf1140b8d1ce93f3821d986fa165552023440lgao 14030fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass TOK_DEF_CPP_COMMENTS 14130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE; >> 14230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r]+" << zzskip(); >> 14330fdf1140b8d1ce93f3821d986fa165552023440lgao 14430fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass ACTION_CPP_COMMENTS 14530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzmode(ACTIONS); zzmore(); DAWDLE; >> 14630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r]+" << zzmore(); >> 14730fdf1140b8d1ce93f3821d986fa165552023440lgao 14830fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass CPP_COMMENTS 14930fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzmode(START); zzskip(); DAWDLE; >> 15030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r]+" << zzskip(); >> 15130fdf1140b8d1ce93f3821d986fa165552023440lgao 15230fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass COMMENTS 15330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*/" << zzmode(START); zzskip(); >> 15430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*" << zzskip(); >> 15530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzskip(); DAWDLE; >> 15630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r\*]+" << zzskip(); >> 15730fdf1140b8d1ce93f3821d986fa165552023440lgao 15830fdf1140b8d1ce93f3821d986fa165552023440lgao/* 15930fdf1140b8d1ce93f3821d986fa165552023440lgao * This lexical class accepts actions of type [..] and <<..>> 16030fdf1140b8d1ce93f3821d986fa165552023440lgao * 16130fdf1140b8d1ce93f3821d986fa165552023440lgao * It translates the following special items for C: 16230fdf1140b8d1ce93f3821d986fa165552023440lgao * 16330fdf1140b8d1ce93f3821d986fa165552023440lgao * $j --> "zzaArg(current zztasp, j)" 16430fdf1140b8d1ce93f3821d986fa165552023440lgao * $i.j --> "zzaArg(zztaspi, j)" 16530fdf1140b8d1ce93f3821d986fa165552023440lgao * $i.nondigit> "zzaArg(current zztasp, i).nondigit" 16630fdf1140b8d1ce93f3821d986fa165552023440lgao * $$ --> "zzaRet" 16730fdf1140b8d1ce93f3821d986fa165552023440lgao * $alnum --> "alnum" (used to ref parameters) 16830fdf1140b8d1ce93f3821d986fa165552023440lgao * $rule --> "zzaRet" 16930fdf1140b8d1ce93f3821d986fa165552023440lgao * $retval --> "_retv.retval" if > 1 return values else "_retv" 17030fdf1140b8d1ce93f3821d986fa165552023440lgao * $[token, text] --> "zzconstr_attr(token, text)" 17130fdf1140b8d1ce93f3821d986fa165552023440lgao * $[] --> "zzempty_attr()" 17230fdf1140b8d1ce93f3821d986fa165552023440lgao * 17330fdf1140b8d1ce93f3821d986fa165552023440lgao * It translates the following special items for C++: 17430fdf1140b8d1ce93f3821d986fa165552023440lgao * (attributes are now stored with 'Token' and $i's are only 17530fdf1140b8d1ce93f3821d986fa165552023440lgao * pointers to the Tokens. Rules don't have attributes now.) 17630fdf1140b8d1ce93f3821d986fa165552023440lgao * 17730fdf1140b8d1ce93f3821d986fa165552023440lgao * $j --> "_tbj" where b is the block level 17830fdf1140b8d1ce93f3821d986fa165552023440lgao * $i.j --> "_tij" 17930fdf1140b8d1ce93f3821d986fa165552023440lgao * $j->nondigit> "_tbj->nondigit" 18030fdf1140b8d1ce93f3821d986fa165552023440lgao * $$ --> "$$" 18130fdf1140b8d1ce93f3821d986fa165552023440lgao * $alnum --> "alnum" (used to ref parameters) 18230fdf1140b8d1ce93f3821d986fa165552023440lgao * $rule --> "$rule" 18330fdf1140b8d1ce93f3821d986fa165552023440lgao * $retval --> "_retv.retval" if > 1 return values else "_retv" 18430fdf1140b8d1ce93f3821d986fa165552023440lgao * $[token, text] --> invalid 18530fdf1140b8d1ce93f3821d986fa165552023440lgao * $[] --> invalid 18630fdf1140b8d1ce93f3821d986fa165552023440lgao * 18730fdf1140b8d1ce93f3821d986fa165552023440lgao * And, for trees: 18830fdf1140b8d1ce93f3821d986fa165552023440lgao * 18930fdf1140b8d1ce93f3821d986fa165552023440lgao * #0 --> "(*_root)" 19030fdf1140b8d1ce93f3821d986fa165552023440lgao * #i --> "zzastArg(i)" 19130fdf1140b8d1ce93f3821d986fa165552023440lgao * #[args] --> "zzmk_ast(zzastnew(), args)" 19230fdf1140b8d1ce93f3821d986fa165552023440lgao * #[] --> "zzastnew()" 19330fdf1140b8d1ce93f3821d986fa165552023440lgao * #( root, child1, ..., childn ) 19430fdf1140b8d1ce93f3821d986fa165552023440lgao * --> "zztmake(root, child1, ...., childn, NULL)" 19530fdf1140b8d1ce93f3821d986fa165552023440lgao * #() --> "NULL" 19630fdf1140b8d1ce93f3821d986fa165552023440lgao * 19730fdf1140b8d1ce93f3821d986fa165552023440lgao * For C++, ... 19830fdf1140b8d1ce93f3821d986fa165552023440lgao * 19930fdf1140b8d1ce93f3821d986fa165552023440lgao * #0 --> "(*_root)" 20030fdf1140b8d1ce93f3821d986fa165552023440lgao * #i --> "_astbi" where b is the block level 20130fdf1140b8d1ce93f3821d986fa165552023440lgao * #alnum --> "alnum_ast" (used to ref #label) 20230fdf1140b8d1ce93f3821d986fa165552023440lgao * #[args] --> "new AST(args)" 20330fdf1140b8d1ce93f3821d986fa165552023440lgao * #[] --> "new AST" 20430fdf1140b8d1ce93f3821d986fa165552023440lgao * #( root, child1, ..., childn ) 20530fdf1140b8d1ce93f3821d986fa165552023440lgao * --> "AST::tmake(root, child1, ...., childn, NULL)" 20630fdf1140b8d1ce93f3821d986fa165552023440lgao * #() --> "NULL" 20730fdf1140b8d1ce93f3821d986fa165552023440lgao * 20830fdf1140b8d1ce93f3821d986fa165552023440lgao * To escape, 20930fdf1140b8d1ce93f3821d986fa165552023440lgao * 21030fdf1140b8d1ce93f3821d986fa165552023440lgao * \] --> ] 21130fdf1140b8d1ce93f3821d986fa165552023440lgao * \) --> ) 21230fdf1140b8d1ce93f3821d986fa165552023440lgao * \$ --> $ 21330fdf1140b8d1ce93f3821d986fa165552023440lgao * \# --> # 21430fdf1140b8d1ce93f3821d986fa165552023440lgao * 21530fdf1140b8d1ce93f3821d986fa165552023440lgao * A stack is used to nest action terminators because they can be nested 21630fdf1140b8d1ce93f3821d986fa165552023440lgao * like crazy: << #[$[..],..] >> 21730fdf1140b8d1ce93f3821d986fa165552023440lgao */ 21830fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass ACTIONS 21930fdf1140b8d1ce93f3821d986fa165552023440lgao#token Action "\>\>" << /* these do not nest */ 22030fdf1140b8d1ce93f3821d986fa165552023440lgao zzmode(START); 22130fdf1140b8d1ce93f3821d986fa165552023440lgao NLATEXT[0] = ' '; 22230fdf1140b8d1ce93f3821d986fa165552023440lgao NLATEXT[1] = ' '; 22330fdf1140b8d1ce93f3821d986fa165552023440lgao zzbegexpr[0] = ' '; 22430fdf1140b8d1ce93f3821d986fa165552023440lgao zzbegexpr[1] = ' '; 22530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( zzbufovf ) { 22630fdf1140b8d1ce93f3821d986fa165552023440lgao err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE)); 22730fdf1140b8d1ce93f3821d986fa165552023440lgao } 22830fdf1140b8d1ce93f3821d986fa165552023440lgao 22930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */ 23030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 in DLG action */ 23130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 Doesn't matter what kind of action it is - reset*/ 23230fdf1140b8d1ce93f3821d986fa165552023440lgao 23330fdf1140b8d1ce93f3821d986fa165552023440lgao tokenActionActive=0; /* MR1 */ 23430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 23530fdf1140b8d1ce93f3821d986fa165552023440lgao#token Pred "\>\>?" << /* these do not nest */ 23630fdf1140b8d1ce93f3821d986fa165552023440lgao zzmode(START); 23730fdf1140b8d1ce93f3821d986fa165552023440lgao NLATEXT[0] = ' '; 23830fdf1140b8d1ce93f3821d986fa165552023440lgao NLATEXT[1] = ' '; 23930fdf1140b8d1ce93f3821d986fa165552023440lgao zzbegexpr[0] = '\0'; 24030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( zzbufovf ) { 24130fdf1140b8d1ce93f3821d986fa165552023440lgao err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE)); 24230fdf1140b8d1ce93f3821d986fa165552023440lgao }; 24330fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __cplusplus__ 24430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred); 24530fdf1140b8d1ce93f3821d986fa165552023440lgao#else 24630fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __STDC__ 24730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred); 24830fdf1140b8d1ce93f3821d986fa165552023440lgao#else 24930fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 25030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MRxx */ list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred); 25130fdf1140b8d1ce93f3821d986fa165552023440lgao#else 25230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ list_apply(CurActionLabels,mark_label_used_in_sem_pred); 25330fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 25430fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 25530fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 25630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 25730fdf1140b8d1ce93f3821d986fa165552023440lgao#token PassAction "\]" << if ( topint() == ']' ) { 25830fdf1140b8d1ce93f3821d986fa165552023440lgao popint(); 25930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( istackempty() ) /* terminate action */ 26030fdf1140b8d1ce93f3821d986fa165552023440lgao { 26130fdf1140b8d1ce93f3821d986fa165552023440lgao zzmode(START); 26230fdf1140b8d1ce93f3821d986fa165552023440lgao NLATEXT[0] = ' '; 26330fdf1140b8d1ce93f3821d986fa165552023440lgao zzbegexpr[0] = ' '; 26430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( zzbufovf ) { 26530fdf1140b8d1ce93f3821d986fa165552023440lgao err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE)); 26630fdf1140b8d1ce93f3821d986fa165552023440lgao } 26730fdf1140b8d1ce93f3821d986fa165552023440lgao } 26830fdf1140b8d1ce93f3821d986fa165552023440lgao else { 26930fdf1140b8d1ce93f3821d986fa165552023440lgao /* terminate $[..] and #[..] */ 27030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenCC ) zzreplstr("))"); 27130fdf1140b8d1ce93f3821d986fa165552023440lgao else zzreplstr(")"); 27230fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 27330fdf1140b8d1ce93f3821d986fa165552023440lgao } 27430fdf1140b8d1ce93f3821d986fa165552023440lgao } 27530fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( topint() == '|' ) { /* end of simple [...] */ 27630fdf1140b8d1ce93f3821d986fa165552023440lgao popint(); 27730fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 27830fdf1140b8d1ce93f3821d986fa165552023440lgao } 27930fdf1140b8d1ce93f3821d986fa165552023440lgao else zzmore(); 28030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 28130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "consumeUntil\( [\ \t]* \{~[\}]+\} [\ \t]* \)" 28230fdf1140b8d1ce93f3821d986fa165552023440lgao << 28330fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 28430fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(inline_set(zzbegexpr+ 28530fdf1140b8d1ce93f3821d986fa165552023440lgao strlen("consumeUntil("))); 28630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 28730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "consumeUntil\( ~[\)]+ \)" 28830fdf1140b8d1ce93f3821d986fa165552023440lgao << zzmore(); >> 28930fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzmore(); DAWDLE; >> 29030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\>" << zzmore(); >> 29130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$" << zzmore(); >> 29230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$$" << if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();} 29330fdf1140b8d1ce93f3821d986fa165552023440lgao else err("$$ use invalid in C++ mode"); >> 29430fdf1140b8d1ce93f3821d986fa165552023440lgao 29530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$\[\]" << if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();} 29630fdf1140b8d1ce93f3821d986fa165552023440lgao else err("$[] use invalid in C++ mode"); >> 29730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$\[" << 29830fdf1140b8d1ce93f3821d986fa165552023440lgao pushint(']'); 29930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !GenCC ) zzreplstr("zzconstr_attr("); 30030fdf1140b8d1ce93f3821d986fa165552023440lgao else err("$[..] use invalid in C++ mode"); 30130fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 30230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 30330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$[0-9]+" <<{ 30430fdf1140b8d1ce93f3821d986fa165552023440lgao static char buf[100]; 30530fdf1140b8d1ce93f3821d986fa165552023440lgao numericActionLabel=1; /* MR10 */ 30630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( strlen(zzbegexpr)>(size_t)85 ) 30730fdf1140b8d1ce93f3821d986fa165552023440lgao fatal("$i attrib ref too big"); 30830fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction); 30930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)", 31030fdf1140b8d1ce93f3821d986fa165552023440lgao BlkLevel-1,zzbegexpr+1); 31130fdf1140b8d1ce93f3821d986fa165552023440lgao else sprintf(buf,"_t%d%s", 31230fdf1140b8d1ce93f3821d986fa165552023440lgao BlkLevel-1,zzbegexpr+1); 31330fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(buf); 31430fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 31530fdf1140b8d1ce93f3821d986fa165552023440lgao UsedOldStyleAttrib = 1; 31630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( UsedNewStyleLabel ) 31730fdf1140b8d1ce93f3821d986fa165552023440lgao err("cannot mix old-style $i with new-style labels"); 31830fdf1140b8d1ce93f3821d986fa165552023440lgao } 31930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 32030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$[0-9]+." <<{ 32130fdf1140b8d1ce93f3821d986fa165552023440lgao static char buf[100]; 32230fdf1140b8d1ce93f3821d986fa165552023440lgao numericActionLabel=1; /* MR10 */ 32330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( strlen(zzbegexpr)>(size_t)85 ) 32430fdf1140b8d1ce93f3821d986fa165552023440lgao fatal("$i.field attrib ref too big"); 32530fdf1140b8d1ce93f3821d986fa165552023440lgao zzbegexpr[strlen(zzbegexpr)-1] = ' '; 32630fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction); 32730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).", 32830fdf1140b8d1ce93f3821d986fa165552023440lgao BlkLevel-1,zzbegexpr+1); 32930fdf1140b8d1ce93f3821d986fa165552023440lgao else sprintf(buf,"_t%d%s.", 33030fdf1140b8d1ce93f3821d986fa165552023440lgao BlkLevel-1,zzbegexpr+1); 33130fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(buf); 33230fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 33330fdf1140b8d1ce93f3821d986fa165552023440lgao UsedOldStyleAttrib = 1; 33430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( UsedNewStyleLabel ) 33530fdf1140b8d1ce93f3821d986fa165552023440lgao err("cannot mix old-style $i with new-style labels"); 33630fdf1140b8d1ce93f3821d986fa165552023440lgao } 33730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 33830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$[0-9]+.[0-9]+" <<{ 33930fdf1140b8d1ce93f3821d986fa165552023440lgao static char buf[100]; 34030fdf1140b8d1ce93f3821d986fa165552023440lgao static char i[20], j[20]; 34130fdf1140b8d1ce93f3821d986fa165552023440lgao char *p,*q; 34230fdf1140b8d1ce93f3821d986fa165552023440lgao numericActionLabel=1; /* MR10 */ 34330fdf1140b8d1ce93f3821d986fa165552023440lgao if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big"); 34430fdf1140b8d1ce93f3821d986fa165552023440lgao for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) { 34530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( q == &i[20] ) 34630fdf1140b8d1ce93f3821d986fa165552023440lgao fatalFL("i of $i.j attrib ref too big", 34730fdf1140b8d1ce93f3821d986fa165552023440lgao FileStr[CurFile], zzline ); 34830fdf1140b8d1ce93f3821d986fa165552023440lgao *q++ = *p; 34930fdf1140b8d1ce93f3821d986fa165552023440lgao } 35030fdf1140b8d1ce93f3821d986fa165552023440lgao *q = '\0'; 35130fdf1140b8d1ce93f3821d986fa165552023440lgao for (p++, q= &j[0]; *p!='\0'; p++) { 35230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( q == &j[20] ) 35330fdf1140b8d1ce93f3821d986fa165552023440lgao fatalFL("j of $i.j attrib ref too big", 35430fdf1140b8d1ce93f3821d986fa165552023440lgao FileStr[CurFile], zzline ); 35530fdf1140b8d1ce93f3821d986fa165552023440lgao *q++ = *p; 35630fdf1140b8d1ce93f3821d986fa165552023440lgao } 35730fdf1140b8d1ce93f3821d986fa165552023440lgao *q = '\0'; 35830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j); 35930fdf1140b8d1ce93f3821d986fa165552023440lgao else sprintf(buf,"_t%s%s",i,j); 36030fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(buf); 36130fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 36230fdf1140b8d1ce93f3821d986fa165552023440lgao UsedOldStyleAttrib = 1; 36330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( UsedNewStyleLabel ) 36430fdf1140b8d1ce93f3821d986fa165552023440lgao err("cannot mix old-style $i with new-style labels"); 36530fdf1140b8d1ce93f3821d986fa165552023440lgao } 36630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 36730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "$[_a-zA-Z][_a-zA-Z0-9]*" 36830fdf1140b8d1ce93f3821d986fa165552023440lgao <<{ static char buf[300]; LabelEntry *el; 36930fdf1140b8d1ce93f3821d986fa165552023440lgao zzbegexpr[0] = ' '; 37030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( CurRule != NULL && 37130fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(CurRule, &zzbegexpr[1])==0 ) { 37230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !GenCC ) zzreplstr("zzaRet"); 37330fdf1140b8d1ce93f3821d986fa165552023440lgao } 37430fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( CurRetDef != NULL && 37530fdf1140b8d1ce93f3821d986fa165552023440lgao strmember(CurRetDef, &zzbegexpr[1])) { 37630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( hasMultipleOperands( CurRetDef ) ) { 37730fdf1140b8d1ce93f3821d986fa165552023440lgao require (strlen(zzbegexpr)<=(size_t)285, 37830fdf1140b8d1ce93f3821d986fa165552023440lgao "$retval attrib ref too big"); 37930fdf1140b8d1ce93f3821d986fa165552023440lgao sprintf(buf,"_retv.%s",&zzbegexpr[1]); 38030fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(buf); 38130fdf1140b8d1ce93f3821d986fa165552023440lgao } 38230fdf1140b8d1ce93f3821d986fa165552023440lgao else zzreplstr("_retv"); 38330fdf1140b8d1ce93f3821d986fa165552023440lgao } 38430fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( CurParmDef != NULL && 38530fdf1140b8d1ce93f3821d986fa165552023440lgao strmember(CurParmDef, &zzbegexpr[1])) { 38630fdf1140b8d1ce93f3821d986fa165552023440lgao ; 38730fdf1140b8d1ce93f3821d986fa165552023440lgao } 38830fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( Elabel==NULL ) { 38930fdf1140b8d1ce93f3821d986fa165552023440lgao { err("$-variables in actions outside of rules are not allowed"); } 39030fdf1140b8d1ce93f3821d986fa165552023440lgao } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) { 39130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ 39230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ /* element labels might exist without an elem when */ 39330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ /* it is a forward reference (to a rule) */ 39430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ 39530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) ) 39630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); } 39730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ 39830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) { 39930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ err("You can no longer use attributes returned by rules when also using ASTs"); 40030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ err(" Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...\>\>\")"); 40130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ }; 40230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ 40330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ /* keep track of <<... $label ...>> for semantic predicates in guess mode */ 40430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ /* element labels contain pointer to the owners node */ 40530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ 40630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ if (el->elem != NULL && el->elem->ntype == nToken) { 40730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ list_add(&CurActionLabels,el); 40830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ }; 40930fdf1140b8d1ce93f3821d986fa165552023440lgao } 41030fdf1140b8d1ce93f3821d986fa165552023440lgao else 41130fdf1140b8d1ce93f3821d986fa165552023440lgao warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1])); 41230fdf1140b8d1ce93f3821d986fa165552023440lgao } 41330fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 41430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 41530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#0" << zzreplstr("(*_root)"); zzmore(); chkGTFlag(); >> 41630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#\[\]" << if ( GenCC ) { 41730fdf1140b8d1ce93f3821d986fa165552023440lgao if (NewAST) zzreplstr("(newAST)"); 41830fdf1140b8d1ce93f3821d986fa165552023440lgao else zzreplstr("(new AST)");} 41930fdf1140b8d1ce93f3821d986fa165552023440lgao else {zzreplstr("zzastnew()");} zzmore(); 42030fdf1140b8d1ce93f3821d986fa165552023440lgao chkGTFlag(); 42130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 42230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#\(\)" << zzreplstr("NULL"); zzmore(); chkGTFlag(); >> 42330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#[0-9]+" <<{ 42430fdf1140b8d1ce93f3821d986fa165552023440lgao static char buf[100]; 42530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( strlen(zzbegexpr)>(size_t)85 ) 42630fdf1140b8d1ce93f3821d986fa165552023440lgao fatal("#i AST ref too big"); 42730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1); 42830fdf1140b8d1ce93f3821d986fa165552023440lgao else sprintf(buf,"zzastArg(%s)",zzbegexpr+1); 42930fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(buf); 43030fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 43130fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions); 43230fdf1140b8d1ce93f3821d986fa165552023440lgao chkGTFlag(); 43330fdf1140b8d1ce93f3821d986fa165552023440lgao } 43430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 43530fdf1140b8d1ce93f3821d986fa165552023440lgao 43630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR14 Arpad Beszedes 26-May-98 43730fdf1140b8d1ce93f3821d986fa165552023440lgao Add support for #line directives when antlr source is pre-processed 43830fdf1140b8d1ce93f3821d986fa165552023440lgao #lexclass ACTIONS 43930fdf1140b8d1ce93f3821d986fa165552023440lgao*/ 44030fdf1140b8d1ce93f3821d986fa165552023440lgao 44130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)" 44230fdf1140b8d1ce93f3821d986fa165552023440lgao << 44330fdf1140b8d1ce93f3821d986fa165552023440lgao zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore(); 44430fdf1140b8d1ce93f3821d986fa165552023440lgao getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr); 44530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 44630fdf1140b8d1ce93f3821d986fa165552023440lgao 44730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#line ~[\n\r]* (\n|\r|\r\n)" 44830fdf1140b8d1ce93f3821d986fa165552023440lgao << 44930fdf1140b8d1ce93f3821d986fa165552023440lgao zzline++; zzmore(); 45030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 45130fdf1140b8d1ce93f3821d986fa165552023440lgao 45230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR14 end of a block to support #line in antlr source code */ 45330fdf1140b8d1ce93f3821d986fa165552023440lgao 45430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#[_a-zA-Z][_a-zA-Z0-9]*" 45530fdf1140b8d1ce93f3821d986fa165552023440lgao << 45630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !(strcmp(zzbegexpr, "#ifdef")==0 || 45730fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#if")==0 || 45830fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#else")==0 || 45930fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#endif")==0 || 46030fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#ifndef")==0 || 46130fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#define")==0 || 46230fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#pragma")==0 || 46330fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#undef")==0 || 46430fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#import")==0 || 46530fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#line")==0 || 46630fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#include")==0 || 46730fdf1140b8d1ce93f3821d986fa165552023440lgao strcmp(zzbegexpr, "#error")==0) ) 46830fdf1140b8d1ce93f3821d986fa165552023440lgao { 46930fdf1140b8d1ce93f3821d986fa165552023440lgao static char buf[100]; 47030fdf1140b8d1ce93f3821d986fa165552023440lgao sprintf(buf, "%s_ast", zzbegexpr+1); 47130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR27 */ list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1)); 47230fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(buf); 47330fdf1140b8d1ce93f3821d986fa165552023440lgao chkGTFlag(); 47430fdf1140b8d1ce93f3821d986fa165552023440lgao } 47530fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 47630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 47730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#\[" << 47830fdf1140b8d1ce93f3821d986fa165552023440lgao pushint(']'); 47930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenCC ) { 48030fdf1140b8d1ce93f3821d986fa165552023440lgao if (NewAST) zzreplstr("(newAST("); 48130fdf1140b8d1ce93f3821d986fa165552023440lgao else zzreplstr("(new AST("); } 48230fdf1140b8d1ce93f3821d986fa165552023440lgao else zzreplstr("zzmk_ast(zzastnew(),"); 48330fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 48430fdf1140b8d1ce93f3821d986fa165552023440lgao chkGTFlag(); 48530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 48630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#\(" << 48730fdf1140b8d1ce93f3821d986fa165552023440lgao pushint('}'); 48830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenCC ) { 48930fdf1140b8d1ce93f3821d986fa165552023440lgao if (tmakeInParser) { 49030fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr("tmake("); 49130fdf1140b8d1ce93f3821d986fa165552023440lgao } 49230fdf1140b8d1ce93f3821d986fa165552023440lgao else { 49330fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr("ASTBase::tmake("); 49430fdf1140b8d1ce93f3821d986fa165552023440lgao } 49530fdf1140b8d1ce93f3821d986fa165552023440lgao } 49630fdf1140b8d1ce93f3821d986fa165552023440lgao else { 49730fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr("zztmake("); 49830fdf1140b8d1ce93f3821d986fa165552023440lgao } 49930fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 50030fdf1140b8d1ce93f3821d986fa165552023440lgao chkGTFlag(); 50130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 50230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#" << zzmore(); >> 50330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\)" << 50430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( istackempty() ) 50530fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 50630fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( topint()==')' ) { 50730fdf1140b8d1ce93f3821d986fa165552023440lgao popint(); 50830fdf1140b8d1ce93f3821d986fa165552023440lgao } 50930fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( topint()=='}' ) { 51030fdf1140b8d1ce93f3821d986fa165552023440lgao popint(); 51130fdf1140b8d1ce93f3821d986fa165552023440lgao /* terminate #(..) */ 51230fdf1140b8d1ce93f3821d986fa165552023440lgao zzreplstr(", NULL)"); 51330fdf1140b8d1ce93f3821d986fa165552023440lgao } 51430fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 51530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 51630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\[" << 51730fdf1140b8d1ce93f3821d986fa165552023440lgao pushint('|'); /* look for '|' to terminate simple [...] */ 51830fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 51930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 52030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\(" << 52130fdf1140b8d1ce93f3821d986fa165552023440lgao pushint(')'); 52230fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); 52330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 52430fdf1140b8d1ce93f3821d986fa165552023440lgao 52530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\\]" << zzreplstr("]"); zzmore(); >> 52630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\\)" << zzreplstr(")"); zzmore(); >> 52730fdf1140b8d1ce93f3821d986fa165552023440lgao 52830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 10-Apr-97 MR1 Previously unable to put right shift operator */ 52930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 in DLG action */ 53030fdf1140b8d1ce93f3821d986fa165552023440lgao 53130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\>" << if (! tokenActionActive) zzreplstr(">"); /* MR1 */ 53230fdf1140b8d1ce93f3821d986fa165552023440lgao zzmore(); /* MR1 */ 53330fdf1140b8d1ce93f3821d986fa165552023440lgao >> /* MR1 */ 53430fdf1140b8d1ce93f3821d986fa165552023440lgao 53530fdf1140b8d1ce93f3821d986fa165552023440lgao 53630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "'" << zzmode(ACTION_CHARS); zzmore();>> 53730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\"" << zzmode(ACTION_STRINGS); zzmore();>> 53830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\$" << zzreplstr("$"); zzmore(); >> 53930fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\#" << zzreplstr("#"); zzmore(); >> 54030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\(\n|\r|\r\n)" << zzline++; zzmore(); >> 54130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\\~[\]\)>$#]" << zzmore(); >> /* escaped char, always ignore */ 54230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "/" << zzmore(); >> 54330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "/\*" << zzmode(ACTION_COMMENTS); zzmore(); >> 54430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*/" << warn("Missing /*; found dangling */ in action"); zzmore(); >> 54530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "//" << zzmode(ACTION_CPP_COMMENTS); zzmore(); >> 54630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "~[\n\r\)\(\\$#\>\]\[\"'/]+" << zzmore(); >> 54730fdf1140b8d1ce93f3821d986fa165552023440lgao 54830fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass START 54930fdf1140b8d1ce93f3821d986fa165552023440lgao#token "[\t\ ]+" << zzskip(); >> /* Ignore White */ 55030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzskip(); >> /* Track Line # */ 55130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\[" << zzmode(ACTIONS); zzmore(); 55230fdf1140b8d1ce93f3821d986fa165552023440lgao istackreset(); 55330fdf1140b8d1ce93f3821d986fa165552023440lgao pushint(']'); >> 55430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\<\<" << action_file=CurFile; action_line=zzline; 55530fdf1140b8d1ce93f3821d986fa165552023440lgao zzmode(ACTIONS); zzmore(); 55630fdf1140b8d1ce93f3821d986fa165552023440lgao list_free(&CurActionLabels,0); /* MR10 */ 55730fdf1140b8d1ce93f3821d986fa165552023440lgao numericActionLabel=0; /* MR10 */ 55830fdf1140b8d1ce93f3821d986fa165552023440lgao istackreset(); 55930fdf1140b8d1ce93f3821d986fa165552023440lgao pushint('>'); >> 56030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\"" << zzmode(STRINGS); zzmore(); >> 56130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "/\*" << zzmode(COMMENTS); zzskip(); >> 56230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\*/" << warn("Missing /*; found dangling */"); zzskip(); >> 56330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "//" << zzmode(CPP_COMMENTS); zzskip(); >> 56430fdf1140b8d1ce93f3821d986fa165552023440lgao 56530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR14 Arpad Beszedes 26-May-98 56630fdf1140b8d1ce93f3821d986fa165552023440lgao Add support for #line directives when antlr source is pre-processed 56730fdf1140b8d1ce93f3821d986fa165552023440lgao #lexclass START 56830fdf1140b8d1ce93f3821d986fa165552023440lgao*/ 56930fdf1140b8d1ce93f3821d986fa165552023440lgao 57030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)" 57130fdf1140b8d1ce93f3821d986fa165552023440lgao << 57230fdf1140b8d1ce93f3821d986fa165552023440lgao zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore(); 57330fdf1140b8d1ce93f3821d986fa165552023440lgao getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr); 57430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 57530fdf1140b8d1ce93f3821d986fa165552023440lgao 57630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#line ~[\n\r]* (\n|\r|\r\n)" 57730fdf1140b8d1ce93f3821d986fa165552023440lgao << 57830fdf1140b8d1ce93f3821d986fa165552023440lgao zzline++; zzmore(); 57930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 58030fdf1140b8d1ce93f3821d986fa165552023440lgao 58130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR14 end of a block to support #line in antlr source code */ 58230fdf1140b8d1ce93f3821d986fa165552023440lgao 58330fdf1140b8d1ce93f3821d986fa165552023440lgao/* */ 58430fdf1140b8d1ce93f3821d986fa165552023440lgao/* 8-Apr-97 Regularize escape sequence for ">>" */ 58530fdf1140b8d1ce93f3821d986fa165552023440lgao/* appearing in string literals */ 58630fdf1140b8d1ce93f3821d986fa165552023440lgao/* */ 58730fdf1140b8d1ce93f3821d986fa165552023440lgao 58830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\>\>" << warn("Missing <<; found dangling \>\>"); zzskip(); >> /* MR1 */ 58930fdf1140b8d1ce93f3821d986fa165552023440lgao#token WildCard "." 59030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\@" <<FoundException = 1; /* MR6 */ 59130fdf1140b8d1ce93f3821d986fa165552023440lgao FoundAtOperator = 1;>> /* MR6 */ 59230fdf1140b8d1ce93f3821d986fa165552023440lgao#token Eof "@" 59330fdf1140b8d1ce93f3821d986fa165552023440lgao << /* L o o k F o r A n o t h e r F i l e */ 59430fdf1140b8d1ce93f3821d986fa165552023440lgao { 59530fdf1140b8d1ce93f3821d986fa165552023440lgao FILE *new_input; 59630fdf1140b8d1ce93f3821d986fa165552023440lgao new_input = NextFile(); 59730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( new_input == NULL ) { NLA=Eof; return; } 59830fdf1140b8d1ce93f3821d986fa165552023440lgao fclose( input ); 59930fdf1140b8d1ce93f3821d986fa165552023440lgao input = new_input; 60030fdf1140b8d1ce93f3821d986fa165552023440lgao zzrdstream( input ); 60130fdf1140b8d1ce93f3821d986fa165552023440lgao zzskip(); /* Skip the Eof (@) char i.e continue */ 60230fdf1140b8d1ce93f3821d986fa165552023440lgao } 60330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 60430fdf1140b8d1ce93f3821d986fa165552023440lgao 60530fdf1140b8d1ce93f3821d986fa165552023440lgao#token LABEL 60630fdf1140b8d1ce93f3821d986fa165552023440lgao 60730fdf1140b8d1ce93f3821d986fa165552023440lgao#errclass "grammar-element" { element } 60830fdf1140b8d1ce93f3821d986fa165552023440lgao#errclass "meta-symbol" { "\}" "!" ";" "\|" "\~" "^" "\)" } 60930fdf1140b8d1ce93f3821d986fa165552023440lgao 61030fdf1140b8d1ce93f3821d986fa165552023440lgao#token Pragma "{\\}#pragma" /* MR21 */ 61130fdf1140b8d1ce93f3821d986fa165552023440lgao#token FirstSetSymbol "{\\}#FirstSetSymbol" /* MR21 */ 61230fdf1140b8d1ce93f3821d986fa165552023440lgao/* 61330fdf1140b8d1ce93f3821d986fa165552023440lgao * Get a grammar -- Build a list of rules like: 61430fdf1140b8d1ce93f3821d986fa165552023440lgao * 61530fdf1140b8d1ce93f3821d986fa165552023440lgao * o-->Rule1--o 61630fdf1140b8d1ce93f3821d986fa165552023440lgao * | 61730fdf1140b8d1ce93f3821d986fa165552023440lgao * o-->Rule2--o 61830fdf1140b8d1ce93f3821d986fa165552023440lgao * | 61930fdf1140b8d1ce93f3821d986fa165552023440lgao * ... 62030fdf1140b8d1ce93f3821d986fa165552023440lgao * | 62130fdf1140b8d1ce93f3821d986fa165552023440lgao * o-->RuleN--o 62230fdf1140b8d1ce93f3821d986fa165552023440lgao */ 62330fdf1140b8d1ce93f3821d986fa165552023440lgao 62430fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule grammar */ 62530fdf1140b8d1ce93f3821d986fa165552023440lgao 62630fdf1140b8d1ce93f3821d986fa165552023440lgaogrammar : <<Graph g;>> 62730fdf1140b8d1ce93f3821d986fa165552023440lgao ( "{\\}#header" Action /* MR13 */ 62830fdf1140b8d1ce93f3821d986fa165552023440lgao << 62930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( HdrAction==NULL ) { 63030fdf1140b8d1ce93f3821d986fa165552023440lgao HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 63130fdf1140b8d1ce93f3821d986fa165552023440lgao require(HdrAction!=NULL, "rule grammar: cannot allocate header action"); 63230fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(HdrAction, LATEXT(1)); 63330fdf1140b8d1ce93f3821d986fa165552023440lgao } 63430fdf1140b8d1ce93f3821d986fa165552023440lgao else warn("additional #header statement ignored"); 63530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 63630fdf1140b8d1ce93f3821d986fa165552023440lgao | "{\\}#first" Action 63730fdf1140b8d1ce93f3821d986fa165552023440lgao << 63830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( FirstAction==NULL ) { 63930fdf1140b8d1ce93f3821d986fa165552023440lgao FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 64030fdf1140b8d1ce93f3821d986fa165552023440lgao require(FirstAction!=NULL, "rule grammar: cannot allocate #first action"); 64130fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(FirstAction, LATEXT(1)); 64230fdf1140b8d1ce93f3821d986fa165552023440lgao } else { 64330fdf1140b8d1ce93f3821d986fa165552023440lgao warn("additional #first statement ignored"); 64430fdf1140b8d1ce93f3821d986fa165552023440lgao }; 64530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 64630fdf1140b8d1ce93f3821d986fa165552023440lgao 64730fdf1140b8d1ce93f3821d986fa165552023440lgao | "{\\}#parser" QuotedTerm 64830fdf1140b8d1ce93f3821d986fa165552023440lgao << 64930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenCC ) { 65030fdf1140b8d1ce93f3821d986fa165552023440lgao warn("#parser meta-op incompatible with -CC; ignored"); 65130fdf1140b8d1ce93f3821d986fa165552023440lgao } 65230fdf1140b8d1ce93f3821d986fa165552023440lgao else { 65330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( strcmp(ParserName,"zzparser")==0 ) { 65430fdf1140b8d1ce93f3821d986fa165552023440lgao ParserName=StripQuotes(mystrdup(LATEXT(1))); 65530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( RulePrefix[0]!='\0' ) 65630fdf1140b8d1ce93f3821d986fa165552023440lgao { 65730fdf1140b8d1ce93f3821d986fa165552023440lgao warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored"); 65830fdf1140b8d1ce93f3821d986fa165552023440lgao RulePrefix[0]='\0'; 65930fdf1140b8d1ce93f3821d986fa165552023440lgao } 66030fdf1140b8d1ce93f3821d986fa165552023440lgao } 66130fdf1140b8d1ce93f3821d986fa165552023440lgao else warn("additional #parser statement ignored"); 66230fdf1140b8d1ce93f3821d986fa165552023440lgao } 66330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 66430fdf1140b8d1ce93f3821d986fa165552023440lgao | "{\\}#tokdefs" QuotedTerm 66530fdf1140b8d1ce93f3821d986fa165552023440lgao <<{ 66630fdf1140b8d1ce93f3821d986fa165552023440lgao char *fname; 66730fdf1140b8d1ce93f3821d986fa165552023440lgao zzantlr_state st; FILE *f; struct zzdlg_state dst; 66830fdf1140b8d1ce93f3821d986fa165552023440lgao UserTokenDefsFile = mystrdup(LATEXT(1)); 66930fdf1140b8d1ce93f3821d986fa165552023440lgao zzsave_antlr_state(&st); 67030fdf1140b8d1ce93f3821d986fa165552023440lgao zzsave_dlg_state(&dst); 67130fdf1140b8d1ce93f3821d986fa165552023440lgao fname = mystrdup(LATEXT(1)); 67230fdf1140b8d1ce93f3821d986fa165552023440lgao f = fopen(StripQuotes(fname), "r"); 67330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));} 67430fdf1140b8d1ce93f3821d986fa165552023440lgao else { 67530fdf1140b8d1ce93f3821d986fa165552023440lgao ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE); 67630fdf1140b8d1ce93f3821d986fa165552023440lgao UserDefdTokens = 1; 67730fdf1140b8d1ce93f3821d986fa165552023440lgao } 67830fdf1140b8d1ce93f3821d986fa165552023440lgao zzrestore_antlr_state(&st); 67930fdf1140b8d1ce93f3821d986fa165552023440lgao zzrestore_dlg_state(&dst); 68030fdf1140b8d1ce93f3821d986fa165552023440lgao }>> 68130fdf1140b8d1ce93f3821d986fa165552023440lgao )* 68230fdf1140b8d1ce93f3821d986fa165552023440lgao ( Action 68330fdf1140b8d1ce93f3821d986fa165552023440lgao <<{ 68430fdf1140b8d1ce93f3821d986fa165552023440lgao UserAction *ua = newUserAction(LATEXT(1)); 68530fdf1140b8d1ce93f3821d986fa165552023440lgao ua->file = action_file; ua->line = action_line; 68630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( class_nest_level>0 ) list_add(&class_before_actions, ua); 68730fdf1140b8d1ce93f3821d986fa165552023440lgao else list_add(&BeforeActions, ua); 68830fdf1140b8d1ce93f3821d986fa165552023440lgao }>> 68930fdf1140b8d1ce93f3821d986fa165552023440lgao | laction 69030fdf1140b8d1ce93f3821d986fa165552023440lgao | lmember /* MR1 */ 69130fdf1140b8d1ce93f3821d986fa165552023440lgao | lprefix /* MR1 */ 69230fdf1140b8d1ce93f3821d986fa165552023440lgao | aLexclass 69330fdf1140b8d1ce93f3821d986fa165552023440lgao | token 69430fdf1140b8d1ce93f3821d986fa165552023440lgao | error 69530fdf1140b8d1ce93f3821d986fa165552023440lgao | tclass 69630fdf1140b8d1ce93f3821d986fa165552023440lgao | aPred /* MR11 */ 69730fdf1140b8d1ce93f3821d986fa165552023440lgao | default_exception_handler 69830fdf1140b8d1ce93f3821d986fa165552023440lgao | class_def 69930fdf1140b8d1ce93f3821d986fa165552023440lgao | "\}" 70030fdf1140b8d1ce93f3821d986fa165552023440lgao << 70130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( class_nest_level==0 ) 70230fdf1140b8d1ce93f3821d986fa165552023440lgao warn("missing class definition for trailing '}'"); 70330fdf1140b8d1ce93f3821d986fa165552023440lgao class_nest_level--; 70430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 70530fdf1140b8d1ce93f3821d986fa165552023440lgao )* 70630fdf1140b8d1ce93f3821d986fa165552023440lgao 70730fdf1140b8d1ce93f3821d986fa165552023440lgao rule <<g=$3; SynDiag = (Junction *) $3.left;>> 70830fdf1140b8d1ce93f3821d986fa165552023440lgao ( rule 70930fdf1140b8d1ce93f3821d986fa165552023440lgao 71030fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( $1.left!=NULL ) { 71130fdf1140b8d1ce93f3821d986fa165552023440lgao g.right = NULL; 71230fdf1140b8d1ce93f3821d986fa165552023440lgao 71330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21a */ /* Avoid use of a malformed graph when CannotContinue */ 71430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21a */ /* is already set */ 71530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21a */ 71630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21a */ if (! (CannotContinue && g.left == NULL)) { 71730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21a */ g = Or(g, $1); 71830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21a */ } 71930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21a */ } 72030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 72130fdf1140b8d1ce93f3821d986fa165552023440lgao 72230fdf1140b8d1ce93f3821d986fa165552023440lgao | aLexclass 72330fdf1140b8d1ce93f3821d986fa165552023440lgao | token 72430fdf1140b8d1ce93f3821d986fa165552023440lgao | error 72530fdf1140b8d1ce93f3821d986fa165552023440lgao | tclass 72630fdf1140b8d1ce93f3821d986fa165552023440lgao | aPred /* MR11 */ 72730fdf1140b8d1ce93f3821d986fa165552023440lgao | class_def 72830fdf1140b8d1ce93f3821d986fa165552023440lgao | "\}" 72930fdf1140b8d1ce93f3821d986fa165552023440lgao << 73030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( class_nest_level==0 ) 73130fdf1140b8d1ce93f3821d986fa165552023440lgao warn("missing class definition for trailing '}'"); 73230fdf1140b8d1ce93f3821d986fa165552023440lgao class_nest_level--; 73330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 73430fdf1140b8d1ce93f3821d986fa165552023440lgao )* 73530fdf1140b8d1ce93f3821d986fa165552023440lgao ( Action 73630fdf1140b8d1ce93f3821d986fa165552023440lgao <<{ 73730fdf1140b8d1ce93f3821d986fa165552023440lgao UserAction *ua = newUserAction(LATEXT(1)); 73830fdf1140b8d1ce93f3821d986fa165552023440lgao ua->file = action_file; ua->line = action_line; 73930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( class_nest_level>0 ) list_add(&class_after_actions, ua); 74030fdf1140b8d1ce93f3821d986fa165552023440lgao else list_add(&AfterActions, ua); 74130fdf1140b8d1ce93f3821d986fa165552023440lgao }>> 74230fdf1140b8d1ce93f3821d986fa165552023440lgao | laction 74330fdf1140b8d1ce93f3821d986fa165552023440lgao | lmember /* MR1 */ 74430fdf1140b8d1ce93f3821d986fa165552023440lgao | lprefix /* MR1 */ 74530fdf1140b8d1ce93f3821d986fa165552023440lgao | error 74630fdf1140b8d1ce93f3821d986fa165552023440lgao | tclass 74730fdf1140b8d1ce93f3821d986fa165552023440lgao | class_def 74830fdf1140b8d1ce93f3821d986fa165552023440lgao | aPred /* MR11 */ 74930fdf1140b8d1ce93f3821d986fa165552023440lgao | "\}" 75030fdf1140b8d1ce93f3821d986fa165552023440lgao << 75130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( class_nest_level==0 ) 75230fdf1140b8d1ce93f3821d986fa165552023440lgao warn("missing class definition for trailing '}'"); 75330fdf1140b8d1ce93f3821d986fa165552023440lgao class_nest_level--; 75430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 75530fdf1140b8d1ce93f3821d986fa165552023440lgao )* 75630fdf1140b8d1ce93f3821d986fa165552023440lgao Eof 75730fdf1140b8d1ce93f3821d986fa165552023440lgao ; 75830fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 75930fdf1140b8d1ce93f3821d986fa165552023440lgao 76030fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule class_def */ 76130fdf1140b8d1ce93f3821d986fa165552023440lgao 76230fdf1140b8d1ce93f3821d986fa165552023440lgaoclass_def 76330fdf1140b8d1ce93f3821d986fa165552023440lgao : <<int go=1; char name[MaxRuleName+1];>> 76430fdf1140b8d1ce93f3821d986fa165552023440lgao "class" 76530fdf1140b8d1ce93f3821d986fa165552023440lgao ( NonTerminal <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>> 76630fdf1140b8d1ce93f3821d986fa165552023440lgao | TokenTerm <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>> 76730fdf1140b8d1ce93f3821d986fa165552023440lgao ) 76830fdf1140b8d1ce93f3821d986fa165552023440lgao << 76930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0 77030fdf1140b8d1ce93f3821d986fa165552023440lgao && GenCC ) { 77130fdf1140b8d1ce93f3821d986fa165552023440lgao err("only one grammar class allowed in this release"); 77230fdf1140b8d1ce93f3821d986fa165552023440lgao go = 0; 77330fdf1140b8d1ce93f3821d986fa165552023440lgao } 77430fdf1140b8d1ce93f3821d986fa165552023440lgao else strcpy(CurrentClassName, name); 77530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 77630fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( !GenCC ) { err("class meta-op used without C++ option"); }>> 77730fdf1140b8d1ce93f3821d986fa165552023440lgao 77830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ (~ "\{" 77930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ <<if (ClassDeclStuff == NULL) { 78030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char)); 78130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ }; 78230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ strncat(ClassDeclStuff," ",MaxClassDeclStuff); 78330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff); 78430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ do { 78530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ if (0 == strcmp(LATEXT(1),"public")) break; 78630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ if (0 == strcmp(LATEXT(1),"private")) break; 78730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ if (0 == strcmp(LATEXT(1),"protected")) break; 78830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ if (0 == strcmp(LATEXT(1),"virtual")) break; 78930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ if (0 == strcmp(LATEXT(1),",")) break; 79030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ if (0 == strcmp(LATEXT(1),":")) break; 79130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ if (BaseClassName != NULL) break; 79230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char)); 79330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name"); 79430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ strcpy(BaseClassName,LATEXT(1)); 79530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR22 */ } while (0); 79630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ >> 79730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ )* 79830fdf1140b8d1ce93f3821d986fa165552023440lgao 79930fdf1140b8d1ce93f3821d986fa165552023440lgao "\{" 80030fdf1140b8d1ce93f3821d986fa165552023440lgao << 80130fdf1140b8d1ce93f3821d986fa165552023440lgao no_classes_found = 0; 80230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( class_nest_level>=1 ) {warn("cannot have nested classes");} 80330fdf1140b8d1ce93f3821d986fa165552023440lgao else class_nest_level++; 80430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 80530fdf1140b8d1ce93f3821d986fa165552023440lgao ; 80630fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 80730fdf1140b8d1ce93f3821d986fa165552023440lgao 80830fdf1140b8d1ce93f3821d986fa165552023440lgao/* 80930fdf1140b8d1ce93f3821d986fa165552023440lgao * Build -o-->o-R-o-->o- where -o-R-o- is the block from rule 'block'. 81030fdf1140b8d1ce93f3821d986fa165552023440lgao * Construct the RuleBlk front and EndRule node on the end of the 81130fdf1140b8d1ce93f3821d986fa165552023440lgao * block. This is used to add FOLLOW pointers to the rule end. Add the 81230fdf1140b8d1ce93f3821d986fa165552023440lgao * new rule name to the Rname hash table and sets its rulenum. 81330fdf1140b8d1ce93f3821d986fa165552023440lgao * Store the parameter definitions if any are found. 81430fdf1140b8d1ce93f3821d986fa165552023440lgao * 81530fdf1140b8d1ce93f3821d986fa165552023440lgao * Note that locks are required on the RuleBlk and EndRule nodes to thwart 81630fdf1140b8d1ce93f3821d986fa165552023440lgao * infinite recursion. 81730fdf1140b8d1ce93f3821d986fa165552023440lgao * 81830fdf1140b8d1ce93f3821d986fa165552023440lgao * Return the left graph pointer == NULL to indicate error/dupl rule def. 81930fdf1140b8d1ce93f3821d986fa165552023440lgao */ 82030fdf1140b8d1ce93f3821d986fa165552023440lgao 82130fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule rule */ 82230fdf1140b8d1ce93f3821d986fa165552023440lgao 82330fdf1140b8d1ce93f3821d986fa165552023440lgaorule : << 82430fdf1140b8d1ce93f3821d986fa165552023440lgao 82530fdf1140b8d1ce93f3821d986fa165552023440lgao ExceptionGroup *eg; 82630fdf1140b8d1ce93f3821d986fa165552023440lgao RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e; 82730fdf1140b8d1ce93f3821d986fa165552023440lgao set toksrefd, rulesrefd; 82830fdf1140b8d1ce93f3821d986fa165552023440lgao char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL; 82930fdf1140b8d1ce93f3821d986fa165552023440lgao CurExGroups = NULL; 83030fdf1140b8d1ce93f3821d986fa165552023440lgao CurElementLabels = NULL; 83130fdf1140b8d1ce93f3821d986fa165552023440lgao CurAstLabelsInActions = NULL; /* MR27 */ 83230fdf1140b8d1ce93f3821d986fa165552023440lgao /* We want a new element label hash table for each rule */ 83330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Elabel!=NULL ) killHashTable(Elabel); 83430fdf1140b8d1ce93f3821d986fa165552023440lgao Elabel = newHashTable(); 83530fdf1140b8d1ce93f3821d986fa165552023440lgao attribsRefdFromAction = empty; 83630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 83730fdf1140b8d1ce93f3821d986fa165552023440lgao NonTerminal 83830fdf1140b8d1ce93f3821d986fa165552023440lgao <<q=NULL; 83930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( hash_get(Rname, LATEXT(1))!=NULL ) { 84030fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("duplicate rule definition: '%s'",LATEXT(1))); 84130fdf1140b8d1ce93f3821d986fa165552023440lgao CannotContinue=TRUE; 84230fdf1140b8d1ce93f3821d986fa165552023440lgao } 84330fdf1140b8d1ce93f3821d986fa165552023440lgao else 84430fdf1140b8d1ce93f3821d986fa165552023440lgao { 84530fdf1140b8d1ce93f3821d986fa165552023440lgao q = (RuleEntry *)hash_add(Rname, 84630fdf1140b8d1ce93f3821d986fa165552023440lgao LATEXT(1), 84730fdf1140b8d1ce93f3821d986fa165552023440lgao (Entry *)newRuleEntry(LATEXT(1))); 84830fdf1140b8d1ce93f3821d986fa165552023440lgao CurRule = q->str; 84930fdf1140b8d1ce93f3821d986fa165552023440lgao } 85030fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleNode = q; 85130fdf1140b8d1ce93f3821d986fa165552023440lgao f = CurFile; l = zzline; 85230fdf1140b8d1ce93f3821d986fa165552023440lgao NumRules++; 85330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 85430fdf1140b8d1ce93f3821d986fa165552023440lgao { "!" <<if ( q!=NULL ) q->noAST = TRUE;>> } 85530fdf1140b8d1ce93f3821d986fa165552023440lgao { <<;>> 85630fdf1140b8d1ce93f3821d986fa165552023440lgao {"\<"} 85730fdf1140b8d1ce93f3821d986fa165552023440lgao PassAction 85830fdf1140b8d1ce93f3821d986fa165552023440lgao << pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 85930fdf1140b8d1ce93f3821d986fa165552023440lgao require(pdecl!=NULL, "rule rule: cannot allocate param decl"); 86030fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(pdecl, LATEXT(1)); 86130fdf1140b8d1ce93f3821d986fa165552023440lgao CurParmDef = pdecl; 86230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 86330fdf1140b8d1ce93f3821d986fa165552023440lgao } 86430fdf1140b8d1ce93f3821d986fa165552023440lgao { "\>" 86530fdf1140b8d1ce93f3821d986fa165552023440lgao PassAction 86630fdf1140b8d1ce93f3821d986fa165552023440lgao << ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 86730fdf1140b8d1ce93f3821d986fa165552023440lgao require(ret!=NULL, "rule rule: cannot allocate ret type"); 86830fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(ret, LATEXT(1)); 86930fdf1140b8d1ce93f3821d986fa165552023440lgao CurRetDef = ret; 87030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 87130fdf1140b8d1ce93f3821d986fa165552023440lgao } 87230fdf1140b8d1ce93f3821d986fa165552023440lgao { QuotedTerm <<if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));>> } 87330fdf1140b8d1ce93f3821d986fa165552023440lgao << 87430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenEClasseForRules && q!=NULL ) { 87530fdf1140b8d1ce93f3821d986fa165552023440lgao e = newECnode; 87630fdf1140b8d1ce93f3821d986fa165552023440lgao require(e!=NULL, "cannot allocate error class node"); 87730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);} 87830fdf1140b8d1ce93f3821d986fa165552023440lgao else a = q->egroup; 87930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( a ) == 0 ) 88030fdf1140b8d1ce93f3821d986fa165552023440lgao { 88130fdf1140b8d1ce93f3821d986fa165552023440lgao e->tok = addTname( a ); 88230fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&eclasses, (char *)e); 88330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]); 88430fdf1140b8d1ce93f3821d986fa165552023440lgao /* refers to itself */ 88530fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&(e->elist), mystrdup(q->str)); 88630fdf1140b8d1ce93f3821d986fa165552023440lgao } 88730fdf1140b8d1ce93f3821d986fa165552023440lgao else { 88830fdf1140b8d1ce93f3821d986fa165552023440lgao warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a)); 88930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]); 89030fdf1140b8d1ce93f3821d986fa165552023440lgao free((char *)e); 89130fdf1140b8d1ce93f3821d986fa165552023440lgao } 89230fdf1140b8d1ce93f3821d986fa165552023440lgao } 89330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 89430fdf1140b8d1ce93f3821d986fa165552023440lgao <<BlkLevel++; 89530fdf1140b8d1ce93f3821d986fa165552023440lgao if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply"); 89630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID; 89730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum; 89830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 89930fdf1140b8d1ce93f3821d986fa165552023440lgao 90030fdf1140b8d1ce93f3821d986fa165552023440lgao ":" <<inAlt=1;>> 90130fdf1140b8d1ce93f3821d986fa165552023440lgao block[&toksrefd, &rulesrefd] 90230fdf1140b8d1ce93f3821d986fa165552023440lgao <<r = makeBlk($7,0, NULL /* pFirstSetSymbol */ ); 90330fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk = (Junction *)r.left; 90430fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->blockid = CurBlockID; 90530fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->jtype = RuleBlk; 90630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( q!=NULL ) CurRuleBlk->rname = q->str; 90730fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->file = f; 90830fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->line = l; 90930fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->pdecl = pdecl; 91030fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->ret = ret; 91130fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->lock = makelocks(); 91230fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->pred_lock = makelocks(); 91330fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->tokrefs = toksrefd; 91430fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->rulerefs = rulesrefd; 91530fdf1140b8d1ce93f3821d986fa165552023440lgao p = newJunction(); /* add EndRule Node */ 91630fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)r.right)->p1 = (Node *)p; 91730fdf1140b8d1ce93f3821d986fa165552023440lgao r.right = (Node *) p; 91830fdf1140b8d1ce93f3821d986fa165552023440lgao p->jtype = EndRule; 91930fdf1140b8d1ce93f3821d986fa165552023440lgao p->lock = makelocks(); 92030fdf1140b8d1ce93f3821d986fa165552023440lgao p->pred_lock = makelocks(); 92130fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->end = p; 92230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( q!=NULL ) q->rulenum = NumRules; 92330fdf1140b8d1ce93f3821d986fa165552023440lgao $7 = r; 92430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 92530fdf1140b8d1ce93f3821d986fa165552023440lgao << 92630fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR23 */ CurBlockID_array[BlkLevel] = (-1); 92730fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR23 */ CurAltNum_array[BlkLevel] = (-1); 92830fdf1140b8d1ce93f3821d986fa165552023440lgao --BlkLevel; 92930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 93030fdf1140b8d1ce93f3821d986fa165552023440lgao <<altFixup();leFixup();egFixup();>> /* MR7 */ 93130fdf1140b8d1ce93f3821d986fa165552023440lgao ";" <<inAlt=0;>> 93230fdf1140b8d1ce93f3821d986fa165552023440lgao { Action 93330fdf1140b8d1ce93f3821d986fa165552023440lgao << a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 93430fdf1140b8d1ce93f3821d986fa165552023440lgao require(a!=NULL, "rule rule: cannot allocate error action"); 93530fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(a, LATEXT(1)); 93630fdf1140b8d1ce93f3821d986fa165552023440lgao CurRuleBlk->erraction = a; 93730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 93830fdf1140b8d1ce93f3821d986fa165552023440lgao } 93930fdf1140b8d1ce93f3821d986fa165552023440lgao ( exception_group > [eg] 94030fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( eg!=NULL ) { 94130fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&CurExGroups, (void *)eg); 94230fdf1140b8d1ce93f3821d986fa165552023440lgao if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1; 94330fdf1140b8d1ce93f3821d986fa165552023440lgao } 94430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 94530fdf1140b8d1ce93f3821d986fa165552023440lgao )* 94630fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( q==NULL ) $0.left = NULL; else $0 = $7;>> 94730fdf1140b8d1ce93f3821d986fa165552023440lgao <<CurRuleBlk->exceptions = CurExGroups;>> 94830fdf1140b8d1ce93f3821d986fa165552023440lgao <<CurRuleBlk->el_labels = CurElementLabels;>> 94930fdf1140b8d1ce93f3821d986fa165552023440lgao <<CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;>> /* MR27 */ 95030fdf1140b8d1ce93f3821d986fa165552023440lgao <<CurRuleNode = NULL;>> /* MR27 Moved */ 95130fdf1140b8d1ce93f3821d986fa165552023440lgao ; 95230fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 95330fdf1140b8d1ce93f3821d986fa165552023440lgao 95430fdf1140b8d1ce93f3821d986fa165552023440lgao/* 95530fdf1140b8d1ce93f3821d986fa165552023440lgao * pragma : "{\\}#pragma" "dup\-labeled\-tokens" 95630fdf1140b8d1ce93f3821d986fa165552023440lgao * <<Pragma_DupLabeledTokens=1;>> 95730fdf1140b8d1ce93f3821d986fa165552023440lgao * ; 95830fdf1140b8d1ce93f3821d986fa165552023440lgao */ 95930fdf1140b8d1ce93f3821d986fa165552023440lgao 96030fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule laction */ 96130fdf1140b8d1ce93f3821d986fa165552023440lgao 96230fdf1140b8d1ce93f3821d986fa165552023440lgaolaction : <<char *a;>> 96330fdf1140b8d1ce93f3821d986fa165552023440lgao 96430fdf1140b8d1ce93f3821d986fa165552023440lgao "{\\}#lexaction" 96530fdf1140b8d1ce93f3821d986fa165552023440lgao Action 96630fdf1140b8d1ce93f3821d986fa165552023440lgao << 96730fdf1140b8d1ce93f3821d986fa165552023440lgao a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 96830fdf1140b8d1ce93f3821d986fa165552023440lgao require(a!=NULL, "rule laction: cannot allocate action"); 96930fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(a, LATEXT(1)); 97030fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&LexActions, a); 97130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 97230fdf1140b8d1ce93f3821d986fa165552023440lgao ; 97330fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 97430fdf1140b8d1ce93f3821d986fa165552023440lgao 97530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ 97630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */ 97730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 via #lexmember <<....>> & #lexprefix <<...>> */ 97830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ 97930fdf1140b8d1ce93f3821d986fa165552023440lgao 98030fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule lmember */ 98130fdf1140b8d1ce93f3821d986fa165552023440lgao 98230fdf1140b8d1ce93f3821d986fa165552023440lgaolmember: <<char *a;>> /* MR1 */ 98330fdf1140b8d1ce93f3821d986fa165552023440lgao 98430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ "{\\}#lexmember" 98530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ Action 98630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ << 98730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ if (! GenCC) { 98830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ err("Use #lexmember only in C++ mode (to insert code in DLG class header"); 98930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ } else { 99030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 99130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ require(a!=NULL, "rule lmember: cannot allocate action"); 99230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ strcpy(a, LATEXT(1)); 99330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ list_add(&LexMemberActions, a); 99430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ }; 99530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ >> 99630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ ; 99730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ <<CannotContinue=TRUE;>> 99830fdf1140b8d1ce93f3821d986fa165552023440lgao 99930fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule lprefix */ 100030fdf1140b8d1ce93f3821d986fa165552023440lgao 100130fdf1140b8d1ce93f3821d986fa165552023440lgaolprefix: <<char *a;>> /* MR1 */ 100230fdf1140b8d1ce93f3821d986fa165552023440lgao 100330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ "{\\}#lexprefix" 100430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ Action 100530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ << 100630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ if (! GenCC) { 100730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ err("Use #lexprefix only in C++ mode (to insert code in DLG class header"); 100830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ } else { 100930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 101030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ require(a!=NULL, "rule lprefix: cannot allocate action"); 101130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ strcpy(a, LATEXT(1)); 101230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ list_add(&LexPrefixActions, a); 101330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ }; 101430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ >> 101530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ ; 101630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ <<CannotContinue=TRUE;>> 101730fdf1140b8d1ce93f3821d986fa165552023440lgao 101830fdf1140b8d1ce93f3821d986fa165552023440lgao/* 101930fdf1140b8d1ce93f3821d986fa165552023440lgao * #pred upper <<isupper()>>? predicate literal 102030fdf1140b8d1ce93f3821d986fa165552023440lgao * #pred lower <<islower()>>? predicate literal 102130fdf1140b8d1ce93f3821d986fa165552023440lgao * #pred up_or_low upper || lower predicate expression 102230fdf1140b8d1ce93f3821d986fa165552023440lgao * concealed interdependence 102330fdf1140b8d1ce93f3821d986fa165552023440lgao * #pred up_or_low_2 <<isletter()>>? A || B predicate literal equals predicate expr 102430fdf1140b8d1ce93f3821d986fa165552023440lgao * analyze using lower||upper 102530fdf1140b8d1ce93f3821d986fa165552023440lgao * generate using isLetter() 102630fdf1140b8d1ce93f3821d986fa165552023440lgao */ 102730fdf1140b8d1ce93f3821d986fa165552023440lgao 102830fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule aPref */ 102930fdf1140b8d1ce93f3821d986fa165552023440lgao 103030fdf1140b8d1ce93f3821d986fa165552023440lgaoaPred: <<PredEntry *predEntry=NULL; 103130fdf1140b8d1ce93f3821d986fa165552023440lgao char *name=NULL; 103230fdf1140b8d1ce93f3821d986fa165552023440lgao Predicate *predExpr=NULL; 103330fdf1140b8d1ce93f3821d986fa165552023440lgao char *predLiteral=NULL; 103430fdf1140b8d1ce93f3821d986fa165552023440lgao int save_file; 103530fdf1140b8d1ce93f3821d986fa165552023440lgao int save_line; 103630fdf1140b8d1ce93f3821d986fa165552023440lgao int predExprPresent=0; 103730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 103830fdf1140b8d1ce93f3821d986fa165552023440lgao 103930fdf1140b8d1ce93f3821d986fa165552023440lgao "{\\}#pred" 104030fdf1140b8d1ce93f3821d986fa165552023440lgao 104130fdf1140b8d1ce93f3821d986fa165552023440lgao << 104230fdf1140b8d1ce93f3821d986fa165552023440lgao MR_usingPredNames=1; /* will need to use -mrhoist version of genPredTree */ 104330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 104430fdf1140b8d1ce93f3821d986fa165552023440lgao 104530fdf1140b8d1ce93f3821d986fa165552023440lgao /* used to allow NonTerminal but it caused problems 104630fdf1140b8d1ce93f3821d986fa165552023440lgao when a rule name immediately followed a #pred statement */ 104730fdf1140b8d1ce93f3821d986fa165552023440lgao 104830fdf1140b8d1ce93f3821d986fa165552023440lgao TokenTerm <<name=mystrdup(LATEXT(1));>> 104930fdf1140b8d1ce93f3821d986fa165552023440lgao 105030fdf1140b8d1ce93f3821d986fa165552023440lgao << 105130fdf1140b8d1ce93f3821d986fa165552023440lgao /* don't free - referenced in predicates */ 105230fdf1140b8d1ce93f3821d986fa165552023440lgao 105330fdf1140b8d1ce93f3821d986fa165552023440lgao CurPredName=(char *)calloc(1,strlen(name) + 10); 105430fdf1140b8d1ce93f3821d986fa165552023440lgao strcat(CurPredName,"#pred "); 105530fdf1140b8d1ce93f3821d986fa165552023440lgao strcat(CurPredName,name); 105630fdf1140b8d1ce93f3821d986fa165552023440lgao 105730fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry=(PredEntry *) hash_get(Pname,name); 105830fdf1140b8d1ce93f3821d986fa165552023440lgao if (predEntry != NULL) { 105930fdf1140b8d1ce93f3821d986fa165552023440lgao warnFL(eMsg1("#pred %s previously defined - ignored",name), 106030fdf1140b8d1ce93f3821d986fa165552023440lgao FileStr[action_file],action_line); 106130fdf1140b8d1ce93f3821d986fa165552023440lgao name=NULL; 106230fdf1140b8d1ce93f3821d986fa165552023440lgao }; 106330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 106430fdf1140b8d1ce93f3821d986fa165552023440lgao 106530fdf1140b8d1ce93f3821d986fa165552023440lgao ( 106630fdf1140b8d1ce93f3821d986fa165552023440lgao 106730fdf1140b8d1ce93f3821d986fa165552023440lgao Pred <<predLiteral=mystrdup(LATEXT(1)); 106830fdf1140b8d1ce93f3821d986fa165552023440lgao save_line=action_line; 106930fdf1140b8d1ce93f3821d986fa165552023440lgao save_file=action_file; 107030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 107130fdf1140b8d1ce93f3821d986fa165552023440lgao 107230fdf1140b8d1ce93f3821d986fa165552023440lgao { 107330fdf1140b8d1ce93f3821d986fa165552023440lgao predOrExpr>[predExpr] <<predExprPresent=1;>> 107430fdf1140b8d1ce93f3821d986fa165552023440lgao } 107530fdf1140b8d1ce93f3821d986fa165552023440lgao 107630fdf1140b8d1ce93f3821d986fa165552023440lgao <<if (predLiteral != NULL && name != NULL) { 107730fdf1140b8d1ce93f3821d986fa165552023440lgao 107830fdf1140b8d1ce93f3821d986fa165552023440lgao /* 107930fdf1140b8d1ce93f3821d986fa165552023440lgao * predExpr may be NULL due to syntax errors 108030fdf1140b8d1ce93f3821d986fa165552023440lgao * or simply omitted by the user 108130fdf1140b8d1ce93f3821d986fa165552023440lgao */ 108230fdf1140b8d1ce93f3821d986fa165552023440lgao 108330fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry=newPredEntry(name); 108430fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry->file=save_file; 108530fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry->line=save_line; 108630fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr=MR_predFlatten(predExpr); 108730fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry->predLiteral=predLiteral; 108830fdf1140b8d1ce93f3821d986fa165552023440lgao if (! predExprPresent || predExpr == NULL) { 108930fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr=new_pred(); 109030fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->expr=predLiteral; 109130fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->source=newActionNode(); 109230fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->source->action=predExpr->expr; 109330fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->source->rname=CurPredName; 109430fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->source->line=action_line; 109530fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->source->file=action_file; 109630fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->source->is_predicate=1; 109730fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->k=predicateLookaheadDepth(predExpr->source); 109830fdf1140b8d1ce93f3821d986fa165552023440lgao }; 109930fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry->pred=predExpr; 110030fdf1140b8d1ce93f3821d986fa165552023440lgao hash_add(Pname,name,(Entry *)predEntry); 110130fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr=NULL; 110230fdf1140b8d1ce93f3821d986fa165552023440lgao }; 110330fdf1140b8d1ce93f3821d986fa165552023440lgao predicate_free(predExpr); 110430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 110530fdf1140b8d1ce93f3821d986fa165552023440lgao 110630fdf1140b8d1ce93f3821d986fa165552023440lgao | 110730fdf1140b8d1ce93f3821d986fa165552023440lgao <<save_line=zzline; save_file=CurFile;>> 110830fdf1140b8d1ce93f3821d986fa165552023440lgao 110930fdf1140b8d1ce93f3821d986fa165552023440lgao predOrExpr>[predExpr] 111030fdf1140b8d1ce93f3821d986fa165552023440lgao 111130fdf1140b8d1ce93f3821d986fa165552023440lgao <<if (predExpr != NULL && name != NULL) { 111230fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry=newPredEntry(name); 111330fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry->file=CurFile; 111430fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry->line=zzline; 111530fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr=MR_predFlatten(predExpr); 111630fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry->pred=predExpr; 111730fdf1140b8d1ce93f3821d986fa165552023440lgao hash_add(Pname,name,(Entry *)predEntry); 111830fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr=NULL; 111930fdf1140b8d1ce93f3821d986fa165552023440lgao }; 112030fdf1140b8d1ce93f3821d986fa165552023440lgao predicate_free(predExpr); 112130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 112230fdf1140b8d1ce93f3821d986fa165552023440lgao ) 112330fdf1140b8d1ce93f3821d986fa165552023440lgao {";"} 112430fdf1140b8d1ce93f3821d986fa165552023440lgao; 112530fdf1140b8d1ce93f3821d986fa165552023440lgao 112630fdf1140b8d1ce93f3821d986fa165552023440lgao/* fail */ 112730fdf1140b8d1ce93f3821d986fa165552023440lgao 112830fdf1140b8d1ce93f3821d986fa165552023440lgao<<predicate_free(predExpr); 112930fdf1140b8d1ce93f3821d986fa165552023440lgao>> 113030fdf1140b8d1ce93f3821d986fa165552023440lgao 113130fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule predOrExpr */ 113230fdf1140b8d1ce93f3821d986fa165552023440lgao 113330fdf1140b8d1ce93f3821d986fa165552023440lgaopredOrExpr>[Predicate *result] : 113430fdf1140b8d1ce93f3821d986fa165552023440lgao <<Predicate *ORnode; 113530fdf1140b8d1ce93f3821d986fa165552023440lgao Predicate *predExpr; 113630fdf1140b8d1ce93f3821d986fa165552023440lgao Predicate **tail=NULL; 113730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 113830fdf1140b8d1ce93f3821d986fa165552023440lgao predAndExpr>[predExpr] 113930fdf1140b8d1ce93f3821d986fa165552023440lgao << 114030fdf1140b8d1ce93f3821d986fa165552023440lgao ORnode=new_pred(); 114130fdf1140b8d1ce93f3821d986fa165552023440lgao ORnode->expr=PRED_OR_LIST; 114230fdf1140b8d1ce93f3821d986fa165552023440lgao if (predExpr != NULL) { 114330fdf1140b8d1ce93f3821d986fa165552023440lgao ORnode->down=predExpr; 114430fdf1140b8d1ce93f3821d986fa165552023440lgao tail=&predExpr->right; 114530fdf1140b8d1ce93f3821d986fa165552023440lgao }; 114630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 114730fdf1140b8d1ce93f3821d986fa165552023440lgao ( "\|\|" predAndExpr>[predExpr] 114830fdf1140b8d1ce93f3821d986fa165552023440lgao << 114930fdf1140b8d1ce93f3821d986fa165552023440lgao if (predExpr != NULL) { 115030fdf1140b8d1ce93f3821d986fa165552023440lgao *tail=predExpr; 115130fdf1140b8d1ce93f3821d986fa165552023440lgao tail=&predExpr->right; 115230fdf1140b8d1ce93f3821d986fa165552023440lgao }; 115330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 115430fdf1140b8d1ce93f3821d986fa165552023440lgao )* 115530fdf1140b8d1ce93f3821d986fa165552023440lgao << 115630fdf1140b8d1ce93f3821d986fa165552023440lgao $result=ORnode; 115730fdf1140b8d1ce93f3821d986fa165552023440lgao ORnode=NULL; 115830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 115930fdf1140b8d1ce93f3821d986fa165552023440lgao; 116030fdf1140b8d1ce93f3821d986fa165552023440lgao 116130fdf1140b8d1ce93f3821d986fa165552023440lgao/* fail */ 116230fdf1140b8d1ce93f3821d986fa165552023440lgao 116330fdf1140b8d1ce93f3821d986fa165552023440lgao<<predicate_free(ORnode);>> 116430fdf1140b8d1ce93f3821d986fa165552023440lgao 116530fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule predAndExpr */ 116630fdf1140b8d1ce93f3821d986fa165552023440lgao 116730fdf1140b8d1ce93f3821d986fa165552023440lgaopredAndExpr>[Predicate *result] : 116830fdf1140b8d1ce93f3821d986fa165552023440lgao <<Predicate *ANDnode; 116930fdf1140b8d1ce93f3821d986fa165552023440lgao Predicate *predExpr; 117030fdf1140b8d1ce93f3821d986fa165552023440lgao Predicate **tail=NULL; 117130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 117230fdf1140b8d1ce93f3821d986fa165552023440lgao predPrimary>[predExpr] 117330fdf1140b8d1ce93f3821d986fa165552023440lgao << 117430fdf1140b8d1ce93f3821d986fa165552023440lgao ANDnode=new_pred(); 117530fdf1140b8d1ce93f3821d986fa165552023440lgao ANDnode->expr=PRED_AND_LIST; 117630fdf1140b8d1ce93f3821d986fa165552023440lgao if (predExpr != NULL) { 117730fdf1140b8d1ce93f3821d986fa165552023440lgao ANDnode->down=predExpr; 117830fdf1140b8d1ce93f3821d986fa165552023440lgao tail=&predExpr->right; 117930fdf1140b8d1ce93f3821d986fa165552023440lgao }; 118030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 118130fdf1140b8d1ce93f3821d986fa165552023440lgao ( "&&" predPrimary>[predExpr] 118230fdf1140b8d1ce93f3821d986fa165552023440lgao << 118330fdf1140b8d1ce93f3821d986fa165552023440lgao if (predExpr != NULL) { 118430fdf1140b8d1ce93f3821d986fa165552023440lgao *tail=predExpr; 118530fdf1140b8d1ce93f3821d986fa165552023440lgao tail=&predExpr->right; 118630fdf1140b8d1ce93f3821d986fa165552023440lgao }; 118730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 118830fdf1140b8d1ce93f3821d986fa165552023440lgao )* 118930fdf1140b8d1ce93f3821d986fa165552023440lgao << 119030fdf1140b8d1ce93f3821d986fa165552023440lgao $result=ANDnode; 119130fdf1140b8d1ce93f3821d986fa165552023440lgao ANDnode=NULL; 119230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 119330fdf1140b8d1ce93f3821d986fa165552023440lgao; 119430fdf1140b8d1ce93f3821d986fa165552023440lgao 119530fdf1140b8d1ce93f3821d986fa165552023440lgao/* fail */ 119630fdf1140b8d1ce93f3821d986fa165552023440lgao 119730fdf1140b8d1ce93f3821d986fa165552023440lgao<<predicate_free(ANDnode);>> 119830fdf1140b8d1ce93f3821d986fa165552023440lgao 119930fdf1140b8d1ce93f3821d986fa165552023440lgao 120030fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule predPrimary */ 120130fdf1140b8d1ce93f3821d986fa165552023440lgao 120230fdf1140b8d1ce93f3821d986fa165552023440lgaopredPrimary>[Predicate *result] : 120330fdf1140b8d1ce93f3821d986fa165552023440lgao << 120430fdf1140b8d1ce93f3821d986fa165552023440lgao char *name=NULL; 120530fdf1140b8d1ce93f3821d986fa165552023440lgao PredEntry *predEntry=NULL; 120630fdf1140b8d1ce93f3821d986fa165552023440lgao Predicate *predExpr=NULL; 120730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 120830fdf1140b8d1ce93f3821d986fa165552023440lgao 120930fdf1140b8d1ce93f3821d986fa165552023440lgao TokenTerm <<name=mystrdup(LATEXT(1));>> 121030fdf1140b8d1ce93f3821d986fa165552023440lgao 121130fdf1140b8d1ce93f3821d986fa165552023440lgao << 121230fdf1140b8d1ce93f3821d986fa165552023440lgao predEntry=(PredEntry *) hash_get(Pname,name); 121330fdf1140b8d1ce93f3821d986fa165552023440lgao if (predEntry == NULL) { 121430fdf1140b8d1ce93f3821d986fa165552023440lgao warnFL(eMsg1("no previously defined #pred with name \"%s\"",name), 121530fdf1140b8d1ce93f3821d986fa165552023440lgao FileStr[CurFile],zzline); 121630fdf1140b8d1ce93f3821d986fa165552023440lgao name=NULL; 121730fdf1140b8d1ce93f3821d986fa165552023440lgao $result=NULL; 121830fdf1140b8d1ce93f3821d986fa165552023440lgao } else { 121930fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr=predicate_dup(predEntry->pred); 122030fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->predEntry=predEntry; 122130fdf1140b8d1ce93f3821d986fa165552023440lgao $result=predExpr; 122230fdf1140b8d1ce93f3821d986fa165552023440lgao }; 122330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 122430fdf1140b8d1ce93f3821d986fa165552023440lgao 122530fdf1140b8d1ce93f3821d986fa165552023440lgao | "\(" predOrExpr>[predExpr] "\)" 122630fdf1140b8d1ce93f3821d986fa165552023440lgao << 122730fdf1140b8d1ce93f3821d986fa165552023440lgao $result=predExpr; 122830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 122930fdf1140b8d1ce93f3821d986fa165552023440lgao 123030fdf1140b8d1ce93f3821d986fa165552023440lgao | "!" predPrimary>[predExpr] 123130fdf1140b8d1ce93f3821d986fa165552023440lgao << 123230fdf1140b8d1ce93f3821d986fa165552023440lgao predExpr->inverted=!predExpr->inverted; 123330fdf1140b8d1ce93f3821d986fa165552023440lgao $result=predExpr; 123430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 123530fdf1140b8d1ce93f3821d986fa165552023440lgao; 123630fdf1140b8d1ce93f3821d986fa165552023440lgao 123730fdf1140b8d1ce93f3821d986fa165552023440lgao/* fail */ << 123830fdf1140b8d1ce93f3821d986fa165552023440lgao predicate_free(predExpr); 123930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 124030fdf1140b8d1ce93f3821d986fa165552023440lgao 124130fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule aLexclass */ 124230fdf1140b8d1ce93f3821d986fa165552023440lgao 124330fdf1140b8d1ce93f3821d986fa165552023440lgaoaLexclass: "{\\}#lexclass" TokenTerm <<lexclass(mystrdup(LATEXT(1)));>> 124430fdf1140b8d1ce93f3821d986fa165552023440lgao ; 124530fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 124630fdf1140b8d1ce93f3821d986fa165552023440lgao 124730fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule error */ 124830fdf1140b8d1ce93f3821d986fa165552023440lgao 124930fdf1140b8d1ce93f3821d986fa165552023440lgaoerror : <<char *t=NULL; ECnode *e; int go=1; TermEntry *p;>> 125030fdf1140b8d1ce93f3821d986fa165552023440lgao "{\\}#errclass" 125130fdf1140b8d1ce93f3821d986fa165552023440lgao (<<;>> TokenTerm <<t=mystrdup(LATEXT(1));>> 125230fdf1140b8d1ce93f3821d986fa165552023440lgao | QuotedTerm <<t=mystrdup(LATEXT(1));>> 125330fdf1140b8d1ce93f3821d986fa165552023440lgao ) 125430fdf1140b8d1ce93f3821d986fa165552023440lgao <<e = newECnode; 125530fdf1140b8d1ce93f3821d986fa165552023440lgao require(e!=NULL, "cannot allocate error class node"); 125630fdf1140b8d1ce93f3821d986fa165552023440lgao e->lexclass = CurrentLexClass; 125730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( (t=StripQuotes(t)) ) == 0 ) 125830fdf1140b8d1ce93f3821d986fa165552023440lgao { 125930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( hash_get(Texpr, t) != NULL ) 126030fdf1140b8d1ce93f3821d986fa165552023440lgao warn(eMsg1("errclass name conflicts with regular expression '%s'",t)); 126130fdf1140b8d1ce93f3821d986fa165552023440lgao e->tok = addTname( t ); 126230fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(e->tok, &imag_tokens); 126330fdf1140b8d1ce93f3821d986fa165552023440lgao require((p=(TermEntry *)hash_get(Tname, t)) != NULL, 126430fdf1140b8d1ce93f3821d986fa165552023440lgao "hash table mechanism is broken"); 126530fdf1140b8d1ce93f3821d986fa165552023440lgao p->classname = 1; /* entry is errclass name, not token */ 126630fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&eclasses, (char *)e); 126730fdf1140b8d1ce93f3821d986fa165552023440lgao } 126830fdf1140b8d1ce93f3821d986fa165552023440lgao else 126930fdf1140b8d1ce93f3821d986fa165552023440lgao { 127030fdf1140b8d1ce93f3821d986fa165552023440lgao warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t)); 127130fdf1140b8d1ce93f3821d986fa165552023440lgao free( (char *)e ); 127230fdf1140b8d1ce93f3821d986fa165552023440lgao go=0; 127330fdf1140b8d1ce93f3821d986fa165552023440lgao } 127430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 127530fdf1140b8d1ce93f3821d986fa165552023440lgao "\{" 127630fdf1140b8d1ce93f3821d986fa165552023440lgao ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>> 127730fdf1140b8d1ce93f3821d986fa165552023440lgao | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>> 127830fdf1140b8d1ce93f3821d986fa165552023440lgao | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>> 127930fdf1140b8d1ce93f3821d986fa165552023440lgao ) 128030fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( go ) list_add(&(e->elist), t);>> 128130fdf1140b8d1ce93f3821d986fa165552023440lgao ( 128230fdf1140b8d1ce93f3821d986fa165552023440lgao ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>> 128330fdf1140b8d1ce93f3821d986fa165552023440lgao | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>> 128430fdf1140b8d1ce93f3821d986fa165552023440lgao | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>> 128530fdf1140b8d1ce93f3821d986fa165552023440lgao ) 128630fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( go ) list_add(&(e->elist), t);>> 128730fdf1140b8d1ce93f3821d986fa165552023440lgao )* 128830fdf1140b8d1ce93f3821d986fa165552023440lgao "\}" 128930fdf1140b8d1ce93f3821d986fa165552023440lgao ; 129030fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 129130fdf1140b8d1ce93f3821d986fa165552023440lgao 129230fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule tclass */ 129330fdf1140b8d1ce93f3821d986fa165552023440lgao 129430fdf1140b8d1ce93f3821d986fa165552023440lgaotclass : <<char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;>> 129530fdf1140b8d1ce93f3821d986fa165552023440lgao <<char *akaString=NULL; int save_file; int save_line;>> 129630fdf1140b8d1ce93f3821d986fa165552023440lgao <<char *totext=NULL; >> 129730fdf1140b8d1ce93f3821d986fa165552023440lgao "{\\}#tokclass" TokenTerm <<t=mystrdup(LATEXT(1));>> 129830fdf1140b8d1ce93f3821d986fa165552023440lgao <<e = newTCnode; 129930fdf1140b8d1ce93f3821d986fa165552023440lgao require(e!=NULL, "cannot allocate token class node"); 130030fdf1140b8d1ce93f3821d986fa165552023440lgao e->lexclass = CurrentLexClass; 130130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( t ) == 0 ) 130230fdf1140b8d1ce93f3821d986fa165552023440lgao { 130330fdf1140b8d1ce93f3821d986fa165552023440lgao e->tok = addTname( t ); 130430fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(e->tok, &imag_tokens); 130530fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(e->tok, &tokclasses); 130630fdf1140b8d1ce93f3821d986fa165552023440lgao require((p=(TermEntry *)hash_get(Tname, t)) != NULL, 130730fdf1140b8d1ce93f3821d986fa165552023440lgao "hash table mechanism is broken"); 130830fdf1140b8d1ce93f3821d986fa165552023440lgao p->classname = 1; /* entry is class name, not token */ 130930fdf1140b8d1ce93f3821d986fa165552023440lgao p->tclass = e; /* save ptr to this tclass def */ 131030fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&tclasses, (char *)e); 131130fdf1140b8d1ce93f3821d986fa165552023440lgao } 131230fdf1140b8d1ce93f3821d986fa165552023440lgao else 131330fdf1140b8d1ce93f3821d986fa165552023440lgao { 131430fdf1140b8d1ce93f3821d986fa165552023440lgao warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t)); 131530fdf1140b8d1ce93f3821d986fa165552023440lgao free( (char *)e ); 131630fdf1140b8d1ce93f3821d986fa165552023440lgao go=0; 131730fdf1140b8d1ce93f3821d986fa165552023440lgao } 131830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 131930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ { 132030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ "\(" 132130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ QuotedTerm 132230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ <<akaString=mystrdup(StripQuotes(LATEXT(1))); 132330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ save_file=CurFile;save_line=zzline; 132430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ >> 132530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ "\)" 132630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ } 132730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ 132830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ 132930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ << 133030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ if (p!= NULL && akaString != NULL) { 133130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ if (p->akaString != NULL) { 133230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ if (strcmp(p->akaString,akaString) != 0) { 133330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement", 133430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ t,p->akaString), 133530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ FileStr[save_file],save_line); 133630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ }; 133730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ } else { 133830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ p->akaString=akaString; 133930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ }; 134030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ }; 134130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ >> 134230fdf1140b8d1ce93f3821d986fa165552023440lgao 134330fdf1140b8d1ce93f3821d986fa165552023440lgao "\{" 134430fdf1140b8d1ce93f3821d986fa165552023440lgao ( 134530fdf1140b8d1ce93f3821d986fa165552023440lgao ( TokenTerm 134630fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( go ) { 134730fdf1140b8d1ce93f3821d986fa165552023440lgao term = (TermEntry *) hash_get(Tname, LATEXT(1)); 134830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( term==NULL && UserDefdTokens ) { 134930fdf1140b8d1ce93f3821d986fa165552023440lgao err("implicit token definition not allowed with #tokdefs"); 135030fdf1140b8d1ce93f3821d986fa165552023440lgao go = 0; 135130fdf1140b8d1ce93f3821d986fa165552023440lgao } 135230fdf1140b8d1ce93f3821d986fa165552023440lgao else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));} 135330fdf1140b8d1ce93f3821d986fa165552023440lgao }>> 135430fdf1140b8d1ce93f3821d986fa165552023440lgao 135530fdf1140b8d1ce93f3821d986fa165552023440lgao { 135630fdf1140b8d1ce93f3821d986fa165552023440lgao ".." 135730fdf1140b8d1ce93f3821d986fa165552023440lgao TokenTerm 135830fdf1140b8d1ce93f3821d986fa165552023440lgao 135930fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( go ) { 136030fdf1140b8d1ce93f3821d986fa165552023440lgao toterm = (TermEntry *) hash_get(Tname, LATEXT(1)); 136130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( toterm==NULL && UserDefdTokens ) { 136230fdf1140b8d1ce93f3821d986fa165552023440lgao err("implicit token definition not allowed with #tokdefs"); 136330fdf1140b8d1ce93f3821d986fa165552023440lgao go = 0; 136430fdf1140b8d1ce93f3821d986fa165552023440lgao } else { 136530fdf1140b8d1ce93f3821d986fa165552023440lgao totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1)); 136630fdf1140b8d1ce93f3821d986fa165552023440lgao } 136730fdf1140b8d1ce93f3821d986fa165552023440lgao } 136830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 136930fdf1140b8d1ce93f3821d986fa165552023440lgao } 137030fdf1140b8d1ce93f3821d986fa165552023440lgao 137130fdf1140b8d1ce93f3821d986fa165552023440lgao | QuotedTerm 137230fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( go ) { 137330fdf1140b8d1ce93f3821d986fa165552023440lgao term = (TermEntry *) hash_get(Texpr, LATEXT(1)); 137430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( term==NULL && UserDefdTokens ) { 137530fdf1140b8d1ce93f3821d986fa165552023440lgao err("implicit token definition not allowed with #tokdefs"); 137630fdf1140b8d1ce93f3821d986fa165552023440lgao go = 0; 137730fdf1140b8d1ce93f3821d986fa165552023440lgao } 137830fdf1140b8d1ce93f3821d986fa165552023440lgao else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));} 137930fdf1140b8d1ce93f3821d986fa165552023440lgao }>> 138030fdf1140b8d1ce93f3821d986fa165552023440lgao ) 138130fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( go ) { 138230fdf1140b8d1ce93f3821d986fa165552023440lgao if (totext == NULL) { 138330fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&(e->tlist), t); 138430fdf1140b8d1ce93f3821d986fa165552023440lgao } else { 138530fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&(e->tlist),".."); 138630fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&(e->tlist),t); 138730fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&(e->tlist),totext); 138830fdf1140b8d1ce93f3821d986fa165552023440lgao } 138930fdf1140b8d1ce93f3821d986fa165552023440lgao totext=NULL; 139030fdf1140b8d1ce93f3821d986fa165552023440lgao } 139130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 139230fdf1140b8d1ce93f3821d986fa165552023440lgao )+ // MR15 Manfred Kogler - forbid empty #tokclass sets (was "+") 139330fdf1140b8d1ce93f3821d986fa165552023440lgao "\}" 139430fdf1140b8d1ce93f3821d986fa165552023440lgao ; 139530fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 139630fdf1140b8d1ce93f3821d986fa165552023440lgao 139730fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule token */ 139830fdf1140b8d1ce93f3821d986fa165552023440lgao 139930fdf1140b8d1ce93f3821d986fa165552023440lgaotoken : <<char *t=NULL, *e=NULL, *a=NULL; int tnum=0;>> 140030fdf1140b8d1ce93f3821d986fa165552023440lgao <<char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;>> /* MR11 */ 140130fdf1140b8d1ce93f3821d986fa165552023440lgao "{\\}#token" 140230fdf1140b8d1ce93f3821d986fa165552023440lgao 140330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 10-Apr-97 MR1 Allow shift right operator in DLG actions */ 140430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 Danger when parser feedback to lexer */ 140530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR1 */ 140630fdf1140b8d1ce93f3821d986fa165552023440lgao 140730fdf1140b8d1ce93f3821d986fa165552023440lgao <<tokenActionActive=1;>> /* MR1 */ 140830fdf1140b8d1ce93f3821d986fa165552023440lgao { TokenTerm <<t=mystrdup(LATEXT(1));>> 140930fdf1140b8d1ce93f3821d986fa165552023440lgao 141030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ { 141130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ "\(" 141230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ QuotedTerm 141330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ <<akaString=mystrdup(StripQuotes(LATEXT(1))); 141430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ save_file=CurFile;save_line=zzline; 141530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ >> 141630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ "\)" 141730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ } 141830fdf1140b8d1ce93f3821d986fa165552023440lgao 141930fdf1140b8d1ce93f3821d986fa165552023440lgao { "=" "[0-9]+" /* define the token type number */ 142030fdf1140b8d1ce93f3821d986fa165552023440lgao <<tnum = atoi(LATEXT(1));>> 142130fdf1140b8d1ce93f3821d986fa165552023440lgao } 142230fdf1140b8d1ce93f3821d986fa165552023440lgao } 142330fdf1140b8d1ce93f3821d986fa165552023440lgao { QuotedTerm <<e=mystrdup(LATEXT(1));>> } 142430fdf1140b8d1ce93f3821d986fa165552023440lgao { Action 142530fdf1140b8d1ce93f3821d986fa165552023440lgao << 142630fdf1140b8d1ce93f3821d986fa165552023440lgao a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 142730fdf1140b8d1ce93f3821d986fa165552023440lgao require(a!=NULL, "rule token: cannot allocate action"); 142830fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(a, LATEXT(1)); 142930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 143030fdf1140b8d1ce93f3821d986fa165552023440lgao } 143130fdf1140b8d1ce93f3821d986fa165552023440lgao 143230fdf1140b8d1ce93f3821d986fa165552023440lgao { ";" } /* MR11 */ 143330fdf1140b8d1ce93f3821d986fa165552023440lgao 143430fdf1140b8d1ce93f3821d986fa165552023440lgao <<chkToken(t, e, a, tnum);>> 143530fdf1140b8d1ce93f3821d986fa165552023440lgao 143630fdf1140b8d1ce93f3821d986fa165552023440lgao <<if (t != NULL) { 143730fdf1140b8d1ce93f3821d986fa165552023440lgao te=(TermEntry *)hash_get(Tname,t); 143830fdf1140b8d1ce93f3821d986fa165552023440lgao if (te != NULL && akaString != NULL) { 143930fdf1140b8d1ce93f3821d986fa165552023440lgao if (te->akaString != NULL) { 144030fdf1140b8d1ce93f3821d986fa165552023440lgao if (strcmp(te->akaString,akaString) != 0) { 144130fdf1140b8d1ce93f3821d986fa165552023440lgao warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement", 144230fdf1140b8d1ce93f3821d986fa165552023440lgao t,te->akaString), 144330fdf1140b8d1ce93f3821d986fa165552023440lgao FileStr[save_file],save_line); 144430fdf1140b8d1ce93f3821d986fa165552023440lgao }; 144530fdf1140b8d1ce93f3821d986fa165552023440lgao } else { 144630fdf1140b8d1ce93f3821d986fa165552023440lgao te->akaString=akaString; 144730fdf1140b8d1ce93f3821d986fa165552023440lgao }; 144830fdf1140b8d1ce93f3821d986fa165552023440lgao }; 144930fdf1140b8d1ce93f3821d986fa165552023440lgao }; 145030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 145130fdf1140b8d1ce93f3821d986fa165552023440lgao ; 145230fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 145330fdf1140b8d1ce93f3821d986fa165552023440lgao 145430fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule block */ 145530fdf1140b8d1ce93f3821d986fa165552023440lgao 145630fdf1140b8d1ce93f3821d986fa165552023440lgaoblock[set *toksrefd, set *rulesrefd] 145730fdf1140b8d1ce93f3821d986fa165552023440lgao : << 145830fdf1140b8d1ce93f3821d986fa165552023440lgao Graph g, b; 145930fdf1140b8d1ce93f3821d986fa165552023440lgao set saveblah; 146030fdf1140b8d1ce93f3821d986fa165552023440lgao int saveinalt = inAlt; 146130fdf1140b8d1ce93f3821d986fa165552023440lgao ExceptionGroup *eg; 146230fdf1140b8d1ce93f3821d986fa165552023440lgao *$toksrefd = empty; 146330fdf1140b8d1ce93f3821d986fa165552023440lgao *$rulesrefd = empty; 146430fdf1140b8d1ce93f3821d986fa165552023440lgao set_clr(AST_nodes_refd_in_actions); 146530fdf1140b8d1ce93f3821d986fa165552023440lgao CurBlockID++; 146630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID; 146730fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltNum = 1; 146830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum; 146930fdf1140b8d1ce93f3821d986fa165552023440lgao saveblah = attribsRefdFromAction; 147030fdf1140b8d1ce93f3821d986fa165552023440lgao attribsRefdFromAction = empty; 147130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 147230fdf1140b8d1ce93f3821d986fa165552023440lgao 147330fdf1140b8d1ce93f3821d986fa165552023440lgao alt[toksrefd,rulesrefd] <<b = g = $1;>> 147430fdf1140b8d1ce93f3821d986fa165552023440lgao 147530fdf1140b8d1ce93f3821d986fa165552023440lgao << 147630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( ((Junction *)g.left)->p1->ntype == nAction ) 147730fdf1140b8d1ce93f3821d986fa165552023440lgao { 147830fdf1140b8d1ce93f3821d986fa165552023440lgao ActionNode *actionNode=(ActionNode *) 147930fdf1140b8d1ce93f3821d986fa165552023440lgao ( ( (Junction *)g.left) ->p1); 148030fdf1140b8d1ce93f3821d986fa165552023440lgao if (!actionNode->is_predicate ) 148130fdf1140b8d1ce93f3821d986fa165552023440lgao { 148230fdf1140b8d1ce93f3821d986fa165552023440lgao actionNode->init_action = TRUE; 148330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR12c */ if (actionNode->noHoist) { 148430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR12c */ errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>", 148530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR12c */ FileStr[actionNode->file],actionNode->line); 148630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR12c */ }; 148730fdf1140b8d1ce93f3821d986fa165552023440lgao } 148830fdf1140b8d1ce93f3821d986fa165552023440lgao } 148930fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)g.left)->blockid = CurBlockID; 149030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 149130fdf1140b8d1ce93f3821d986fa165552023440lgao 149230fdf1140b8d1ce93f3821d986fa165552023440lgao ( exception_group > [eg] 149330fdf1140b8d1ce93f3821d986fa165552023440lgao << 149430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( eg!=NULL ) { 149530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 ***** eg->altID = makeAltID(CurBlockID,CurAltNum); *****/ 149630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 ***** CurAltStart->exception_label = eg->altID; *****/ 149730fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&CurExGroups, (void *)eg); 149830fdf1140b8d1ce93f3821d986fa165552023440lgao } 149930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 150030fdf1140b8d1ce93f3821d986fa165552023440lgao )* 150130fdf1140b8d1ce93f3821d986fa165552023440lgao <<CurAltNum++; 150230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum; 150330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 150430fdf1140b8d1ce93f3821d986fa165552023440lgao 150530fdf1140b8d1ce93f3821d986fa165552023440lgao ( "\|" <<inAlt=1;>> 150630fdf1140b8d1ce93f3821d986fa165552023440lgao alt[toksrefd,rulesrefd] <<g = Or(g, $2);>> 150730fdf1140b8d1ce93f3821d986fa165552023440lgao << 150830fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)g.left)->blockid = CurBlockID; 150930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 151030fdf1140b8d1ce93f3821d986fa165552023440lgao 151130fdf1140b8d1ce93f3821d986fa165552023440lgao ( exception_group > [eg] 151230fdf1140b8d1ce93f3821d986fa165552023440lgao << 151330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( eg!=NULL ) { 151430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 ***** eg->altID = makeAltID(CurBlockID,CurAltNum); *****/ 151530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 ***** CurAltStart->exception_label = eg->altID; *****/ 151630fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&CurExGroups, (void *)eg); 151730fdf1140b8d1ce93f3821d986fa165552023440lgao } 151830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 151930fdf1140b8d1ce93f3821d986fa165552023440lgao )* 152030fdf1140b8d1ce93f3821d986fa165552023440lgao 152130fdf1140b8d1ce93f3821d986fa165552023440lgao <<CurAltNum++; 152230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum; 152330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 152430fdf1140b8d1ce93f3821d986fa165552023440lgao 152530fdf1140b8d1ce93f3821d986fa165552023440lgao )* 152630fdf1140b8d1ce93f3821d986fa165552023440lgao <<$0 = b;>> 152730fdf1140b8d1ce93f3821d986fa165552023440lgao <<attribsRefdFromAction = saveblah; inAlt = saveinalt;>> 152830fdf1140b8d1ce93f3821d986fa165552023440lgao ; 152930fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 153030fdf1140b8d1ce93f3821d986fa165552023440lgao 153130fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule alt */ 153230fdf1140b8d1ce93f3821d986fa165552023440lgao 153330fdf1140b8d1ce93f3821d986fa165552023440lgaoalt[set *toksrefd, set *rulesrefd] 153430fdf1140b8d1ce93f3821d986fa165552023440lgao : <<int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif; 153530fdf1140b8d1ce93f3821d986fa165552023440lgao int first_on_line = 1, use_def_MT_handler = 0; 153630fdf1140b8d1ce93f3821d986fa165552023440lgao g.left=NULL; g.right=NULL; 153730fdf1140b8d1ce93f3821d986fa165552023440lgao 153830fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = NULL; 153930fdf1140b8d1ce93f3821d986fa165552023440lgao elems = empty; 154030fdf1140b8d1ce93f3821d986fa165552023440lgao inAlt = 1; 154130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 154230fdf1140b8d1ce93f3821d986fa165552023440lgao { "\@" /* handle MismatchedToken signals with default handler */ 154330fdf1140b8d1ce93f3821d986fa165552023440lgao <<use_def_MT_handler = 1;>> 154430fdf1140b8d1ce93f3821d986fa165552023440lgao } 154530fdf1140b8d1ce93f3821d986fa165552023440lgao 154630fdf1140b8d1ce93f3821d986fa165552023440lgao ( <<;>> /* MR9 Removed unreferenced variable "tok" */ 154730fdf1140b8d1ce93f3821d986fa165552023440lgao { <<old_not=0;>> "\~" <<old_not=1;>> } 154830fdf1140b8d1ce93f3821d986fa165552023440lgao element[old_not, first_on_line, use_def_MT_handler] > [node] 154930fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;>> 155030fdf1140b8d1ce93f3821d986fa165552023440lgao << 155130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( $2.left!=NULL ) { 155230fdf1140b8d1ce93f3821d986fa165552023440lgao g = Cat(g, $2); 155330fdf1140b8d1ce93f3821d986fa165552023440lgao n++; 155430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( node!=NULL ) { 155530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( node->ntype!=nAction ) e_num++; 155630fdf1140b8d1ce93f3821d986fa165552023440lgao /* record record number of all rule and token refs */ 155730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( node->ntype==nToken ) { 155830fdf1140b8d1ce93f3821d986fa165552023440lgao TokNode *tk = (TokNode *)((Junction *)$2.left)->p1; 155930fdf1140b8d1ce93f3821d986fa165552023440lgao tk->elnum = e_num; 156030fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(e_num, &elems); 156130fdf1140b8d1ce93f3821d986fa165552023440lgao } 156230fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( node->ntype==nRuleRef ) { 156330fdf1140b8d1ce93f3821d986fa165552023440lgao RuleRefNode *rn = (RuleRefNode *)((Junction *)$2.left)->p1; 156430fdf1140b8d1ce93f3821d986fa165552023440lgao rn->elnum = e_num; 156530fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(e_num, $rulesrefd); 156630fdf1140b8d1ce93f3821d986fa165552023440lgao } 156730fdf1140b8d1ce93f3821d986fa165552023440lgao } 156830fdf1140b8d1ce93f3821d986fa165552023440lgao } 156930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 157030fdf1140b8d1ce93f3821d986fa165552023440lgao )* 157130fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( n == 0 ) g = emptyAlt(); 157230fdf1140b8d1ce93f3821d986fa165552023440lgao $0 = g; 157330fdf1140b8d1ce93f3821d986fa165552023440lgao /* We want to reduce number of LT(i) calls and the number of 157430fdf1140b8d1ce93f3821d986fa165552023440lgao * local attribute variables in C++ mode (for moment, later we'll 157530fdf1140b8d1ce93f3821d986fa165552023440lgao * do for C also). However, if trees are being built, they 157630fdf1140b8d1ce93f3821d986fa165552023440lgao * require most of the attrib variables to create the tree nodes 157730fdf1140b8d1ce93f3821d986fa165552023440lgao * with; therefore, we gen a token ptr for each token ref in C++ 157830fdf1140b8d1ce93f3821d986fa165552023440lgao */ 157930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenCC && !GenAST ) 158030fdf1140b8d1ce93f3821d986fa165552023440lgao { 158130fdf1140b8d1ce93f3821d986fa165552023440lgao /* This now free's the temp set -ATG 5/6/95 */ 158230fdf1140b8d1ce93f3821d986fa165552023440lgao set temp; 158330fdf1140b8d1ce93f3821d986fa165552023440lgao temp = set_and(elems, attribsRefdFromAction); 158430fdf1140b8d1ce93f3821d986fa165552023440lgao set_orin($toksrefd, temp); 158530fdf1140b8d1ce93f3821d986fa165552023440lgao set_free(temp); 158630fdf1140b8d1ce93f3821d986fa165552023440lgao } 158730fdf1140b8d1ce93f3821d986fa165552023440lgao else set_orin($toksrefd, elems); 158830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( GenCC ) { 158930fdf1140b8d1ce93f3821d986fa165552023440lgao dif = set_dif(attribsRefdFromAction, elems); 159030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( set_deg(dif)>0 ) 159130fdf1140b8d1ce93f3821d986fa165552023440lgao err("one or more $i in action(s) refer to non-token elements"); 159230fdf1140b8d1ce93f3821d986fa165552023440lgao set_free(dif); 159330fdf1140b8d1ce93f3821d986fa165552023440lgao } 159430fdf1140b8d1ce93f3821d986fa165552023440lgao set_free(elems); 159530fdf1140b8d1ce93f3821d986fa165552023440lgao set_free(attribsRefdFromAction); 159630fdf1140b8d1ce93f3821d986fa165552023440lgao inAlt = 0; 159730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 159830fdf1140b8d1ce93f3821d986fa165552023440lgao ; 159930fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 160030fdf1140b8d1ce93f3821d986fa165552023440lgao 160130fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule element_label */ 160230fdf1140b8d1ce93f3821d986fa165552023440lgao 160330fdf1140b8d1ce93f3821d986fa165552023440lgaoelement_label > [LabelEntry *label] 160430fdf1140b8d1ce93f3821d986fa165552023440lgao : <<TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;>> 160530fdf1140b8d1ce93f3821d986fa165552023440lgao LABEL <<lab = mystrdup(LATEXT(1));>> 160630fdf1140b8d1ce93f3821d986fa165552023440lgao << 160730fdf1140b8d1ce93f3821d986fa165552023440lgao UsedNewStyleLabel = 1; 160830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i"); 160930fdf1140b8d1ce93f3821d986fa165552023440lgao t = (TermEntry *) hash_get(Tname, lab); 161030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab); 161130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab); 161230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( t!=NULL ) { 161330fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab)); 161430fdf1140b8d1ce93f3821d986fa165552023440lgao $label = NULL; 161530fdf1140b8d1ce93f3821d986fa165552023440lgao } 161630fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( r!=NULL ) { 161730fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("label definition clashes with rule definition: '%s'", lab)); 161830fdf1140b8d1ce93f3821d986fa165552023440lgao $label = NULL; 161930fdf1140b8d1ce93f3821d986fa165552023440lgao } 162030fdf1140b8d1ce93f3821d986fa165552023440lgao else { 162130fdf1140b8d1ce93f3821d986fa165552023440lgao /* we don't clash with anybody else */ 162230fdf1140b8d1ce93f3821d986fa165552023440lgao l = (LabelEntry *) hash_get(Elabel, lab); 162330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( l==NULL ) { /* ok to add new element label */ 162430fdf1140b8d1ce93f3821d986fa165552023440lgao l = (LabelEntry *)hash_add(Elabel, 162530fdf1140b8d1ce93f3821d986fa165552023440lgao lab, 162630fdf1140b8d1ce93f3821d986fa165552023440lgao (Entry *)newLabelEntry(lab)); 162730fdf1140b8d1ce93f3821d986fa165552023440lgao /* add to list of element labels for this rule */ 162830fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&CurElementLabels, (void *)lab); 162930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ leAdd(l); /* list of labels waiting for exception group definitions */ 163030fdf1140b8d1ce93f3821d986fa165552023440lgao $label = l; 163130fdf1140b8d1ce93f3821d986fa165552023440lgao } 163230fdf1140b8d1ce93f3821d986fa165552023440lgao else { 163330fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("label definitions must be unique per rule: '%s'", lab)); 163430fdf1140b8d1ce93f3821d986fa165552023440lgao $label = NULL; 163530fdf1140b8d1ce93f3821d986fa165552023440lgao } 163630fdf1140b8d1ce93f3821d986fa165552023440lgao } 163730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 163830fdf1140b8d1ce93f3821d986fa165552023440lgao ":" 163930fdf1140b8d1ce93f3821d986fa165552023440lgao ; 164030fdf1140b8d1ce93f3821d986fa165552023440lgao 164130fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule element */ 164230fdf1140b8d1ce93f3821d986fa165552023440lgao 164330fdf1140b8d1ce93f3821d986fa165552023440lgaoelement[int old_not, int first_on_line, int use_def_MT_handler] > [Node *node] 164430fdf1140b8d1ce93f3821d986fa165552023440lgao : << 164530fdf1140b8d1ce93f3821d986fa165552023440lgao Attrib blk; 164630fdf1140b8d1ce93f3821d986fa165552023440lgao Predicate *pred = NULL; 164730fdf1140b8d1ce93f3821d986fa165552023440lgao int local_use_def_MT_handler=0; 164830fdf1140b8d1ce93f3821d986fa165552023440lgao ActionNode *act; 164930fdf1140b8d1ce93f3821d986fa165552023440lgao RuleRefNode *rr; 165030fdf1140b8d1ce93f3821d986fa165552023440lgao set toksrefd, rulesrefd; 165130fdf1140b8d1ce93f3821d986fa165552023440lgao TermEntry *term; 165230fdf1140b8d1ce93f3821d986fa165552023440lgao TokNode *p=NULL; RuleRefNode *q; int approx=0; 165330fdf1140b8d1ce93f3821d986fa165552023440lgao LabelEntry *label=NULL; 165430fdf1140b8d1ce93f3821d986fa165552023440lgao int predMsgDone=0; 165530fdf1140b8d1ce93f3821d986fa165552023440lgao int semDepth=0; 165630fdf1140b8d1ce93f3821d986fa165552023440lgao int ampersandStyle; 165730fdf1140b8d1ce93f3821d986fa165552023440lgao int height; /* MR11 */ 165830fdf1140b8d1ce93f3821d986fa165552023440lgao int equal_height; /* MR11 */ 165930fdf1140b8d1ce93f3821d986fa165552023440lgao 166030fdf1140b8d1ce93f3821d986fa165552023440lgao char* pFirstSetSymbol = NULL; /* MR21 */ 166130fdf1140b8d1ce93f3821d986fa165552023440lgao 166230fdf1140b8d1ce93f3821d986fa165552023440lgao $node = NULL; 166330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 166430fdf1140b8d1ce93f3821d986fa165552023440lgao {element_label>[label]} 166530fdf1140b8d1ce93f3821d986fa165552023440lgao ( TokenTerm 166630fdf1140b8d1ce93f3821d986fa165552023440lgao << 166730fdf1140b8d1ce93f3821d986fa165552023440lgao term = (TermEntry *) hash_get(Tname, LATEXT(1)); 166830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( term==NULL && UserDefdTokens ) { 166930fdf1140b8d1ce93f3821d986fa165552023440lgao err("implicit token definition not allowed with #tokdefs"); 167030fdf1140b8d1ce93f3821d986fa165552023440lgao $$.left = $$.right = NULL; 167130fdf1140b8d1ce93f3821d986fa165552023440lgao } 167230fdf1140b8d1ce93f3821d986fa165552023440lgao else { 167330fdf1140b8d1ce93f3821d986fa165552023440lgao $$ = buildToken(LATEXT(1)); 167430fdf1140b8d1ce93f3821d986fa165552023440lgao p=((TokNode *)((Junction *)$$.left)->p1); 167530fdf1140b8d1ce93f3821d986fa165552023440lgao term = (TermEntry *) hash_get(Tname, LATEXT(1)); 167630fdf1140b8d1ce93f3821d986fa165552023440lgao require( term!= NULL, "hash table mechanism is broken"); 167730fdf1140b8d1ce93f3821d986fa165552023440lgao p->tclass = term->tclass; 167830fdf1140b8d1ce93f3821d986fa165552023440lgao p->complement = $old_not; 167930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( label!=NULL ) { 168030fdf1140b8d1ce93f3821d986fa165552023440lgao p->el_label = label->str; 168130fdf1140b8d1ce93f3821d986fa165552023440lgao label->elem = (Node *)p; 168230fdf1140b8d1ce93f3821d986fa165552023440lgao } 168330fdf1140b8d1ce93f3821d986fa165552023440lgao } 168430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 168530fdf1140b8d1ce93f3821d986fa165552023440lgao { ".." 168630fdf1140b8d1ce93f3821d986fa165552023440lgao ( QuotedTerm 168730fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>> 168830fdf1140b8d1ce93f3821d986fa165552023440lgao | TokenTerm 168930fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>> 169030fdf1140b8d1ce93f3821d986fa165552023440lgao ) 169130fdf1140b8d1ce93f3821d986fa165552023440lgao } 169230fdf1140b8d1ce93f3821d986fa165552023440lgao << 169330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) ) 169430fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&MetaTokenNodes, (void *)p); 169530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 169630fdf1140b8d1ce93f3821d986fa165552023440lgao ( "^" <<if ( p!=NULL ) p->astnode=ASTroot;>> 169730fdf1140b8d1ce93f3821d986fa165552023440lgao | <<if ( p!=NULL ) p->astnode=ASTchild;>> 169830fdf1140b8d1ce93f3821d986fa165552023440lgao | "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>> 169930fdf1140b8d1ce93f3821d986fa165552023440lgao ) 170030fdf1140b8d1ce93f3821d986fa165552023440lgao { "\@" <<local_use_def_MT_handler = 1;>> } 170130fdf1140b8d1ce93f3821d986fa165552023440lgao << 170230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( p!=NULL && $first_on_line ) { 170330fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *)$$.left; 170430fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 170530fdf1140b8d1ce93f3821d986fa165552023440lgao p->altstart = CurAltStart; 170630fdf1140b8d1ce93f3821d986fa165552023440lgao } 170730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( p!=NULL ) 170830fdf1140b8d1ce93f3821d986fa165552023440lgao p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler; 170930fdf1140b8d1ce93f3821d986fa165552023440lgao $node = (Node *)p; 171030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 171130fdf1140b8d1ce93f3821d986fa165552023440lgao | QuotedTerm 171230fdf1140b8d1ce93f3821d986fa165552023440lgao << 171330fdf1140b8d1ce93f3821d986fa165552023440lgao term = (TermEntry *) hash_get(Texpr, LATEXT(1)); 171430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( term==NULL && UserDefdTokens ) { 171530fdf1140b8d1ce93f3821d986fa165552023440lgao err("implicit token definition not allowed with #tokdefs"); 171630fdf1140b8d1ce93f3821d986fa165552023440lgao $$.left = $$.right = NULL; 171730fdf1140b8d1ce93f3821d986fa165552023440lgao } 171830fdf1140b8d1ce93f3821d986fa165552023440lgao else { 171930fdf1140b8d1ce93f3821d986fa165552023440lgao $$ = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1); 172030fdf1140b8d1ce93f3821d986fa165552023440lgao p->complement = $old_not; 172130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( label!=NULL ) { 172230fdf1140b8d1ce93f3821d986fa165552023440lgao p->el_label = label->str; 172330fdf1140b8d1ce93f3821d986fa165552023440lgao label->elem = (Node *)p; 172430fdf1140b8d1ce93f3821d986fa165552023440lgao } 172530fdf1140b8d1ce93f3821d986fa165552023440lgao } 172630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 172730fdf1140b8d1ce93f3821d986fa165552023440lgao { ".." 172830fdf1140b8d1ce93f3821d986fa165552023440lgao ( QuotedTerm 172930fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>> 173030fdf1140b8d1ce93f3821d986fa165552023440lgao | TokenTerm 173130fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>> 173230fdf1140b8d1ce93f3821d986fa165552023440lgao ) 173330fdf1140b8d1ce93f3821d986fa165552023440lgao } 173430fdf1140b8d1ce93f3821d986fa165552023440lgao ( "^" <<if ( p!=NULL ) p->astnode=ASTroot;>> 173530fdf1140b8d1ce93f3821d986fa165552023440lgao | <<if ( p!=NULL ) p->astnode=ASTchild;>> 173630fdf1140b8d1ce93f3821d986fa165552023440lgao | "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>> 173730fdf1140b8d1ce93f3821d986fa165552023440lgao ) 173830fdf1140b8d1ce93f3821d986fa165552023440lgao { "\@" <<local_use_def_MT_handler = 1;>> } 173930fdf1140b8d1ce93f3821d986fa165552023440lgao << 174030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) ) 174130fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&MetaTokenNodes, (void *)p); 174230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 174330fdf1140b8d1ce93f3821d986fa165552023440lgao << 174430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( $first_on_line ) { 174530fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *)$$.left; 174630fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 174730fdf1140b8d1ce93f3821d986fa165552023440lgao p->altstart = CurAltStart; 174830fdf1140b8d1ce93f3821d986fa165552023440lgao } 174930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( p!=NULL ) 175030fdf1140b8d1ce93f3821d986fa165552023440lgao p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler; 175130fdf1140b8d1ce93f3821d986fa165552023440lgao $node = (Node *)p; 175230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 175330fdf1140b8d1ce93f3821d986fa165552023440lgao 175430fdf1140b8d1ce93f3821d986fa165552023440lgao | <<if ( $old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");>> 175530fdf1140b8d1ce93f3821d986fa165552023440lgao "." 175630fdf1140b8d1ce93f3821d986fa165552023440lgao <<$$ = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);>> 175730fdf1140b8d1ce93f3821d986fa165552023440lgao ( "^" <<p->astnode=ASTroot;>> 175830fdf1140b8d1ce93f3821d986fa165552023440lgao | <<p->astnode=ASTchild;>> 175930fdf1140b8d1ce93f3821d986fa165552023440lgao | "!" <<p->astnode=ASTexclude;>> 176030fdf1140b8d1ce93f3821d986fa165552023440lgao ) 176130fdf1140b8d1ce93f3821d986fa165552023440lgao <<list_add(&MetaTokenNodes, (void *)p);>> 176230fdf1140b8d1ce93f3821d986fa165552023440lgao << 176330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( $first_on_line ) { 176430fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *)$$.left; 176530fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 176630fdf1140b8d1ce93f3821d986fa165552023440lgao p->altstart = CurAltStart; 176730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( label!=NULL ) { 176830fdf1140b8d1ce93f3821d986fa165552023440lgao p->el_label = label->str; 176930fdf1140b8d1ce93f3821d986fa165552023440lgao label->elem = (Node *)p; 177030fdf1140b8d1ce93f3821d986fa165552023440lgao } 177130fdf1140b8d1ce93f3821d986fa165552023440lgao } 177230fdf1140b8d1ce93f3821d986fa165552023440lgao $node = (Node *)p; 177330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 177430fdf1140b8d1ce93f3821d986fa165552023440lgao 177530fdf1140b8d1ce93f3821d986fa165552023440lgao | <<if ( $old_not ) warn("~ NONTERMINAL is an undefined operation");>> 177630fdf1140b8d1ce93f3821d986fa165552023440lgao NonTerminal 177730fdf1140b8d1ce93f3821d986fa165552023440lgao <<$$ = buildRuleRef(LATEXT(1));>> 177830fdf1140b8d1ce93f3821d986fa165552023440lgao { "!" <<q = (RuleRefNode *) ((Junction *)$$.left)->p1; 177930fdf1140b8d1ce93f3821d986fa165552023440lgao q->astnode=ASTexclude;>> 178030fdf1140b8d1ce93f3821d986fa165552023440lgao } 178130fdf1140b8d1ce93f3821d986fa165552023440lgao { {"\<"} 178230fdf1140b8d1ce93f3821d986fa165552023440lgao PassAction <<addParm(((Junction *)$$.left)->p1, LATEXT(1));>> 178330fdf1140b8d1ce93f3821d986fa165552023440lgao } 178430fdf1140b8d1ce93f3821d986fa165552023440lgao <<rr=(RuleRefNode *) ((Junction *)$$.left)->p1;>> 178530fdf1140b8d1ce93f3821d986fa165552023440lgao { <<char *a;>> 178630fdf1140b8d1ce93f3821d986fa165552023440lgao "\>" 178730fdf1140b8d1ce93f3821d986fa165552023440lgao PassAction 178830fdf1140b8d1ce93f3821d986fa165552023440lgao << 178930fdf1140b8d1ce93f3821d986fa165552023440lgao a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 179030fdf1140b8d1ce93f3821d986fa165552023440lgao require(a!=NULL, "rule element: cannot allocate assignment"); 179130fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(a, LATEXT(1)); 179230fdf1140b8d1ce93f3821d986fa165552023440lgao rr->assign = a; 179330fdf1140b8d1ce93f3821d986fa165552023440lgao >> 179430fdf1140b8d1ce93f3821d986fa165552023440lgao } 179530fdf1140b8d1ce93f3821d986fa165552023440lgao << 179630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( label!=NULL ) { 179730fdf1140b8d1ce93f3821d986fa165552023440lgao rr->el_label = label->str; 179830fdf1140b8d1ce93f3821d986fa165552023440lgao label->elem = (Node *)rr; 179930fdf1140b8d1ce93f3821d986fa165552023440lgao } 180030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( $first_on_line ) { 180130fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *)$$.left; 180230fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 180330fdf1140b8d1ce93f3821d986fa165552023440lgao ((RuleRefNode *)((Junction *)$$.left)->p1)->altstart = CurAltStart; 180430fdf1140b8d1ce93f3821d986fa165552023440lgao } 180530fdf1140b8d1ce93f3821d986fa165552023440lgao $node = (Node *)rr; 180630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 180730fdf1140b8d1ce93f3821d986fa165552023440lgao ) 180830fdf1140b8d1ce93f3821d986fa165552023440lgao 180930fdf1140b8d1ce93f3821d986fa165552023440lgao | <<if ( $old_not ) warn("~ ACTION is an undefined operation");>> 181030fdf1140b8d1ce93f3821d986fa165552023440lgao Action <<$0 = buildAction(LATEXT(1),action_file,action_line, 0);>> 181130fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( $first_on_line ) { /* MR7 */ 181230fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *)$0.left; /* MR7 */ 181330fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 181430fdf1140b8d1ce93f3821d986fa165552023440lgao };>> /* MR7 */ 181530fdf1140b8d1ce93f3821d986fa165552023440lgao <<$node = (Node *) ((Junction *)$0.left)->p1;>> 181630fdf1140b8d1ce93f3821d986fa165552023440lgao 181730fdf1140b8d1ce93f3821d986fa165552023440lgao | <<if ( $old_not ) warn("~ SEMANTIC-PREDICATE is an undefined operation");>> 181830fdf1140b8d1ce93f3821d986fa165552023440lgao Pred <<$0 = buildAction(LATEXT(1),action_file,action_line, 1);>> 181930fdf1140b8d1ce93f3821d986fa165552023440lgao <<act = (ActionNode *) ((Junction *)$0.left)->p1;>> 182030fdf1140b8d1ce93f3821d986fa165552023440lgao <<if (numericActionLabel) { /* MR10 */ 182130fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&NumericPredLabels,act); /* MR10 */ 182230fdf1140b8d1ce93f3821d986fa165552023440lgao numericActionLabel=0; /* MR10 */ 182330fdf1140b8d1ce93f3821d986fa165552023440lgao }; /* MR10 */ 182430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 182530fdf1140b8d1ce93f3821d986fa165552023440lgao { <<char *a;>> 182630fdf1140b8d1ce93f3821d986fa165552023440lgao PassAction 182730fdf1140b8d1ce93f3821d986fa165552023440lgao << 182830fdf1140b8d1ce93f3821d986fa165552023440lgao a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 182930fdf1140b8d1ce93f3821d986fa165552023440lgao require(a!=NULL, "rule element: cannot allocate predicate fail action"); 183030fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(a, LATEXT(1)); 183130fdf1140b8d1ce93f3821d986fa165552023440lgao act->pred_fail = a; 183230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 183330fdf1140b8d1ce93f3821d986fa165552023440lgao } 183430fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( $first_on_line ) { /* MR7 */ 183530fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *)$0.left; /* MR7 */ 183630fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 183730fdf1140b8d1ce93f3821d986fa165552023440lgao };>> /* MR7 */ 183830fdf1140b8d1ce93f3821d986fa165552023440lgao <<$node = (Node *)act;>> 183930fdf1140b8d1ce93f3821d986fa165552023440lgao 184030fdf1140b8d1ce93f3821d986fa165552023440lgao | <<if ( $old_not ) warn("~ BLOCK is an undefined operation");>> 184130fdf1140b8d1ce93f3821d986fa165552023440lgao <<BlkLevel++; 184230fdf1140b8d1ce93f3821d986fa165552023440lgao if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply"); 184330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurBlockID_array[BlkLevel] = CurBlockID; 184430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR23 */ CurAltNum_array[BlkLevel] = CurAltNum; 184530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 184630fdf1140b8d1ce93f3821d986fa165552023440lgao { Pragma 184730fdf1140b8d1ce93f3821d986fa165552023440lgao ( "approx" <<approx=LL_k;>> 184830fdf1140b8d1ce93f3821d986fa165552023440lgao | "LL\(1\)" <<approx = 1;>> /* MR20 */ 184930fdf1140b8d1ce93f3821d986fa165552023440lgao | "LL\(2\)" <<approx = 2;>> /* MR20 */ 185030fdf1140b8d1ce93f3821d986fa165552023440lgao ) 185130fdf1140b8d1ce93f3821d986fa165552023440lgao } 185230fdf1140b8d1ce93f3821d986fa165552023440lgao 185330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ { FirstSetSymbol 185430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ "\(" 185530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ ( NonTerminal 185630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ << 185730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1, 185830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ sizeof(char)); 185930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ require(pFirstSetSymbol!=NULL, 186030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ "cannot allocate first set name"); 186130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ strcpy(pFirstSetSymbol, LATEXT(1)); 186230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ >> 186330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ | TokenTerm 186430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ << 186530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1, 186630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ sizeof(char)); 186730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ require(pFirstSetSymbol!=NULL, 186830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ "cannot allocate first set name"); 186930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ strcpy(pFirstSetSymbol, LATEXT(1)); 187030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ >> 187130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ ) 187230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ "\)" 187330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR21 */ } 187430fdf1140b8d1ce93f3821d986fa165552023440lgao 187530fdf1140b8d1ce93f3821d986fa165552023440lgao ( 187630fdf1140b8d1ce93f3821d986fa165552023440lgao 187730fdf1140b8d1ce93f3821d986fa165552023440lgao "\(" block[&toksrefd,&rulesrefd] "\)" 187830fdf1140b8d1ce93f3821d986fa165552023440lgao <<blk = $$ = $2; 187930fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR23 */ CurBlockID_array[BlkLevel] = (-1); 188030fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR23 */ CurAltNum_array[BlkLevel] = (-1); 188130fdf1140b8d1ce93f3821d986fa165552023440lgao --BlkLevel; 188230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 188330fdf1140b8d1ce93f3821d986fa165552023440lgao 188430fdf1140b8d1ce93f3821d986fa165552023440lgao ( "\*" <<$$ = makeLoop($$,approx,pFirstSetSymbol);>> 188530fdf1140b8d1ce93f3821d986fa165552023440lgao | "\+" <<$$ = makePlus($$,approx,pFirstSetSymbol);>> 188630fdf1140b8d1ce93f3821d986fa165552023440lgao | "?" 188730fdf1140b8d1ce93f3821d986fa165552023440lgao ( 188830fdf1140b8d1ce93f3821d986fa165552023440lgao ( "=>" <<ampersandStyle=0;>> 188930fdf1140b8d1ce93f3821d986fa165552023440lgao | "&&" <<ampersandStyle=1;>> /* MR10 (g)? && <<p>>? */ 189030fdf1140b8d1ce93f3821d986fa165552023440lgao ) 189130fdf1140b8d1ce93f3821d986fa165552023440lgao Pred /* generalized predicate */ 189230fdf1140b8d1ce93f3821d986fa165552023440lgao /* first make into a predicate */ 189330fdf1140b8d1ce93f3821d986fa165552023440lgao <<$$ = buildAction(LATEXT(1),action_file,action_line,1);>> 189430fdf1140b8d1ce93f3821d986fa165552023440lgao <<act = (ActionNode *) ((Junction *)$$.left)->p1;>> 189530fdf1140b8d1ce93f3821d986fa165552023440lgao <<semDepth=predicateLookaheadDepth(act);>> /* MR10 */ 189630fdf1140b8d1ce93f3821d986fa165552023440lgao <<if (numericActionLabel) { /* MR10 */ 189730fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&NumericPredLabels,act); /* MR10 */ 189830fdf1140b8d1ce93f3821d986fa165552023440lgao numericActionLabel=0; /* MR10 */ 189930fdf1140b8d1ce93f3821d986fa165552023440lgao }; /* MR10 */ 190030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 190130fdf1140b8d1ce93f3821d986fa165552023440lgao { <<char *a;>> 190230fdf1140b8d1ce93f3821d986fa165552023440lgao PassAction 190330fdf1140b8d1ce93f3821d986fa165552023440lgao << 190430fdf1140b8d1ce93f3821d986fa165552023440lgao a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char)); 190530fdf1140b8d1ce93f3821d986fa165552023440lgao require(a!=NULL, "rule element: cannot allocate predicate fail action"); 190630fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(a, LATEXT(1)); 190730fdf1140b8d1ce93f3821d986fa165552023440lgao act->pred_fail = a; 190830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 190930fdf1140b8d1ce93f3821d986fa165552023440lgao } 191030fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ($first_on_line) { /* MR7 */ 191130fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart=(Junction *)$$.left; /* MR7 */ 191230fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 191330fdf1140b8d1ce93f3821d986fa165552023440lgao };>> 191430fdf1140b8d1ce93f3821d986fa165552023440lgao <<$node = (Node *)act;>> 191530fdf1140b8d1ce93f3821d986fa165552023440lgao 191630fdf1140b8d1ce93f3821d986fa165552023440lgao /* for now, just snag context */ 191730fdf1140b8d1ce93f3821d986fa165552023440lgao << 191830fdf1140b8d1ce93f3821d986fa165552023440lgao pred = computePredFromContextGuard(blk,&predMsgDone); /* MR10 */ 191930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( pred==NULL) { /* MR10 */ 192030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !predMsgDone) err("invalid or missing context guard"); /* MR10 */ 192130fdf1140b8d1ce93f3821d986fa165552023440lgao predMsgDone=1; /* MR10 */ 192230fdf1140b8d1ce93f3821d986fa165552023440lgao } else { /* MR10 */ 192330fdf1140b8d1ce93f3821d986fa165552023440lgao act->guardNodes=(Junction *)blk.left; /* MR11 */ 192430fdf1140b8d1ce93f3821d986fa165552023440lgao pred->expr = act->action; 192530fdf1140b8d1ce93f3821d986fa165552023440lgao pred->source = act; 192630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ pred->ampersandStyle = ampersandStyle; /* 0 means (g)? => ... 1 means (g)? && ... */ 192730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ if (pred->tcontext != NULL) { 192830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ height=MR_max_height_of_tree(pred->tcontext); 192930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ equal_height=MR_all_leaves_same_height(pred->tcontext,height); 193030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ if (! equal_height) { 193130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ errFL("in guarded predicates all tokens in the guard must be at the same height", 193230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ FileStr[act->file],act->line); 193330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ }; 193430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR13 */ } 193530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ if (ampersandStyle) { 193630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ act->ampersandPred = pred; 193730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ if (! HoistPredicateContext) { 193830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense", 193930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ FileStr[act->file],act->line); 194030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR11 */ }; 194130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ } else { 194230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ act->guardpred = pred; 194330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ }; 194430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ if (pred->k != semDepth) { 194530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)", 194630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ pred->k,semDepth)); 194730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR10 */ }; 194830fdf1140b8d1ce93f3821d986fa165552023440lgao } 194930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 195030fdf1140b8d1ce93f3821d986fa165552023440lgao | <<$$ = makeBlk($$,approx,pFirstSetSymbol); 195130fdf1140b8d1ce93f3821d986fa165552023440lgao FoundGuessBlk = 1; 195230fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *) ((Junction *)$$.left)->p1)->guess=1; 195330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !$first_on_line ) { 195430fdf1140b8d1ce93f3821d986fa165552023440lgao err("(...)? predicate must be first element of production"); 195530fdf1140b8d1ce93f3821d986fa165552023440lgao } 195630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 195730fdf1140b8d1ce93f3821d986fa165552023440lgao ) 195830fdf1140b8d1ce93f3821d986fa165552023440lgao | <<$$ = makeBlk($$,approx,pFirstSetSymbol);>> 195930fdf1140b8d1ce93f3821d986fa165552023440lgao ) 196030fdf1140b8d1ce93f3821d986fa165552023440lgao << 196130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( pred==NULL && !predMsgDone) { /* MR10 */ 196230fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID; 196330fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd; 196430fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd; 196530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( $first_on_line ) { /* MR7 */ 196630fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *)((Junction *)((Junction *)$$.left)->p1); /* MR7 */ 196730fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 196830fdf1140b8d1ce93f3821d986fa165552023440lgao }; /* MR7 */ 196930fdf1140b8d1ce93f3821d986fa165552023440lgao $node = (Node *) ((Junction *)$$.left)->p1; 197030fdf1140b8d1ce93f3821d986fa165552023440lgao } 197130fdf1140b8d1ce93f3821d986fa165552023440lgao >> 197230fdf1140b8d1ce93f3821d986fa165552023440lgao 197330fdf1140b8d1ce93f3821d986fa165552023440lgao | "\{" block[&toksrefd,&rulesrefd] 197430fdf1140b8d1ce93f3821d986fa165552023440lgao <<$$ = makeOpt($2,approx,pFirstSetSymbol); 197530fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR23 */ CurBlockID_array[BlkLevel] = (-1); 197630fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR23 */ CurAltNum_array[BlkLevel] = (-1); 197730fdf1140b8d1ce93f3821d986fa165552023440lgao --BlkLevel; 197830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 197930fdf1140b8d1ce93f3821d986fa165552023440lgao "\}" 198030fdf1140b8d1ce93f3821d986fa165552023440lgao << 198130fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID; 198230fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd; 198330fdf1140b8d1ce93f3821d986fa165552023440lgao ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd; 198430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 198530fdf1140b8d1ce93f3821d986fa165552023440lgao <<if ( $first_on_line ) { /* MR7 */ 198630fdf1140b8d1ce93f3821d986fa165552023440lgao CurAltStart = (Junction *) ((Junction *)((Junction *)$$.left)->p1); /* MR7 */ 198730fdf1140b8d1ce93f3821d986fa165552023440lgao altAdd(CurAltStart); /* MR7 */ 198830fdf1140b8d1ce93f3821d986fa165552023440lgao }; 198930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 199030fdf1140b8d1ce93f3821d986fa165552023440lgao <<$node = (Node *) ((Junction *)$$.left)->p1;>> 199130fdf1140b8d1ce93f3821d986fa165552023440lgao 199230fdf1140b8d1ce93f3821d986fa165552023440lgao ) 199330fdf1140b8d1ce93f3821d986fa165552023440lgao 199430fdf1140b8d1ce93f3821d986fa165552023440lgao/* Error catching alternatives */ 199530fdf1140b8d1ce93f3821d986fa165552023440lgao | "\*" <<warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;>> 199630fdf1140b8d1ce93f3821d986fa165552023440lgao | "\+" <<warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;>> 199730fdf1140b8d1ce93f3821d986fa165552023440lgao | "\>" <<warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;>> 199830fdf1140b8d1ce93f3821d986fa165552023440lgao | PassAction <<warn("[...] out of context 'rule > [...]'"); 199930fdf1140b8d1ce93f3821d986fa165552023440lgao CannotContinue=TRUE;>> 200030fdf1140b8d1ce93f3821d986fa165552023440lgao ; 200130fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 200230fdf1140b8d1ce93f3821d986fa165552023440lgao 200330fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule default_exception_handler */ 200430fdf1140b8d1ce93f3821d986fa165552023440lgao 200530fdf1140b8d1ce93f3821d986fa165552023440lgaodefault_exception_handler 200630fdf1140b8d1ce93f3821d986fa165552023440lgao : exception_group > [DefaultExGroup] 200730fdf1140b8d1ce93f3821d986fa165552023440lgao ; 200830fdf1140b8d1ce93f3821d986fa165552023440lgao 200930fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule exception_group */ 201030fdf1140b8d1ce93f3821d986fa165552023440lgao 201130fdf1140b8d1ce93f3821d986fa165552023440lgaoexception_group > [ExceptionGroup *eg] 201230fdf1140b8d1ce93f3821d986fa165552023440lgao : <<ExceptionHandler *h; LabelEntry *label=NULL; /* MR6 */ 201330fdf1140b8d1ce93f3821d986fa165552023440lgao FoundException = 1; FoundExceptionGroup = 1;>> /* MR6 */ 201430fdf1140b8d1ce93f3821d986fa165552023440lgao 201530fdf1140b8d1ce93f3821d986fa165552023440lgao "exception" <<$eg = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));>> 201630fdf1140b8d1ce93f3821d986fa165552023440lgao { <<char *p;>> 201730fdf1140b8d1ce93f3821d986fa165552023440lgao PassAction /* did they attach a label? */ 201830fdf1140b8d1ce93f3821d986fa165552023440lgao << 201930fdf1140b8d1ce93f3821d986fa165552023440lgao p = LATEXT(1)+1; 202030fdf1140b8d1ce93f3821d986fa165552023440lgao p[strlen(p)-1] = '\0'; /* kill trailing space */ 202130fdf1140b8d1ce93f3821d986fa165552023440lgao label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1); 202230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( label==NULL ) 202330fdf1140b8d1ce93f3821d986fa165552023440lgao { 202430fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1)); 202530fdf1140b8d1ce93f3821d986fa165552023440lgao } 202630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 202730fdf1140b8d1ce93f3821d986fa165552023440lgao } 202830fdf1140b8d1ce93f3821d986fa165552023440lgao ( exception_handler > [h] 202930fdf1140b8d1ce93f3821d986fa165552023440lgao <<list_add(&($eg->handlers), (void *)h);>> 203030fdf1140b8d1ce93f3821d986fa165552023440lgao )* 203130fdf1140b8d1ce93f3821d986fa165552023440lgao { "default" ":" Action 203230fdf1140b8d1ce93f3821d986fa165552023440lgao <<{ 203330fdf1140b8d1ce93f3821d986fa165552023440lgao ExceptionHandler *eh = (ExceptionHandler *) 203430fdf1140b8d1ce93f3821d986fa165552023440lgao calloc(1, sizeof(ExceptionHandler)); 203530fdf1140b8d1ce93f3821d986fa165552023440lgao char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 203630fdf1140b8d1ce93f3821d986fa165552023440lgao require(eh!=NULL, "exception: cannot allocate handler"); 203730fdf1140b8d1ce93f3821d986fa165552023440lgao require(a!=NULL, "exception: cannot allocate action"); 203830fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(a, LATEXT(1)); 203930fdf1140b8d1ce93f3821d986fa165552023440lgao eh->action = a; 204030fdf1140b8d1ce93f3821d986fa165552023440lgao eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char)); 204130fdf1140b8d1ce93f3821d986fa165552023440lgao require(eh->signalname!=NULL, "exception: cannot allocate sig name"); 204230fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy(eh->signalname, "default"); 204330fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&($eg->handlers), (void *)eh); 204430fdf1140b8d1ce93f3821d986fa165552023440lgao }>> 204530fdf1140b8d1ce93f3821d986fa165552023440lgao } 204630fdf1140b8d1ce93f3821d986fa165552023440lgao 204730fdf1140b8d1ce93f3821d986fa165552023440lgao << 204830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( label!=NULL ) { 204930fdf1140b8d1ce93f3821d986fa165552023440lgao /* Record ex group in sym tab for this label */ 205030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( label->ex_group!=NULL ) { 205130fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("duplicate exception handler for label '%s'",label->str)); 205230fdf1140b8d1ce93f3821d986fa165552023440lgao } else { 205330fdf1140b8d1ce93f3821d986fa165552023440lgao label->ex_group = $eg; 205430fdf1140b8d1ce93f3821d986fa165552023440lgao /* Label the exception group itself */ 205530fdf1140b8d1ce93f3821d986fa165552023440lgao $eg->label = label->str; 205630fdf1140b8d1ce93f3821d986fa165552023440lgao /* Make the labelled element pt to the exception also */ 205730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR6 */ if (label->elem == NULL) { 205830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR6 */ err(eMsg1("reference in exception handler to undefined label '%s'",label->str)); 205930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR6 */ } else { 206030fdf1140b8d1ce93f3821d986fa165552023440lgao switch ( label->elem->ntype ) { 206130fdf1140b8d1ce93f3821d986fa165552023440lgao case nRuleRef : 206230fdf1140b8d1ce93f3821d986fa165552023440lgao { 206330fdf1140b8d1ce93f3821d986fa165552023440lgao RuleRefNode *r = (RuleRefNode *)label->elem; 206430fdf1140b8d1ce93f3821d986fa165552023440lgao r->ex_group = $eg; 206530fdf1140b8d1ce93f3821d986fa165552023440lgao break; 206630fdf1140b8d1ce93f3821d986fa165552023440lgao } 206730fdf1140b8d1ce93f3821d986fa165552023440lgao case nToken : 206830fdf1140b8d1ce93f3821d986fa165552023440lgao { 206930fdf1140b8d1ce93f3821d986fa165552023440lgao TokNode *t = (TokNode *)label->elem; 207030fdf1140b8d1ce93f3821d986fa165552023440lgao t->ex_group = $eg; 207130fdf1140b8d1ce93f3821d986fa165552023440lgao break; 207230fdf1140b8d1ce93f3821d986fa165552023440lgao } 207330fdf1140b8d1ce93f3821d986fa165552023440lgao } /* end switch */ 207430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR6 */ }; /* end test on label->elem */ 207530fdf1140b8d1ce93f3821d986fa165552023440lgao } /* end test on label->ex_group */ 207630fdf1140b8d1ce93f3821d986fa165552023440lgao 207730fdf1140b8d1ce93f3821d986fa165552023440lgao } /* end test on exception label */ 207830fdf1140b8d1ce93f3821d986fa165552023440lgao 207930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ 208030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ if (BlkLevel == 1 && label == NULL) { 208130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ $eg->forRule=1; 208230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ } else if (label == NULL) { 208330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ $eg->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]); 208430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ egAdd($eg); 208530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ } else { 208630fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ $eg->labelEntry=label; 208730fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ }; 208830fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ 208930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ /* You may want to remove this exc from the rule list */ 209030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ /* and handle at the labeled element site. */ 209130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ 209230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ if (label != NULL) { 209330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ $eg = NULL; 209430fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR7 */ }; 209530fdf1140b8d1ce93f3821d986fa165552023440lgao 209630fdf1140b8d1ce93f3821d986fa165552023440lgao >> 209730fdf1140b8d1ce93f3821d986fa165552023440lgao ; 209830fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 209930fdf1140b8d1ce93f3821d986fa165552023440lgao 210030fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule exception_handler */ 210130fdf1140b8d1ce93f3821d986fa165552023440lgao 210230fdf1140b8d1ce93f3821d986fa165552023440lgaoexception_handler > [ExceptionHandler *eh] 210330fdf1140b8d1ce93f3821d986fa165552023440lgao : <<;>> /* MR9 Removed unreferenced variable "a" */ 210430fdf1140b8d1ce93f3821d986fa165552023440lgao "catch" 210530fdf1140b8d1ce93f3821d986fa165552023440lgao << 210630fdf1140b8d1ce93f3821d986fa165552023440lgao $eh = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler)); 210730fdf1140b8d1ce93f3821d986fa165552023440lgao require($eh!=NULL, "exception: cannot allocate handler"); 210830fdf1140b8d1ce93f3821d986fa165552023440lgao >> 210930fdf1140b8d1ce93f3821d986fa165552023440lgao ( NonTerminal 211030fdf1140b8d1ce93f3821d986fa165552023440lgao << 211130fdf1140b8d1ce93f3821d986fa165552023440lgao $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 211230fdf1140b8d1ce93f3821d986fa165552023440lgao require($eh->signalname!=NULL, "exception: cannot allocate sig name"); 211330fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy($eh->signalname, LATEXT(1)); 211430fdf1140b8d1ce93f3821d986fa165552023440lgao >> 211530fdf1140b8d1ce93f3821d986fa165552023440lgao | TokenTerm 211630fdf1140b8d1ce93f3821d986fa165552023440lgao << 211730fdf1140b8d1ce93f3821d986fa165552023440lgao $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 211830fdf1140b8d1ce93f3821d986fa165552023440lgao require($eh->signalname!=NULL, "exception: cannot allocate sig name"); 211930fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy($eh->signalname, LATEXT(1)); 212030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 212130fdf1140b8d1ce93f3821d986fa165552023440lgao ) 212230fdf1140b8d1ce93f3821d986fa165552023440lgao ":" 212330fdf1140b8d1ce93f3821d986fa165552023440lgao { <<$eh->action = NULL;>> 212430fdf1140b8d1ce93f3821d986fa165552023440lgao Action 212530fdf1140b8d1ce93f3821d986fa165552023440lgao << 212630fdf1140b8d1ce93f3821d986fa165552023440lgao $eh->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); 212730fdf1140b8d1ce93f3821d986fa165552023440lgao require($eh->action!=NULL, "exception: cannot allocate action"); 212830fdf1140b8d1ce93f3821d986fa165552023440lgao strcpy($eh->action, LATEXT(1)); 212930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 213030fdf1140b8d1ce93f3821d986fa165552023440lgao } 213130fdf1140b8d1ce93f3821d986fa165552023440lgao ; 213230fdf1140b8d1ce93f3821d986fa165552023440lgao <<CannotContinue=TRUE;>> 213330fdf1140b8d1ce93f3821d986fa165552023440lgao 213430fdf1140b8d1ce93f3821d986fa165552023440lgao#token NonTerminal "[a-z] [A-Za-z0-9_]*" 213530fdf1140b8d1ce93f3821d986fa165552023440lgao << 213630fdf1140b8d1ce93f3821d986fa165552023440lgao while ( zzchar==' ' || zzchar=='\t' ) { 213730fdf1140b8d1ce93f3821d986fa165552023440lgao zzadvance(); 213830fdf1140b8d1ce93f3821d986fa165552023440lgao } 213930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( zzchar == ':' && inAlt ) NLA = LABEL; 214030fdf1140b8d1ce93f3821d986fa165552023440lgao >> 214130fdf1140b8d1ce93f3821d986fa165552023440lgao#token TokenTerm "[A-Z] [A-Za-z0-9_]*" 214230fdf1140b8d1ce93f3821d986fa165552023440lgao << 214330fdf1140b8d1ce93f3821d986fa165552023440lgao while ( zzchar==' ' || zzchar=='\t' ) { 214430fdf1140b8d1ce93f3821d986fa165552023440lgao zzadvance(); 214530fdf1140b8d1ce93f3821d986fa165552023440lgao } 214630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( zzchar == ':' && inAlt ) NLA = LABEL; 214730fdf1140b8d1ce93f3821d986fa165552023440lgao >> 214830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "{\\}#[A-Za-z0-9_]*" <<warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip(); >> 214930fdf1140b8d1ce93f3821d986fa165552023440lgao 215030fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass PARSE_ENUM_FILE 215130fdf1140b8d1ce93f3821d986fa165552023440lgao 215230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "[\t\ ]+" << zzskip(); >> /* Ignore White */ 215330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "\n|\r|\r\n" << zzline++; zzskip(); >> /* Track Line # */ 215430fdf1140b8d1ce93f3821d986fa165552023440lgao#token "//" << zzmode(TOK_DEF_CPP_COMMENTS); zzmore(); >> 215530fdf1140b8d1ce93f3821d986fa165552023440lgao#token "/\*" << zzmode(TOK_DEF_COMMENTS); zzskip(); >> 215630fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#ifdef" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >> 215730fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#if" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >> 215830fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#ifndef" << ; >> 215930fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#else" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >> 216030fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#endif" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >> 216130fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#undef" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >> 216230fdf1140b8d1ce93f3821d986fa165552023440lgao#token "#import" << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >> 216330fdf1140b8d1ce93f3821d986fa165552023440lgao#token "@" << ; >> 216430fdf1140b8d1ce93f3821d986fa165552023440lgao 216530fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule enum_file */ 216630fdf1140b8d1ce93f3821d986fa165552023440lgao 216730fdf1140b8d1ce93f3821d986fa165552023440lgaoenum_file[char *fname] 216830fdf1140b8d1ce93f3821d986fa165552023440lgao : { "#ifndef" ID 216930fdf1140b8d1ce93f3821d986fa165552023440lgao { "#define" ID /* ignore if it smells like a gate */ 217030fdf1140b8d1ce93f3821d986fa165552023440lgao /* First #define after the first #ifndef (if any) is ignored */ 217130fdf1140b8d1ce93f3821d986fa165552023440lgao } 217230fdf1140b8d1ce93f3821d986fa165552023440lgao } 217330fdf1140b8d1ce93f3821d986fa165552023440lgao ( ( enum_def[$fname] )+ 217430fdf1140b8d1ce93f3821d986fa165552023440lgao | defines[$fname] 217530fdf1140b8d1ce93f3821d986fa165552023440lgao ) 217630fdf1140b8d1ce93f3821d986fa165552023440lgao | 217730fdf1140b8d1ce93f3821d986fa165552023440lgao ; 217830fdf1140b8d1ce93f3821d986fa165552023440lgao 217930fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule defines */ 218030fdf1140b8d1ce93f3821d986fa165552023440lgao 218130fdf1140b8d1ce93f3821d986fa165552023440lgaodefines[char *fname] 218230fdf1140b8d1ce93f3821d986fa165552023440lgao : <<int v; int maxt=(-1); char *t;>> /* MR3 */ 218330fdf1140b8d1ce93f3821d986fa165552023440lgao ( 218430fdf1140b8d1ce93f3821d986fa165552023440lgao "#define" ID 218530fdf1140b8d1ce93f3821d986fa165552023440lgao <<t = mystrdup(LATEXT(1));>> 218630fdf1140b8d1ce93f3821d986fa165552023440lgao INT 218730fdf1140b8d1ce93f3821d986fa165552023440lgao << 218830fdf1140b8d1ce93f3821d986fa165552023440lgao v = atoi(LATEXT(1)); 218930fdf1140b8d1ce93f3821d986fa165552023440lgao/* fprintf(stderr, "#token %s=%d\n", t, v);*/ 219030fdf1140b8d1ce93f3821d986fa165552023440lgao 219130fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */ 219230fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */ 219330fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 Don't let #tokdefs be confused by */ 219430fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 DLGminToken and DLGmaxToken */ 219530fdf1140b8d1ce93f3821d986fa165552023440lgao 219630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( ! isDLGmaxToken(t)) { /* MR2 */ 219730fdf1140b8d1ce93f3821d986fa165552023440lgao TokenNum = v; 219830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( v>maxt ) maxt=v; 219930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( t ) == 0 ) { 220030fdf1140b8d1ce93f3821d986fa165552023440lgao addForcedTname( t, v ); 220130fdf1140b8d1ce93f3821d986fa165552023440lgao } else { 220230fdf1140b8d1ce93f3821d986fa165552023440lgao warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline); 220330fdf1140b8d1ce93f3821d986fa165552023440lgao }; 220430fdf1140b8d1ce93f3821d986fa165552023440lgao }; 220530fdf1140b8d1ce93f3821d986fa165552023440lgao >> 220630fdf1140b8d1ce93f3821d986fa165552023440lgao )+ 220730fdf1140b8d1ce93f3821d986fa165552023440lgao <<TokenNum = maxt + 1;>> 220830fdf1140b8d1ce93f3821d986fa165552023440lgao ; 220930fdf1140b8d1ce93f3821d986fa165552023440lgao 221030fdf1140b8d1ce93f3821d986fa165552023440lgao/* rule enum_def */ 221130fdf1140b8d1ce93f3821d986fa165552023440lgao 221230fdf1140b8d1ce93f3821d986fa165552023440lgaoenum_def[char *fname] 221330fdf1140b8d1ce93f3821d986fa165552023440lgao : <<int v= 0; int maxt=(-1); char *t;>> /* MR3 */ 221430fdf1140b8d1ce93f3821d986fa165552023440lgao "enum" ID 221530fdf1140b8d1ce93f3821d986fa165552023440lgao "\{" 221630fdf1140b8d1ce93f3821d986fa165552023440lgao ID 221730fdf1140b8d1ce93f3821d986fa165552023440lgao <<t = mystrdup(LATEXT(1));>> 221830fdf1140b8d1ce93f3821d986fa165552023440lgao ( "=" INT <<v=atoi(LATEXT(1));>> 221930fdf1140b8d1ce93f3821d986fa165552023440lgao | <<v++;>> 222030fdf1140b8d1ce93f3821d986fa165552023440lgao ) 222130fdf1140b8d1ce93f3821d986fa165552023440lgao << 222230fdf1140b8d1ce93f3821d986fa165552023440lgao/* fprintf(stderr, "#token %s=%d\n", t, v);*/ 222330fdf1140b8d1ce93f3821d986fa165552023440lgao TokenNum = v; 222430fdf1140b8d1ce93f3821d986fa165552023440lgao if ( v>maxt ) maxt=v; /* MR3 */ 222530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( t ) == 0 ) addForcedTname( t, v ); 222630fdf1140b8d1ce93f3821d986fa165552023440lgao else { 222730fdf1140b8d1ce93f3821d986fa165552023440lgao warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline); 222830fdf1140b8d1ce93f3821d986fa165552023440lgao } 222930fdf1140b8d1ce93f3821d986fa165552023440lgao >> 223030fdf1140b8d1ce93f3821d986fa165552023440lgao ( "," 223130fdf1140b8d1ce93f3821d986fa165552023440lgao 223230fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */ 223330fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */ 223430fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 Don't let #tokdefs be confused by */ 223530fdf1140b8d1ce93f3821d986fa165552023440lgao /* MR2 DLGminToken and DLGmaxToken */ 223630fdf1140b8d1ce93f3821d986fa165552023440lgao 223730fdf1140b8d1ce93f3821d986fa165552023440lgao { 223830fdf1140b8d1ce93f3821d986fa165552023440lgao <<isDLGmaxToken(LATEXT(1))>>? ID { "=" INT } /* MR2 */ 223930fdf1140b8d1ce93f3821d986fa165552023440lgao | ID /* MR2 */ 224030fdf1140b8d1ce93f3821d986fa165552023440lgao <<t = mystrdup(LATEXT(1));>> 224130fdf1140b8d1ce93f3821d986fa165552023440lgao ( "=" INT <<v=atoi(LATEXT(1));>> 224230fdf1140b8d1ce93f3821d986fa165552023440lgao | <<v++;>> 224330fdf1140b8d1ce93f3821d986fa165552023440lgao ) 224430fdf1140b8d1ce93f3821d986fa165552023440lgao << 224530fdf1140b8d1ce93f3821d986fa165552023440lgao/* fprintf(stderr, "#token %s=%d\n", t, v);*/ 224630fdf1140b8d1ce93f3821d986fa165552023440lgao TokenNum = v; 224730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( v>maxt ) maxt=v; /* MR3 */ 224830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( t ) == 0 ) addForcedTname( t, v ); 224930fdf1140b8d1ce93f3821d986fa165552023440lgao else { 225030fdf1140b8d1ce93f3821d986fa165552023440lgao warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline); 225130fdf1140b8d1ce93f3821d986fa165552023440lgao } 225230fdf1140b8d1ce93f3821d986fa165552023440lgao >> 225330fdf1140b8d1ce93f3821d986fa165552023440lgao } 225430fdf1140b8d1ce93f3821d986fa165552023440lgao )* 225530fdf1140b8d1ce93f3821d986fa165552023440lgao "\}" 225630fdf1140b8d1ce93f3821d986fa165552023440lgao ";" 225730fdf1140b8d1ce93f3821d986fa165552023440lgao <<TokenNum = maxt + 1;>> /* MR3 */ 225830fdf1140b8d1ce93f3821d986fa165552023440lgao ; 225930fdf1140b8d1ce93f3821d986fa165552023440lgao 226030fdf1140b8d1ce93f3821d986fa165552023440lgao#token INT "[0-9]+" 226130fdf1140b8d1ce93f3821d986fa165552023440lgao#token ID "[a-zA-Z_][_a-zA-Z0-9]*" 226230fdf1140b8d1ce93f3821d986fa165552023440lgao 226330fdf1140b8d1ce93f3821d986fa165552023440lgao#lexclass START 226430fdf1140b8d1ce93f3821d986fa165552023440lgao 226530fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR14 Arpad Beszedes 26-May-98 226630fdf1140b8d1ce93f3821d986fa165552023440lgao Add support for #line directives when antlr source is pre-processed 226730fdf1140b8d1ce93f3821d986fa165552023440lgao*/ 226830fdf1140b8d1ce93f3821d986fa165552023440lgao 226930fdf1140b8d1ce93f3821d986fa165552023440lgao#lexaction 227030fdf1140b8d1ce93f3821d986fa165552023440lgao<< 227130fdf1140b8d1ce93f3821d986fa165552023440lgao 227230fdf1140b8d1ce93f3821d986fa165552023440lgaostatic char * 227330fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 227430fdf1140b8d1ce93f3821d986fa165552023440lgaogetFileNameFromTheLineInfo(char *toStr, char *fromStr) 227530fdf1140b8d1ce93f3821d986fa165552023440lgao#else 227630fdf1140b8d1ce93f3821d986fa165552023440lgaogetFileNameFromTheLineInfo(toStr, fromStr) 227730fdf1140b8d1ce93f3821d986fa165552023440lgaochar *toStr, *fromStr; 227830fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 227930fdf1140b8d1ce93f3821d986fa165552023440lgao{ 228030fdf1140b8d1ce93f3821d986fa165552023440lgao int i, j, k; 228130fdf1140b8d1ce93f3821d986fa165552023440lgao 228230fdf1140b8d1ce93f3821d986fa165552023440lgao if (!fromStr || !toStr) return toStr; 228330fdf1140b8d1ce93f3821d986fa165552023440lgao 228430fdf1140b8d1ce93f3821d986fa165552023440lgao /* find the first " */ 228530fdf1140b8d1ce93f3821d986fa165552023440lgao 228630fdf1140b8d1ce93f3821d986fa165552023440lgao for (i=0; 228730fdf1140b8d1ce93f3821d986fa165552023440lgao (i<MaxFileName) && 228830fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[i] != '\n') && 228930fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[i] != '\r') && 229030fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[i] != '\"'); 229130fdf1140b8d1ce93f3821d986fa165552023440lgao i++) /* nothing */ ; 229230fdf1140b8d1ce93f3821d986fa165552023440lgao 229330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( (i == MaxFileName) || 229430fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[i] == '\n') || 229530fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[i] == '\r') ) { 229630fdf1140b8d1ce93f3821d986fa165552023440lgao return toStr; 229730fdf1140b8d1ce93f3821d986fa165552023440lgao } 229830fdf1140b8d1ce93f3821d986fa165552023440lgao 229930fdf1140b8d1ce93f3821d986fa165552023440lgao /* find the second " */ 230030fdf1140b8d1ce93f3821d986fa165552023440lgao 230130fdf1140b8d1ce93f3821d986fa165552023440lgao for (j=i+1; 230230fdf1140b8d1ce93f3821d986fa165552023440lgao (j<MaxFileName) && 230330fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[j] != '\n') && 230430fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[j] != '\r') && 230530fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[j] != '\"'); 230630fdf1140b8d1ce93f3821d986fa165552023440lgao j++) /* nothing */ ; 230730fdf1140b8d1ce93f3821d986fa165552023440lgao 230830fdf1140b8d1ce93f3821d986fa165552023440lgao if ((j == MaxFileName) || 230930fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[j] == '\n') || 231030fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[j] == '\r') ) { 231130fdf1140b8d1ce93f3821d986fa165552023440lgao return toStr; 231230fdf1140b8d1ce93f3821d986fa165552023440lgao } 231330fdf1140b8d1ce93f3821d986fa165552023440lgao 231430fdf1140b8d1ce93f3821d986fa165552023440lgao /* go back until the last / or \ */ 231530fdf1140b8d1ce93f3821d986fa165552023440lgao 231630fdf1140b8d1ce93f3821d986fa165552023440lgao for (k=j-1; 231730fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[k] != '\"') && 231830fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[k] != '/') && 231930fdf1140b8d1ce93f3821d986fa165552023440lgao (fromStr[k] != '\\'); 232030fdf1140b8d1ce93f3821d986fa165552023440lgao k--) /* nothing */ ; 232130fdf1140b8d1ce93f3821d986fa165552023440lgao 232230fdf1140b8d1ce93f3821d986fa165552023440lgao /* copy the string after " / or \ into toStr */ 232330fdf1140b8d1ce93f3821d986fa165552023440lgao 232430fdf1140b8d1ce93f3821d986fa165552023440lgao for (i=k+1; fromStr[i] != '\"'; i++) { 232530fdf1140b8d1ce93f3821d986fa165552023440lgao toStr[i-k-1] = fromStr[i]; 232630fdf1140b8d1ce93f3821d986fa165552023440lgao } 232730fdf1140b8d1ce93f3821d986fa165552023440lgao 232830fdf1140b8d1ce93f3821d986fa165552023440lgao toStr[i-k-1] = '\0'; 232930fdf1140b8d1ce93f3821d986fa165552023440lgao 233030fdf1140b8d1ce93f3821d986fa165552023440lgao return toStr; 233130fdf1140b8d1ce93f3821d986fa165552023440lgao} 233230fdf1140b8d1ce93f3821d986fa165552023440lgao 233330fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR14 end of a block to support #line in antlr source code */ 233430fdf1140b8d1ce93f3821d986fa165552023440lgao 233530fdf1140b8d1ce93f3821d986fa165552023440lgao>> 233630fdf1140b8d1ce93f3821d986fa165552023440lgao 233730fdf1140b8d1ce93f3821d986fa165552023440lgao<< 233830fdf1140b8d1ce93f3821d986fa165552023440lgao 233930fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */ 234030fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs */ 234130fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR2 Don't let #tokdefs be confused by */ 234230fdf1140b8d1ce93f3821d986fa165552023440lgao/* MR2 DLGminToken and DLGmaxToken */ 234330fdf1140b8d1ce93f3821d986fa165552023440lgao 234430fdf1140b8d1ce93f3821d986fa165552023440lgao/* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */ 234530fdf1140b8d1ce93f3821d986fa165552023440lgao 234630fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 234730fdf1140b8d1ce93f3821d986fa165552023440lgaostatic int isDLGmaxToken(char *Token) 234830fdf1140b8d1ce93f3821d986fa165552023440lgao#else 234930fdf1140b8d1ce93f3821d986fa165552023440lgaostatic int isDLGmaxToken(Token) 235030fdf1140b8d1ce93f3821d986fa165552023440lgao char * Token; 235130fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 235230fdf1140b8d1ce93f3821d986fa165552023440lgao{ 235330fdf1140b8d1ce93f3821d986fa165552023440lgao static char checkStr1[] = "DLGmaxToken"; 235430fdf1140b8d1ce93f3821d986fa165552023440lgao static char checkStr2[] = "DLGminToken"; 235530fdf1140b8d1ce93f3821d986fa165552023440lgao 235630fdf1140b8d1ce93f3821d986fa165552023440lgao if (strcmp(Token, checkStr1) == 0) 235730fdf1140b8d1ce93f3821d986fa165552023440lgao return 1; 235830fdf1140b8d1ce93f3821d986fa165552023440lgao else if (strcmp(Token, checkStr2) == 0) 235930fdf1140b8d1ce93f3821d986fa165552023440lgao return 1; 236030fdf1140b8d1ce93f3821d986fa165552023440lgao else 236130fdf1140b8d1ce93f3821d986fa165552023440lgao return 0; 236230fdf1140b8d1ce93f3821d986fa165552023440lgao} 236330fdf1140b8d1ce93f3821d986fa165552023440lgao 236430fdf1140b8d1ce93f3821d986fa165552023440lgao/* semantics of #token */ 236530fdf1140b8d1ce93f3821d986fa165552023440lgaostatic void 236630fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 236730fdf1140b8d1ce93f3821d986fa165552023440lgaochkToken(char *t, char *e, char *a, int tnum) 236830fdf1140b8d1ce93f3821d986fa165552023440lgao#else 236930fdf1140b8d1ce93f3821d986fa165552023440lgaochkToken(t,e,a,tnum) 237030fdf1140b8d1ce93f3821d986fa165552023440lgaochar *t, *e, *a; 237130fdf1140b8d1ce93f3821d986fa165552023440lgaoint tnum; 237230fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 237330fdf1140b8d1ce93f3821d986fa165552023440lgao{ 237430fdf1140b8d1ce93f3821d986fa165552023440lgao TermEntry *p; 237530fdf1140b8d1ce93f3821d986fa165552023440lgao 237630fdf1140b8d1ce93f3821d986fa165552023440lgao /* check to see that they don't try to redefine a token as a token class */ 237730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( t!=NULL ) { 237830fdf1140b8d1ce93f3821d986fa165552023440lgao p = (TermEntry *) hash_get(Tname, t); 237930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( p!=NULL && p->classname ) { 238030fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t)); 238130fdf1140b8d1ce93f3821d986fa165552023440lgao if ( a!=NULL ) free((char *)a); 238230fdf1140b8d1ce93f3821d986fa165552023440lgao return; 238330fdf1140b8d1ce93f3821d986fa165552023440lgao } 238430fdf1140b8d1ce93f3821d986fa165552023440lgao } 238530fdf1140b8d1ce93f3821d986fa165552023440lgao 238630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( t==NULL && e==NULL ) { /* none found */ 238730fdf1140b8d1ce93f3821d986fa165552023440lgao err("#token requires at least token name or rexpr"); 238830fdf1140b8d1ce93f3821d986fa165552023440lgao } 238930fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( t!=NULL && e!=NULL ) { /* both found */ 239030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( UserDefdTokens ) { /* if #tokdefs, must not define new */ 239130fdf1140b8d1ce93f3821d986fa165552023440lgao p = (TermEntry *) hash_get(Tname, t); 239230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( p == NULL) { 239330fdf1140b8d1ce93f3821d986fa165552023440lgaoerr(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t)); 239430fdf1140b8d1ce93f3821d986fa165552023440lgao return; 239530fdf1140b8d1ce93f3821d986fa165552023440lgao }; 239630fdf1140b8d1ce93f3821d986fa165552023440lgao } 239730fdf1140b8d1ce93f3821d986fa165552023440lgao Tklink(t, e); 239830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( a!=NULL ) { 239930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( hasAction(e) ) { 240030fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("redefinition of action for %s; ignored",e)); 240130fdf1140b8d1ce93f3821d986fa165552023440lgao } 240230fdf1140b8d1ce93f3821d986fa165552023440lgao else setHasAction(e, a); 240330fdf1140b8d1ce93f3821d986fa165552023440lgao } 240430fdf1140b8d1ce93f3821d986fa165552023440lgao } 240530fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( t!=NULL ) { /* only one found */ 240630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( UserDefdTokens ) { 240730fdf1140b8d1ce93f3821d986fa165552023440lgao p = (TermEntry *) hash_get(Tname, t); 240830fdf1140b8d1ce93f3821d986fa165552023440lgao if (p == NULL) { 240930fdf1140b8d1ce93f3821d986fa165552023440lgaoerr(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t)); 241030fdf1140b8d1ce93f3821d986fa165552023440lgao }; 241130fdf1140b8d1ce93f3821d986fa165552023440lgao return; 241230fdf1140b8d1ce93f3821d986fa165552023440lgao } 241330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( t ) == 0 ) addTname( t ); 241430fdf1140b8d1ce93f3821d986fa165552023440lgao else { 241530fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("redefinition of token %s; ignored",t)); 241630fdf1140b8d1ce93f3821d986fa165552023440lgao } 241730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( a!=NULL ) { 241830fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("action cannot be attached to a token name (%s); ignored",t)); 241930fdf1140b8d1ce93f3821d986fa165552023440lgao free((char *)a); 242030fdf1140b8d1ce93f3821d986fa165552023440lgao } 242130fdf1140b8d1ce93f3821d986fa165552023440lgao } 242230fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( e!=NULL ) { 242330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( Tnum( e ) == 0 ) addTexpr( e ); 242430fdf1140b8d1ce93f3821d986fa165552023440lgao else { 242530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( hasAction(e) ) { 242630fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("redefinition of action for expr %s; ignored",e)); 242730fdf1140b8d1ce93f3821d986fa165552023440lgao } 242830fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( a==NULL ) { 242930fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsg1("redefinition of expr %s; ignored",e)); 243030fdf1140b8d1ce93f3821d986fa165552023440lgao } 243130fdf1140b8d1ce93f3821d986fa165552023440lgao } 243230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( a!=NULL ) setHasAction(e, a); 243330fdf1140b8d1ce93f3821d986fa165552023440lgao } 243430fdf1140b8d1ce93f3821d986fa165552023440lgao 243530fdf1140b8d1ce93f3821d986fa165552023440lgao /* if a token type number was specified, then add the token ID and 'tnum' 243630fdf1140b8d1ce93f3821d986fa165552023440lgao * pair to the ForcedTokens list. (only applies if an id was given) 243730fdf1140b8d1ce93f3821d986fa165552023440lgao */ 243830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( t!=NULL && tnum>0 ) 243930fdf1140b8d1ce93f3821d986fa165552023440lgao { 244030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( set_el(tnum, reserved_positions) ) 244130fdf1140b8d1ce93f3821d986fa165552023440lgao { 244230fdf1140b8d1ce93f3821d986fa165552023440lgao err(eMsgd("a token has already been forced to token number %d; ignored", tnum)); 244330fdf1140b8d1ce93f3821d986fa165552023440lgao } 244430fdf1140b8d1ce93f3821d986fa165552023440lgao else 244530fdf1140b8d1ce93f3821d986fa165552023440lgao { 244630fdf1140b8d1ce93f3821d986fa165552023440lgao list_add(&ForcedTokens, newForcedToken(t,tnum)); 244730fdf1140b8d1ce93f3821d986fa165552023440lgao set_orel(tnum, &reserved_positions); 244830fdf1140b8d1ce93f3821d986fa165552023440lgao } 244930fdf1140b8d1ce93f3821d986fa165552023440lgao } 245030fdf1140b8d1ce93f3821d986fa165552023440lgao} 245130fdf1140b8d1ce93f3821d986fa165552023440lgao>> 245230fdf1140b8d1ce93f3821d986fa165552023440lgao 245330fdf1140b8d1ce93f3821d986fa165552023440lgao<< 245430fdf1140b8d1ce93f3821d986fa165552023440lgaostatic int 245530fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 245630fdf1140b8d1ce93f3821d986fa165552023440lgaomatch_token(char *s, char **nxt) 245730fdf1140b8d1ce93f3821d986fa165552023440lgao#else 245830fdf1140b8d1ce93f3821d986fa165552023440lgaomatch_token(s,nxt) 245930fdf1140b8d1ce93f3821d986fa165552023440lgaochar *s; 246030fdf1140b8d1ce93f3821d986fa165552023440lgaochar **nxt; 246130fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 246230fdf1140b8d1ce93f3821d986fa165552023440lgao{ 246330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !(*s>='A' && *s<='Z') ) return 0; 246430fdf1140b8d1ce93f3821d986fa165552023440lgao s++; 246530fdf1140b8d1ce93f3821d986fa165552023440lgao while ( (*s>='a' && *s<='z') || 246630fdf1140b8d1ce93f3821d986fa165552023440lgao (*s>='A' && *s<='Z') || 246730fdf1140b8d1ce93f3821d986fa165552023440lgao (*s>='0' && *s<='9') || 246830fdf1140b8d1ce93f3821d986fa165552023440lgao *s=='_' ) 246930fdf1140b8d1ce93f3821d986fa165552023440lgao { 247030fdf1140b8d1ce93f3821d986fa165552023440lgao s++; 247130fdf1140b8d1ce93f3821d986fa165552023440lgao } 247230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( *s!=' ' && *s!='}' ) return 0; 247330fdf1140b8d1ce93f3821d986fa165552023440lgao *nxt = s; 247430fdf1140b8d1ce93f3821d986fa165552023440lgao return 1; 247530fdf1140b8d1ce93f3821d986fa165552023440lgao} 247630fdf1140b8d1ce93f3821d986fa165552023440lgao 247730fdf1140b8d1ce93f3821d986fa165552023440lgaostatic int 247830fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 247930fdf1140b8d1ce93f3821d986fa165552023440lgaomatch_rexpr(char *s, char **nxt) 248030fdf1140b8d1ce93f3821d986fa165552023440lgao#else 248130fdf1140b8d1ce93f3821d986fa165552023440lgaomatch_rexpr(s,nxt) 248230fdf1140b8d1ce93f3821d986fa165552023440lgaochar *s; 248330fdf1140b8d1ce93f3821d986fa165552023440lgaochar **nxt; 248430fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 248530fdf1140b8d1ce93f3821d986fa165552023440lgao{ 248630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( *s!='"' ) return 0; 248730fdf1140b8d1ce93f3821d986fa165552023440lgao s++; 248830fdf1140b8d1ce93f3821d986fa165552023440lgao while ( *s!='"' ) 248930fdf1140b8d1ce93f3821d986fa165552023440lgao { 249030fdf1140b8d1ce93f3821d986fa165552023440lgao if ( *s=='\n' || *s=='\r' ) /* MR13 */ 249130fdf1140b8d1ce93f3821d986fa165552023440lgao warn("eoln found in regular expression"); 249230fdf1140b8d1ce93f3821d986fa165552023440lgao if ( *s=='\\' ) s++; 249330fdf1140b8d1ce93f3821d986fa165552023440lgao s++; 249430fdf1140b8d1ce93f3821d986fa165552023440lgao } 249530fdf1140b8d1ce93f3821d986fa165552023440lgao *nxt = s+1; 249630fdf1140b8d1ce93f3821d986fa165552023440lgao return 1; 249730fdf1140b8d1ce93f3821d986fa165552023440lgao} 249830fdf1140b8d1ce93f3821d986fa165552023440lgao 249930fdf1140b8d1ce93f3821d986fa165552023440lgao/* 250030fdf1140b8d1ce93f3821d986fa165552023440lgao * Walk a string "{ A .. Z }" where A..Z is a space separated list 250130fdf1140b8d1ce93f3821d986fa165552023440lgao * of token references (either labels or reg exprs). Return a 250230fdf1140b8d1ce93f3821d986fa165552023440lgao * string "inlineX_set" for some unique integer X. Basically, 250330fdf1140b8d1ce93f3821d986fa165552023440lgao * we pretend as if we had seen "#tokclass inlineX { A .. Z }" 250430fdf1140b8d1ce93f3821d986fa165552023440lgao * on the input stream outside of an action. 250530fdf1140b8d1ce93f3821d986fa165552023440lgao */ 250630fdf1140b8d1ce93f3821d986fa165552023440lgaochar * 250730fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 250830fdf1140b8d1ce93f3821d986fa165552023440lgaoinline_set(char *s) 250930fdf1140b8d1ce93f3821d986fa165552023440lgao#else 251030fdf1140b8d1ce93f3821d986fa165552023440lgaoinline_set(s) 251130fdf1140b8d1ce93f3821d986fa165552023440lgaochar *s; 251230fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 251330fdf1140b8d1ce93f3821d986fa165552023440lgao{ 251430fdf1140b8d1ce93f3821d986fa165552023440lgao char *nxt; 251530fdf1140b8d1ce93f3821d986fa165552023440lgao fprintf(stderr, "found consumeUntil( {...} )\n"); 251630fdf1140b8d1ce93f3821d986fa165552023440lgao while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;} 251730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( *s!='{' ) 251830fdf1140b8d1ce93f3821d986fa165552023440lgao { 251930fdf1140b8d1ce93f3821d986fa165552023440lgao err("malformed consumeUntil( {...} ); missing '{'"); 252030fdf1140b8d1ce93f3821d986fa165552023440lgao return "bad_set"; 252130fdf1140b8d1ce93f3821d986fa165552023440lgao } 252230fdf1140b8d1ce93f3821d986fa165552023440lgao s++; 252330fdf1140b8d1ce93f3821d986fa165552023440lgao while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;} 252430fdf1140b8d1ce93f3821d986fa165552023440lgao while ( *s!='}' ) 252530fdf1140b8d1ce93f3821d986fa165552023440lgao { 252630fdf1140b8d1ce93f3821d986fa165552023440lgao if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s); 252730fdf1140b8d1ce93f3821d986fa165552023440lgao else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s); 252830fdf1140b8d1ce93f3821d986fa165552023440lgao else { 252930fdf1140b8d1ce93f3821d986fa165552023440lgao err("invalid element in consumeUntil( {...} )"); 253030fdf1140b8d1ce93f3821d986fa165552023440lgao return "bad_set"; 253130fdf1140b8d1ce93f3821d986fa165552023440lgao } 253230fdf1140b8d1ce93f3821d986fa165552023440lgao s = nxt; 253330fdf1140b8d1ce93f3821d986fa165552023440lgao while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;} 253430fdf1140b8d1ce93f3821d986fa165552023440lgao } 253530fdf1140b8d1ce93f3821d986fa165552023440lgao return "inlineX_set"; 253630fdf1140b8d1ce93f3821d986fa165552023440lgao} 253730fdf1140b8d1ce93f3821d986fa165552023440lgao>> 253830fdf1140b8d1ce93f3821d986fa165552023440lgao 253930fdf1140b8d1ce93f3821d986fa165552023440lgao<< 254030fdf1140b8d1ce93f3821d986fa165552023440lgao/* ANTLR-specific syntax error message generator 254130fdf1140b8d1ce93f3821d986fa165552023440lgao * (define USER_ZZSYN when compiling so don't get 2 definitions) 254230fdf1140b8d1ce93f3821d986fa165552023440lgao */ 254330fdf1140b8d1ce93f3821d986fa165552023440lgaovoid 254430fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 254530fdf1140b8d1ce93f3821d986fa165552023440lgaozzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, 254630fdf1140b8d1ce93f3821d986fa165552023440lgaoint k, char *bad_text) 254730fdf1140b8d1ce93f3821d986fa165552023440lgao#else 254830fdf1140b8d1ce93f3821d986fa165552023440lgaozzsyn(text, tok, egroup, eset, etok, k, bad_text) 254930fdf1140b8d1ce93f3821d986fa165552023440lgaochar *text, *egroup, *bad_text; 255030fdf1140b8d1ce93f3821d986fa165552023440lgaoint tok; 255130fdf1140b8d1ce93f3821d986fa165552023440lgaoint etok; 255230fdf1140b8d1ce93f3821d986fa165552023440lgaoint k; 255330fdf1140b8d1ce93f3821d986fa165552023440lgaoSetWordType *eset; 255430fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 255530fdf1140b8d1ce93f3821d986fa165552023440lgao{ 255630fdf1140b8d1ce93f3821d986fa165552023440lgao fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline); 255730fdf1140b8d1ce93f3821d986fa165552023440lgao fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text); 255830fdf1140b8d1ce93f3821d986fa165552023440lgao if ( !etok && !eset ) {fprintf(stderr, "\n"); return;} 255930fdf1140b8d1ce93f3821d986fa165552023440lgao if ( k==1 ) fprintf(stderr, " missing"); 256030fdf1140b8d1ce93f3821d986fa165552023440lgao else 256130fdf1140b8d1ce93f3821d986fa165552023440lgao { 256230fdf1140b8d1ce93f3821d986fa165552023440lgao fprintf(stderr, "; \"%s\" not", bad_text); 256330fdf1140b8d1ce93f3821d986fa165552023440lgao if ( zzset_deg(eset)>1 ) fprintf(stderr, " in"); 256430fdf1140b8d1ce93f3821d986fa165552023440lgao } 256530fdf1140b8d1ce93f3821d986fa165552023440lgao if ( zzset_deg(eset)>0 ) zzedecode(eset); 256630fdf1140b8d1ce93f3821d986fa165552023440lgao else fprintf(stderr, " %s", zztokens[etok]); 256730fdf1140b8d1ce93f3821d986fa165552023440lgao if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup); 256830fdf1140b8d1ce93f3821d986fa165552023440lgao fprintf(stderr, "\n"); 256930fdf1140b8d1ce93f3821d986fa165552023440lgao} 257030fdf1140b8d1ce93f3821d986fa165552023440lgao>> 257130fdf1140b8d1ce93f3821d986fa165552023440lgao 257230fdf1140b8d1ce93f3821d986fa165552023440lgao#lexaction << 257330fdf1140b8d1ce93f3821d986fa165552023440lgao#ifdef __USE_PROTOS 257430fdf1140b8d1ce93f3821d986fa165552023440lgaovoid mark_label_used_in_sem_pred(LabelEntry *le) /* MR10 */ 257530fdf1140b8d1ce93f3821d986fa165552023440lgao#else 257630fdf1140b8d1ce93f3821d986fa165552023440lgaovoid mark_label_used_in_sem_pred(le) /* MR10 */ 257730fdf1140b8d1ce93f3821d986fa165552023440lgao LabelEntry *le; 257830fdf1140b8d1ce93f3821d986fa165552023440lgao#endif 257930fdf1140b8d1ce93f3821d986fa165552023440lgao{ 258030fdf1140b8d1ce93f3821d986fa165552023440lgao TokNode *tn; 258130fdf1140b8d1ce93f3821d986fa165552023440lgao require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken"); 258230fdf1140b8d1ce93f3821d986fa165552023440lgao tn=(TokNode *)le->elem; 258330fdf1140b8d1ce93f3821d986fa165552023440lgao require (tn->label != 0,"mark_label_used... TokNode has no label"); 258430fdf1140b8d1ce93f3821d986fa165552023440lgao tn->label_used_in_semantic_pred=1; 258530fdf1140b8d1ce93f3821d986fa165552023440lgao} 258630fdf1140b8d1ce93f3821d986fa165552023440lgao>> 2587