summaryrefslogtreecommitdiffstats
path: root/poxml/GettextParser.cpp
blob: fda1066a31c89d5fe37e9dfd6abea3a255ddddbf (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/* $ANTLR 2.7.1: "gettext.g" -> "GettextParser.cpp"$ */
#include "GettextParser.hpp"
#include "antlr/NoViableAltException.hpp"
#include "antlr/SemanticException.hpp"
#line 12 "gettext.g"

#include <iostream>
#include "GettextLexer.hpp"
#include "GettextParser.hpp"
#include "antlr/AST.hpp"
#include "antlr/CommonAST.hpp"

/* 
int main()
{
	ANTLR_USING_NAMESPACE(std)
	ANTLR_USING_NAMESPACE(antlr)
	try {
		GettextLexer lexer(cin);
		GettextParser parser(lexer);
		parser.file();

	} catch(exception& e) {
		cerr << "exception: " << e.what() << endl;
	}
}
*/

#line 30 "GettextParser.cpp"
GettextParser::GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf, int k)
: ANTLR_USE_NAMESPACE(antlr)LLkParser(tokenBuf,k)
{
	setTokenNames(_tokenNames);
}

GettextParser::GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf)
: ANTLR_USE_NAMESPACE(antlr)LLkParser(tokenBuf,1)
{
	setTokenNames(_tokenNames);
}

GettextParser::GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer, int k)
: ANTLR_USE_NAMESPACE(antlr)LLkParser(lexer,k)
{
	setTokenNames(_tokenNames);
}

GettextParser::GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer)
: ANTLR_USE_NAMESPACE(antlr)LLkParser(lexer,1)
{
	setTokenNames(_tokenNames);
}

GettextParser::GettextParser(const ANTLR_USE_NAMESPACE(antlr)ParserSharedInputState& state)
: ANTLR_USE_NAMESPACE(antlr)LLkParser(state,1)
{
	setTokenNames(_tokenNames);
}

 MsgList  GettextParser::file() {
#line 43 "gettext.g"
	 MsgList ml ;
#line 64 "GettextParser.cpp"
#line 43 "gettext.g"
	
	string c, mi, ms;
	MsgBlock mb;
	MsgList ml2;
	
#line 71 "GettextParser.cpp"
	
	try {      // for error handling
		bool synPredMatched3 = false;
		if (((LA(1)==T_MSGID||LA(1)==T_COMMENT))) {
			int _m3 = mark();
			synPredMatched3 = true;
			inputState->guessing++;
			try {
				{
				comment();
				match(T_MSGID);
				}
			}
			catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
				synPredMatched3 = false;
			}
			rewind(_m3);
			inputState->guessing--;
		}
		if ( synPredMatched3 ) {
			{
			mb=file_block();
			ml2=file();
			if ( inputState->guessing==0 ) {
#line 49 "gettext.g"
				ml = ml2; ml.append(mb);
#line 98 "GettextParser.cpp"
			}
			}
		}
		else {
			bool synPredMatched6 = false;
			if (((LA(1)==ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE||LA(1)==T_COMMENT))) {
				int _m6 = mark();
				synPredMatched6 = true;
				inputState->guessing++;
				try {
					{
					comment();
					match(ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE);
					}
				}
				catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
					synPredMatched6 = false;
				}
				rewind(_m6);
				inputState->guessing--;
			}
			if ( synPredMatched6 ) {
				c=comment();
				if ( inputState->guessing==0 ) {
#line 50 "gettext.g"
					(void)c;
#line 125 "GettextParser.cpp"
				}
			}
		else {
			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
		}
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			consume();
			consumeUntil(_tokenSet_0);
		} else {
			throw ex;
		}
	}
	return ml ;
}

string  GettextParser::comment() {
#line 76 "gettext.g"
	string s;
#line 148 "GettextParser.cpp"
	ANTLR_USE_NAMESPACE(antlr)RefToken  c = ANTLR_USE_NAMESPACE(antlr)nullToken;
#line 76 "gettext.g"
	
	string r;
	
#line 154 "GettextParser.cpp"
	
	try {      // for error handling
		if ((LA(1)==T_COMMENT)) {
			{
			c = LT(1);
			match(T_COMMENT);
			r=comment();
			if ( inputState->guessing==0 ) {
#line 80 "gettext.g"
				s = c->getText() + r;
#line 165 "GettextParser.cpp"
			}
			}
		}
		else if ((LA(1)==ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE||LA(1)==T_MSGID)) {
		}
		else {
			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
		}
		
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			consume();
			consumeUntil(_tokenSet_1);
		} else {
			throw ex;
		}
	}
	return s;
}

 MsgBlock  GettextParser::file_block() {
#line 53 "gettext.g"
	 MsgBlock mb ;
#line 191 "GettextParser.cpp"
#line 53 "gettext.g"
	
	string c, mi, mip, ms;
	
#line 196 "GettextParser.cpp"
	
	try {      // for error handling
		c=comment();
		mi=msgid();
		{
		if ((LA(1)==T_MSGSTR)) {
			{
			ms=msgstr();
			if ( inputState->guessing==0 ) {
#line 59 "gettext.g"
				
					mb.comment = TQString::fromUtf8(c.c_str());
					mb.msgid = TQString::fromUtf8(mi.c_str());
					mb.msgstr = TQString::fromUtf8(ms.c_str());   
				
#line 212 "GettextParser.cpp"
			}
			}
		}
		else if ((LA(1)==T_MSGID_PLURAL)) {
			{
			mip=msgid_plural();
			ms=msgstr_plural();
			if ( inputState->guessing==0 ) {
#line 66 "gettext.g"
				
					mb.comment = TQString::fromUtf8(c.c_str());
					mb.msgid = TQString::fromUtf8(mi.c_str());
					mb.msgid_plural = TQString::fromUtf8(mip.c_str());
					mb.msgstr = TQString::fromUtf8(ms.c_str());   
				
#line 228 "GettextParser.cpp"
			}
			}
		}
		else {
			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
		}
		
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			consume();
			consumeUntil(_tokenSet_2);
		} else {
			throw ex;
		}
	}
	return mb ;
}

string  GettextParser::msgid() {
#line 84 "gettext.g"
	string s;
#line 253 "GettextParser.cpp"
	ANTLR_USE_NAMESPACE(antlr)RefToken  t = ANTLR_USE_NAMESPACE(antlr)nullToken;
	
	try {      // for error handling
		match(T_MSGID);
		t = LT(1);
		match(T_STRING);
		if ( inputState->guessing==0 ) {
#line 85 "gettext.g"
			s = t->getText();
#line 263 "GettextParser.cpp"
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			consume();
			consumeUntil(_tokenSet_3);
		} else {
			throw ex;
		}
	}
	return s;
}

string  GettextParser::msgstr() {
#line 92 "gettext.g"
	string s;
#line 281 "GettextParser.cpp"
	ANTLR_USE_NAMESPACE(antlr)RefToken  t = ANTLR_USE_NAMESPACE(antlr)nullToken;
	
	try {      // for error handling
		match(T_MSGSTR);
		t = LT(1);
		match(T_STRING);
		if ( inputState->guessing==0 ) {
#line 93 "gettext.g"
			s = t->getText();
#line 291 "GettextParser.cpp"
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			consume();
			consumeUntil(_tokenSet_2);
		} else {
			throw ex;
		}
	}
	return s;
}

string  GettextParser::msgid_plural() {
#line 88 "gettext.g"
	string s;
#line 309 "GettextParser.cpp"
	ANTLR_USE_NAMESPACE(antlr)RefToken  t = ANTLR_USE_NAMESPACE(antlr)nullToken;
	
	try {      // for error handling
		match(T_MSGID_PLURAL);
		t = LT(1);
		match(T_STRING);
		if ( inputState->guessing==0 ) {
#line 89 "gettext.g"
			s = t->getText();
#line 319 "GettextParser.cpp"
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			consume();
			consumeUntil(_tokenSet_4);
		} else {
			throw ex;
		}
	}
	return s;
}

string  GettextParser::msgstr_plural() {
#line 96 "gettext.g"
	string s;
#line 337 "GettextParser.cpp"
	ANTLR_USE_NAMESPACE(antlr)RefToken  n = ANTLR_USE_NAMESPACE(antlr)nullToken;
	ANTLR_USE_NAMESPACE(antlr)RefToken  t = ANTLR_USE_NAMESPACE(antlr)nullToken;
	
	try {      // for error handling
		{
		int _cnt18=0;
		for (;;) {
			if ((LA(1)==T_MSGSTR)) {
				match(T_MSGSTR);
				match(L_BRACKET);
				n = LT(1);
				match(T_INT);
				match(R_BRACKET);
				t = LT(1);
				match(T_STRING);
				if ( inputState->guessing==0 ) {
#line 98 "gettext.g"
					s = t->getText();
#line 356 "GettextParser.cpp"
				}
			}
			else {
				if ( _cnt18>=1 ) { goto _loop18; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt18++;
		}
		_loop18:;
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			consume();
			consumeUntil(_tokenSet_2);
		} else {
			throw ex;
		}
	}
	return s;
}

const char* GettextParser::_tokenNames[] = {
	"<0>",
	"EOF",
	"<2>",
	"NULL_TREE_LOOKAHEAD",
	"T_MSGID",
	"T_COMMENT",
	"T_STRING",
	"T_MSGID_PLURAL",
	"T_MSGSTR",
	"L_BRACKET",
	"T_INT",
	"R_BRACKET",
	"WS",
	"MSG_TAG",
	"ESC",
	0
};

const unsigned long GettextParser::_tokenSet_0_data_[] = { 2UL, 0UL, 0UL, 0UL };
// EOF 
const ANTLR_USE_NAMESPACE(antlr)BitSet GettextParser::_tokenSet_0(_tokenSet_0_data_,4);
const unsigned long GettextParser::_tokenSet_1_data_[] = { 18UL, 0UL, 0UL, 0UL };
// EOF T_MSGID 
const ANTLR_USE_NAMESPACE(antlr)BitSet GettextParser::_tokenSet_1(_tokenSet_1_data_,4);
const unsigned long GettextParser::_tokenSet_2_data_[] = { 50UL, 0UL, 0UL, 0UL };
// EOF T_MSGID T_COMMENT 
const ANTLR_USE_NAMESPACE(antlr)BitSet GettextParser::_tokenSet_2(_tokenSet_2_data_,4);
const unsigned long GettextParser::_tokenSet_3_data_[] = { 384UL, 0UL, 0UL, 0UL };
// T_MSGID_PLURAL T_MSGSTR 
const ANTLR_USE_NAMESPACE(antlr)BitSet GettextParser::_tokenSet_3(_tokenSet_3_data_,4);
const unsigned long GettextParser::_tokenSet_4_data_[] = { 256UL, 0UL, 0UL, 0UL };
// T_MSGSTR 
const ANTLR_USE_NAMESPACE(antlr)BitSet GettextParser::_tokenSet_4(_tokenSet_4_data_,4);