/* * Copyright 2001-2007, 2013 Adrian Thurston * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef LMPARSE_H #define LMPARSE_H #include #include "avltree.h" #include "parsedata.h" #include "parser.h" struct ColmParser : public BaseParser { ColmParser( Compiler *pd ) : BaseParser( pd ) {} %%{ parser ColmParser; # Use a class for tokens. token uses class Token; # Atoms. token TK_Word, TK_Literal, TK_SingleLit, TK_DoubleLit, TK_Number, TK_UInt, TK_Hex, KW_Nil, KW_True, KW_False; # General tokens. token TK_DotDot, TK_ColonGt, TK_ColonGtGt, TK_LtColon, TK_DoubleArrow, TK_StarStar, TK_NameSep, TK_DashDash, TK_DoubleEql, TK_NotEql, TK_DoubleColon, TK_LessEql, TK_GrtrEql, TK_RightArrow, TK_LitPat, TK_AmpAmp, TK_BarBar, TK_SqOpen, TK_SqOpenNeg, TK_SqClose, TK_Dash, TK_ReChar, TK_LtLt; # Defining things. token KW_Rl, KW_Def, KW_Lex, KW_Context, KW_Ignore, KW_Token, KW_Commit, KW_Namespace, KW_End, KW_Literal, KW_ReduceFirst, KW_Map, KW_List, KW_Vector, KW_Parser, KW_Global, KW_Export, KW_Iter, KW_Reject, KW_Ptr, KW_Ref, KW_Deref; # Language. token KW_If, KW_While, KW_Else, KW_Elsif, KW_For, KW_Return, KW_Yield, KW_In, KW_Break, KW_PrintXMLAC, KW_PrintXML, KW_Print, KW_PrintStream, KW_Require; # Patterns. token KW_Match, KW_Construct, KW_Parse, KW_ParseStop, KW_New, KW_MakeToken, KW_MakeTree, KW_TypeId, KW_Alias, KW_Send, KW_Ni; token KW_Include, KW_Preeof; token KW_Left, KW_Right, KW_Nonassoc, KW_Prec; }%% %% write instance_data; /* Report an error encountered by the parser. */ ostream &parse_error( int tokId, Token &token ); void init(); int parseLangEl( int type, const Token *token ); int token( InputLoc &loc, int tokId, char *tokstart, int toklen ); }; %% write token_defs; #endif