2 * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
5 /* This file is part of Ragel.
7 * Ragel is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Ragel is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Ragel; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "parsedata.h"
30 /* Import scanner tokens. */
32 #define IMP_Literal 129
34 #define IMP_Define 131
43 token TK_Word, TK_Literal, TK_Number, TK_Reference, TK_ColonEquals,
44 TK_EndSection, TK_UInt, TK_Hex, TK_Word, TK_Literal, TK_DotDot,
45 TK_ColonGt, TK_ColonGtGt, TK_LtColon, TK_Arrow, TK_DoubleArrow,
46 TK_StarStar, TK_ColonEquals, TK_NameSep, TK_BarStar, TK_DashDash;
49 token TK_StartCond, TK_AllCond, TK_LeavingCond;
53 # Global error actions.
54 token TK_StartGblError, TK_AllGblError, TK_FinalGblError,
55 TK_NotFinalGblError, TK_NotStartGblError, TK_MiddleGblError;
57 # Local error actions.
58 token TK_StartLocalError, TK_AllLocalError, TK_FinalLocalError,
59 TK_NotFinalLocalError, TK_NotStartLocalError, TK_MiddleLocalError;
61 # EOF Action embedding.
62 token TK_StartEOF, TK_AllEOF, TK_FinalEOF, TK_NotFinalEOF, TK_NotStartEOF,
66 token TK_StartToState, TK_AllToState, TK_FinalToState, TK_NotFinalToState,
67 TK_NotStartToState, TK_MiddleToState;
70 token TK_StartFromState, TK_AllFromState, TK_FinalFromState,
71 TK_NotFinalFromState, TK_NotStartFromState, TK_MiddleFromState;
73 # Regular expression tokens. */
74 token RE_Slash, RE_SqOpen, RE_SqOpenNeg, RE_SqClose, RE_Dot, RE_Star,
77 # Tokens specific to inline code.
78 token IL_WhiteSpace, IL_Comment, IL_Literal, IL_Symbol;
81 token KW_Machine, KW_Include, KW_Import, KW_Write, KW_Action, KW_AlphType,
82 KW_Range, KW_GetKey, KW_Include, KW_Write, KW_Machine, KW_When, KW_Eof,
83 KW_Err, KW_Lerr, KW_To, KW_From, KW_Export;
85 # Specials in code blocks.
86 token KW_Break, KW_Exec, KW_Hold, KW_PChar, KW_Char, KW_Goto, KW_Call,
87 KW_Ret, KW_CurState, KW_TargState, KW_Entry, KW_Next, KW_Exec,
88 KW_Variable, KW_Access;
90 # Special token for terminating semi-terminated code blocks. Needed because
91 # semi is sent as a token in the code block rather than as a generic
96 %% write instance_data;
99 int parseLangEl( int type, const Token *token );
101 Parser( char *fileName, char *sectionName, InputLoc §ionLoc )
102 : sectionName(sectionName)
104 pd = new ParseData( fileName, sectionName, sectionLoc );
105 exportContext.append( false );
108 int token( InputLoc &loc, int tokId, char *tokstart, int toklen );
109 void tryMachineDef( InputLoc &loc, char *name,
110 JoinOrLm *joinOrLm, bool isInstance );
112 /* Report an error encountered by the parser. */
113 ostream &parse_error( int tokId, Token &token );
117 /* The name of the root section, this does not change during an include. */
121 NameRefList nameRefList;
123 Vector<bool> exportContext;