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
44 typedef Vector<AttrMarker> AttrMkList;
45 typedef Vector<Attribute> AttrList;
46 struct XMLTagHashPair;
50 enum TagType { Open, Close };
52 XMLTag( XMLTagHashPair *tagId, TagType type ) :
53 tagId(tagId), type(type),
54 content(0), attrList(0) {}
56 Attribute *findAttr( const char *id )
58 if ( attrList != 0 ) {
59 for ( AttrList::Iter attr = *attrList; attr.lte(); attr++ ) {
60 if ( strcmp( id, attr->id ) == 0 )
67 XMLTagHashPair *tagId;
70 /* Content is associtated with closing tags. */
73 /* Attribute lists are associated with opening tags. */
94 struct LmSwitchAction;
101 token TAG_unknown, TAG_ragel, TAG_ragel_def, TAG_host, TAG_state_list,
102 TAG_state, TAG_trans_list, TAG_t, TAG_machine, TAG_start_state,
103 TAG_error_state, TAG_action_list, TAG_action_table_list,
104 TAG_action, TAG_action_table, TAG_alphtype, TAG_element,
105 TAG_getkey, TAG_state_actions, TAG_entry_points, TAG_sub_action,
106 TAG_cond_space_list, TAG_cond_space, TAG_cond_list, TAG_c,
109 # Inline block tokens.
110 token TAG_text, TAG_goto, TAG_call, TAG_next, TAG_goto_expr,
111 TAG_call_expr, TAG_next_expr, TAG_ret, TAG_pchar, TAG_char,
112 TAG_hold, TAG_exec, TAG_curs, TAG_targs, TAG_entry, TAG_data,
113 TAG_lm_switch, TAG_init_act, TAG_set_act, TAG_set_tokend,
114 TAG_get_tokend, TAG_init_tokstart, TAG_set_tokstart;
116 token TAG_write, TAG_access, TAG_break, TAG_arg, TAG_cs_expr;
118 token TAG_p_expr, TAG_pe_expr, TAG_eof_expr, TAG_cs_expr, TAG_top_expr,
119 TAG_stack_expr, TAG_act_expr, TAG_tokstart_expr, TAG_tokend_expr,
120 TAG_data_expr, TAG_prepush, TAG_postpop, TAG_eof_t;
123 %% write instance_data;
126 int parseLangEl( int type, const Token *token );
128 Parser( char *fileName, bool outputActive, bool wantComplete ) :
129 fileName(fileName), sourceFileName(0), outStream(0),
130 outputActive(outputActive), wantComplete(wantComplete),
133 int token( int tokenId, Token &token );
134 int token( int tokenId, int col, int line );
135 int token( XMLTag *tag, int col, int line );
137 /* Report an error encountered by the parser. */
138 ostream &warning( const InputLoc &loc );
140 ostream &error( const InputLoc &loc );
141 ostream &parser_error( int tokId, Token &token );
142 ostream &source_error( const InputLoc &loc );
144 /* The name of the root section, this does not change during an include. */
146 char *sourceFileName;
151 /* Collected during parsing. */
162 CodeGenMap codeGenMap;
164 Vector <char*> writeOptions;
169 int xml_parse( std::istream &input, char *fileName,
170 bool outputActive, bool wantComplete );
172 #endif /* _XMLPARSE_H */