001: /* Generated By:JavaCC: Do not edit this line. UtfParser.java */
002: package org.zaval.tools.i18n.translator;
003:
004: import java.io.*;
005: import java.util.*;
006:
007: public class UtfParser implements UtfParserConstants {
008: private String key = "default";
009: private Hashtable ask;
010:
011: public Hashtable parse() throws ParseException {
012: ask = new Hashtable();
013: parseMain();
014: return ask;
015: }
016:
017: final public void parseMain() throws ParseException {
018: label_1: while (true) {
019: keyDef();
020:
021: label_2: while (true) {
022: langPair();
023:
024: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
025: case STRING_LITERAL_1:
026: case STRING_LITERAL_2:
027: ;
028: break;
029: default:
030: jj_la1[0] = jj_gen;
031: break label_2;
032: }
033: }
034:
035: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
036: case KEY:
037: ;
038: break;
039: default:
040: jj_la1[1] = jj_gen;
041: break label_1;
042: }
043: }
044:
045: jj_consume_token(0);
046: }
047:
048: final public void keyDef() throws ParseException {
049: String name;
050: jj_consume_token(KEY);
051: jj_consume_token(EQ);
052: name = string();
053: key = name;
054: jj_consume_token(DBC);
055: }
056:
057: final public void langPair() throws ParseException {
058: String lang, val;
059: lang = string();
060:
061: jj_consume_token(EQ);
062: val = string();
063: ask.put(key + "!" + lang, val);
064: }
065:
066: final public String string() throws ParseException {
067: Token tok;
068: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
069: case STRING_LITERAL_1:
070: tok = jj_consume_token(STRING_LITERAL_1);
071: break;
072: case STRING_LITERAL_2:
073: tok = jj_consume_token(STRING_LITERAL_2);
074: break;
075: default:
076: jj_la1[2] = jj_gen;
077: jj_consume_token(-1);
078: throw new ParseException();
079: }
080: {
081: if (true)
082: return tok.image.substring(1, tok.image.length() - 1);
083: }
084: throw new Error("Missing return statement in function");
085: }
086:
087: public UtfParserTokenManager token_source;
088: JavaCharStream jj_input_stream;
089: public Token token, jj_nt;
090: private int jj_ntk;
091: private int jj_gen;
092: final private int[] jj_la1 = new int[3];
093: static private int[] jj_la1_0;
094: static {
095: jj_la1_0();
096: }
097:
098: private static void jj_la1_0() {
099: jj_la1_0 = new int[] { 0x3000, 0x200, 0x3000, };
100: }
101:
102: public UtfParser(java.io.InputStream stream) {
103: jj_input_stream = new JavaCharStream(stream, 1, 1);
104: token_source = new UtfParserTokenManager(jj_input_stream);
105: token = new Token();
106: jj_ntk = -1;
107: jj_gen = 0;
108: for (int i = 0; i < 3; i++)
109: jj_la1[i] = -1;
110: }
111:
112: public void ReInit(java.io.InputStream stream) {
113: jj_input_stream.ReInit(stream, 1, 1);
114: token_source.ReInit(jj_input_stream);
115: token = new Token();
116: jj_ntk = -1;
117: jj_gen = 0;
118: for (int i = 0; i < 3; i++)
119: jj_la1[i] = -1;
120: }
121:
122: public UtfParser(java.io.Reader stream) {
123: jj_input_stream = new JavaCharStream(stream, 1, 1);
124: token_source = new UtfParserTokenManager(jj_input_stream);
125: token = new Token();
126: jj_ntk = -1;
127: jj_gen = 0;
128: for (int i = 0; i < 3; i++)
129: jj_la1[i] = -1;
130: }
131:
132: public void ReInit(java.io.Reader stream) {
133: jj_input_stream.ReInit(stream, 1, 1);
134: token_source.ReInit(jj_input_stream);
135: token = new Token();
136: jj_ntk = -1;
137: jj_gen = 0;
138: for (int i = 0; i < 3; i++)
139: jj_la1[i] = -1;
140: }
141:
142: public UtfParser(UtfParserTokenManager tm) {
143: token_source = tm;
144: token = new Token();
145: jj_ntk = -1;
146: jj_gen = 0;
147: for (int i = 0; i < 3; i++)
148: jj_la1[i] = -1;
149: }
150:
151: public void ReInit(UtfParserTokenManager tm) {
152: token_source = tm;
153: token = new Token();
154: jj_ntk = -1;
155: jj_gen = 0;
156: for (int i = 0; i < 3; i++)
157: jj_la1[i] = -1;
158: }
159:
160: final private Token jj_consume_token(int kind)
161: throws ParseException {
162: Token oldToken;
163: if ((oldToken = token).next != null)
164: token = token.next;
165: else
166: token = token.next = token_source.getNextToken();
167: jj_ntk = -1;
168: if (token.kind == kind) {
169: jj_gen++;
170: return token;
171: }
172: token = oldToken;
173: jj_kind = kind;
174: throw generateParseException();
175: }
176:
177: final public Token getNextToken() {
178: if (token.next != null)
179: token = token.next;
180: else
181: token = token.next = token_source.getNextToken();
182: jj_ntk = -1;
183: jj_gen++;
184: return token;
185: }
186:
187: final public Token getToken(int index) {
188: Token t = token;
189: for (int i = 0; i < index; i++) {
190: if (t.next != null)
191: t = t.next;
192: else
193: t = t.next = token_source.getNextToken();
194: }
195: return t;
196: }
197:
198: final private int jj_ntk() {
199: if ((jj_nt = token.next) == null)
200: return (jj_ntk = (token.next = token_source.getNextToken()).kind);
201: else
202: return (jj_ntk = jj_nt.kind);
203: }
204:
205: private java.util.Vector jj_expentries = new java.util.Vector();
206: private int[] jj_expentry;
207: private int jj_kind = -1;
208:
209: public ParseException generateParseException() {
210: jj_expentries.removeAllElements();
211: boolean[] la1tokens = new boolean[14];
212: for (int i = 0; i < 14; i++) {
213: la1tokens[i] = false;
214: }
215: if (jj_kind >= 0) {
216: la1tokens[jj_kind] = true;
217: jj_kind = -1;
218: }
219: for (int i = 0; i < 3; i++) {
220: if (jj_la1[i] == jj_gen) {
221: for (int j = 0; j < 32; j++) {
222: if ((jj_la1_0[i] & (1 << j)) != 0) {
223: la1tokens[j] = true;
224: }
225: }
226: }
227: }
228: for (int i = 0; i < 14; i++) {
229: if (la1tokens[i]) {
230: jj_expentry = new int[1];
231: jj_expentry[0] = i;
232: jj_expentries.addElement(jj_expentry);
233: }
234: }
235: int[][] exptokseq = new int[jj_expentries.size()][];
236: for (int i = 0; i < jj_expentries.size(); i++) {
237: exptokseq[i] = (int[]) jj_expentries.elementAt(i);
238: }
239: return new ParseException(token, exptokseq, tokenImage);
240: }
241:
242: final public void enable_tracing() {
243: }
244:
245: final public void disable_tracing() {
246: }
247:
248: }
|