summaryrefslogtreecommitdiff
path: root/colm/load.h
blob: eeaceca771dce51cd8cce214462db5d5256108d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
 *  Copyright 2013 Adrian Thurston <thurston@complang.org>
 */

/*  This file is part of Colm.
 *
 *  Colm is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 * 
 *  Colm is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with Colm; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */

#include <iostream>
#include "avltree.h"
#include "parsedata.h"
#include "parser.h"

struct lex_factor;
struct lex_factor_neg;
struct lex_factor_rep;
struct lex_term;
struct lex_expr;
struct token_list;
struct prod_el_list;
struct prod_list;
struct root_item;
struct region_def;
struct cfl_def;
struct statement;
struct print_stmt;
struct expr_stmt;
struct var_ref;
struct code_expr;
struct _repeat_code_expr;
struct qual;
struct region_qual;
struct opt_repeat;
struct type_ref;
struct root_item;
struct _repeat_root_item;
struct namespace_def;
struct var_def;
struct block_or_single;
struct iter_call;
struct lang_stmt_list;
struct elsif_list;
struct elsif_clause;
struct optional_else;
struct code_factor;
struct reg_or_char;
struct reg_or_data;
struct literal_item;
struct literal_list;
struct literal_def;
struct token_def;
struct ignore_def;
struct context_def;
struct context_item;
struct context_var_def;
struct opt_reduce;
struct field_init;
struct opt_field_init;
struct lit_accum_el;
struct _repeat_lit_accum_el;
struct accum_top_el;
struct accum_list;
struct accumulate;
struct accum_el;
struct _repeat_accum_el;
struct rl_def;
struct lit_cons_el;
struct _repeat_lit_cons_el;
struct cons_top_el;
struct cons_list;
struct constructor;
struct cons_el;
struct _repeat_cons_el;
struct code_relational;
struct code_additive;
struct lit_string_el;
struct _repeat_lit_string_el;
struct string_top_el;
struct string_list;
struct cstring;
struct string_el;
struct _repeat_string_el;

struct LoadSource
:
	public BaseParser
{
	LoadSource( Compiler *pd, const char *inputFileName )
	:
		BaseParser( pd ),
		inputFileName( inputFileName )
	{}

	const char *inputFileName;

	void go();

	ObjectField *walkVarDef( var_def varDef );
	NamespaceQual *walkRegionQual( region_qual regionQual );
	RepeatType walkOptRepeat( opt_repeat OptRepeat );
	TypeRef *walkTypeRef( type_ref typeRef );

	ReOrItem *walkRegOrChar( reg_or_char regOrChar );
	ReOrBlock *walkRegOrData( reg_or_data regOrData );

	LexFactor *walkLexFactor( lex_factor &LexFactorTree );
	LexFactorNeg *walkLexFactorNeg( lex_factor_neg &LexFactorNegTree );
	LexFactorRep *walkLexFactorRep( lex_factor_rep &LexFactorRepTree );
	LexFactorAug *walkLexFactorAug( lex_factor_rep &LexFactorRepTree );
	LexTerm *walkLexTerm( lex_term &LexTerm );
	LexExpression *walkLexExpr( lex_expr &LexExpr );
	ExprVect *walkCodeExprList( _repeat_code_expr codeExprList );
	LangExpr *walkCodeExpr( code_expr codeExpr );
	void walkTokenList( token_list &TokenList );
	void walkLexRegion( region_def regionDef );
	void walkProdElList( ProdElList *list, prod_el_list ProdElList );
	void walkProdList( LelDefList *lelDefList, prod_list &ProdList );
	void walkCflDef( cfl_def cflDef );
	LangTerm *walkIterCall( iter_call IterCall );
	LangStmt *walkOptionalElse( optional_else optionalElse );
	LangStmt *walkElsifClause( elsif_clause elsifClause );
	LangStmt *walkElsifList( elsif_list elsifList );
	LangStmt *walkStatement( statement Statement );
	LangStmt *walkPrintStmt( print_stmt &PrintStmt );
	LangExpr *walkCodeFactor( code_factor codeFactor );
	LangStmt *walkExprStmt( expr_stmt &ExprStmt );
	QualItemVect *walkQual( qual &Qual );
	LangVarRef *walkVarRef( var_ref varRef );
	void walkRootItem( root_item &rootItem, StmtList *stmtList );
	StmtList *walkRootItemList( _repeat_root_item rootItemList );
	void walkNamespaceDef( namespace_def NamespaceDef );
	StmtList *walkLangStmtList( lang_stmt_list LangStmtList );
	StmtList *walkBlockOrSingle( block_or_single blockOrSingle );

	void walkLiteralItem( literal_item literalItem );
	void walkLiteralList( literal_list literalList );
	void walkLiteralDef( literal_def literalDef );

	void walkTokenDef( token_def TokenDef );
	void walkIgnoreDef( ignore_def IgnoreDef );
	void walkContextDef( context_def contextDef );
	void walkContextItem( context_item contextItem );
	void walkContextVarDef( context_var_def contextVarDef );
	CodeBlock *walkOptReduce( opt_reduce optReduce );

	void walkFieldInit( FieldInitVect *list, field_init fieldInit );
	FieldInitVect *walkOptFieldInit( opt_field_init optFieldInit );

	ConsItemList *walkLitAccumEl( lit_accum_el litAccumEl );
	ConsItemList *walkLitAccumElList( _repeat_lit_accum_el litAccumElList );
	ConsItemList *walkAccumTopEl( accum_top_el accumTopEl );
	ConsItemList *walkAccumList( accum_list accumList );
	ConsItemList *walkAccumulate( accumulate Accumulate );
	ConsItemList *walkAccumEl( accum_el accumEl );
	ConsItemList *walkAccumElList( _repeat_accum_el accumElList );

	void walkRlDef( rl_def RlDef );

	ConsItemList *walkLitConsEl( lit_cons_el litConsEl );
	ConsItemList *walkLitConsElList( _repeat_lit_cons_el litConsElList );
	ConsItemList *walkConsTopEl( cons_top_el consTopEl );
	ConsItemList *walkConsList( cons_list consList );
	ConsItemList *walkConstructor( constructor Constructor );
	ConsItemList *walkConsEl( cons_el consEl );
	ConsItemList *walkConsElList( _repeat_cons_el consElList );

	LangExpr *walkCodeRelational( code_relational codeRelational );
	LangExpr *walkCodeAdditive( code_additive codeAdditive );

	ConsItemList *walkLitStringEl( lit_string_el litStringEl );
	ConsItemList *walkLitStringElList( _repeat_lit_string_el litStringElList );
	ConsItemList *walkStringTopEl( string_top_el stringTopEl );
	ConsItemList *walkStringList( string_list stringList );
	ConsItemList *walkString( cstring String );
	ConsItemList *walkStringEl( string_el stringEl );
	ConsItemList *walkStringElList( _repeat_string_el stringElList );
};