X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=ragel%2Frlparse.kh;h=899bbbcee229a0ebbbb1bf48df1312baa2295b8c;hb=refs%2Fheads%2Fmaster;hp=78559267a669f90dd7b44a99df365dcb975ce1b6;hpb=a76b1ca9ae9d7a0adebbc762ef3e3b171a77a44b;p=external%2Fragel.git diff --git a/ragel/rlparse.kh b/ragel/rlparse.kh index 7855926..899bbbc 100644 --- a/ragel/rlparse.kh +++ b/ragel/rlparse.kh @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Adrian Thurston + * Copyright 2001-2007 Adrian Thurston */ /* This file is part of Ragel. @@ -19,8 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef RLPARSE_H -#define RLPARSE_H +#ifndef _RLPARSE_H +#define _RLPARSE_H #include #include "avltree.h" @@ -33,6 +33,17 @@ #define IMP_UInt 130 #define IMP_Define 131 +/* This is used for tracking the include files/machine pairs. */ +struct IncludeHistoryItem +{ + IncludeHistoryItem( const char *fileName, const char *sectionName ) + : fileName(fileName), sectionName(sectionName) {} + + const char *fileName; + const char *sectionName; +}; + +typedef Vector IncludeHistory; struct Parser { @@ -40,14 +51,15 @@ struct Parser parser Parser; # General tokens. - token TK_Word, TK_Literal, TK_Number, TK_Reference, TK_ColonEquals, - TK_EndSection, TK_UInt, TK_Hex, TK_Word, TK_Literal, TK_DotDot, - TK_ColonGt, TK_ColonGtGt, TK_LtColon, TK_Arrow, TK_DoubleArrow, - TK_StarStar, TK_ColonEquals, TK_NameSep, TK_BarStar, TK_DashDash; + token TK_Word, TK_Literal, TK_Number, TK_EndSection, TK_UInt, TK_Hex, + TK_Word, TK_Literal, TK_DotDot, TK_ColonGt, TK_ColonGtGt, TK_LtColon, + TK_Arrow, TK_DoubleArrow, TK_StarStar, TK_ColonEquals, TK_NameSep, + TK_BarStar, TK_DashDash; # Conditions. token TK_StartCond, TK_AllCond, TK_LeavingCond; + # State embedding actions. token TK_Middle; # Global error actions. @@ -79,18 +91,14 @@ struct Parser # Keywords. token KW_Machine, KW_Include, KW_Import, KW_Write, KW_Action, KW_AlphType, - KW_Range, KW_GetKey, KW_Include, KW_Write, KW_Machine, KW_When, KW_Eof, - KW_Err, KW_Lerr, KW_To, KW_From, KW_Export; + KW_Range, KW_GetKey, KW_Include, KW_Write, KW_Machine, KW_InWhen, + KW_When, KW_OutWhen, KW_Eof, KW_Err, KW_Lerr, KW_To, KW_From, + KW_Export, KW_PrePush, KW_PostPop, KW_Length; # Specials in code blocks. token KW_Break, KW_Exec, KW_Hold, KW_PChar, KW_Char, KW_Goto, KW_Call, KW_Ret, KW_CurState, KW_TargState, KW_Entry, KW_Next, KW_Exec, KW_Variable, KW_Access; - - # Special token for terminating semi-terminated code blocks. Needed because - # semi is sent as a token in the code block rather than as a generic - # symbol. - token TK_Semi; }%% %% write instance_data; @@ -98,16 +106,18 @@ struct Parser void init(); int parseLangEl( int type, const Token *token ); - Parser( char *fileName, char *sectionName, InputLoc §ionLoc ) + Parser( const char *fileName, char *sectionName, InputLoc §ionLoc ) : sectionName(sectionName) { pd = new ParseData( fileName, sectionName, sectionLoc ); exportContext.append( false ); + includeHistory.append( IncludeHistoryItem( + fileName, sectionName ) ); } int token( InputLoc &loc, int tokId, char *tokstart, int toklen ); void tryMachineDef( InputLoc &loc, char *name, - JoinOrLm *joinOrLm, bool isInstance ); + MachineDef *machineDef, bool isInstance ); /* Report an error encountered by the parser. */ ostream &parse_error( int tokId, Token &token ); @@ -121,6 +131,9 @@ struct Parser NameRefList nameRefList; Vector exportContext; + IncludeHistory includeHistory; + + Parser *prev, *next; }; %% write token_defs;