1	/*
2	 * ANTLR-generated file resulting from grammar tokdef.g
3	 * 
4	 * Terence Parr, MageLang Institute
5	 * with John Lilley, Empathy Software
6	 * ANTLR Version 2.5.0; 1996,1997
7	 */
8	 package antlr; 
9	import java.io.IOException;
10	import antlr.Tokenizer;
11	import antlr.TokenBuffer;
12	import antlr.LLkParser;
13	import antlr.Token;
14	import antlr.ParserException;
15	import antlr.NoViableAltException;
16	import antlr.MismatchedTokenException;
17	import antlr.SemanticException;
18	import antlr.collections.impl.BitSet;
19	 import antlr.TokdefTokenManager; 
20	public class ANTLRTokdefParser extends LLkParserParser
21	       implements ANTLRTokdefParserTokenTypes
22	 {
23	
24	protected ANTLRTokdefParser(TokenBuffer tokenBuf, int k) {
25	  super(tokenBuf,k);
26	  tokenNames = _tokenNames;
27	}
28	
29	public ANTLRTokdefParser(TokenBuffer tokenBuf) {
30	  this(tokenBuf,3);
31	}
32	
33	protected ANTLRTokdefParser(Tokenizer lexer, int k) {
34	  super(lexer,k);
35	  tokenNames = _tokenNames;
36	}
37	
38	public ANTLRTokdefParser(Tokenizer lexer) {
39	  this(lexer,3);
40	}
41	
42		public final void file(
43			TokdefTokenManager tm
44		) throws ParserException, IOException {
45			
46			Token  name = null;
47			
48			try {      // for error handling
49				name = LT(1);
50				match(ID);
51				tm.setName(name.getText());
52				{
53				_loop3:
54				do {
55					if ((LA(1)==ID||LA(1)==STRING)) {
56						line(tm);
57					}
58					else {
59						break _loop3;
60					}
61					
62				} while (true);
63				}
64			}
65			catch (ParserException ex) {
66				reportError(ex);
67				consume();
68				consumeUntil(_tokenSet_0);
69			}
70		}
71		
72		public final void line(
73			TokdefTokenManager tm
74		) throws ParserException, IOException {
75			
76			Token  s1 = null;
77			Token  lab = null;
78			Token  s2 = null;
79			Token  id = null;
80			Token  para = null;
81			Token  id2 = null;
82			Token  i = null;
83			Token t=null; Token s=null;
84			
85			try {      // for error handling
86				{
87				if ((LA(1)==STRING)) {
88					s1 = LT(1);
89					match(STRING);
90					s = s1;
91				}
92				else if ((LA(1)==ID) && (LA(2)==ASSIGN) && (LA(3)==STRING)) {
93					lab = LT(1);
94					match(ID);
95					t = lab;
96					match(ASSIGN);
97					s2 = LT(1);
98					match(STRING);
99					s = s2;
100				}
101				else if ((LA(1)==ID) && (LA(2)==LPAREN)) {
102					id = LT(1);
103					match(ID);
104					t=id;
105					match(LPAREN);
106					para = LT(1);
107					match(STRING);
108					match(RPAREN);
109				}
110				else if ((LA(1)==ID) && (LA(2)==ASSIGN) && (LA(3)==INT)) {
111					id2 = LT(1);
112					match(ID);
113					t=id2;
114				}
115				else {
116					throw new NoViableAltException(LT(1));
117				}
118				
119				}
120				match(ASSIGN);
121				i = LT(1);
122				match(INT);
123				
124						Integer value = Integer.valueOf(i.getText());
125						// define token type of token label
126						if ( t!=null ) {
127							tm.define(t.getText(), value.intValue());
128							if ( para!=null ) {
129								TokenSymbol ts = tm.getTokenSymbol(t.getText());
130								ts.setParaphrase(
131				//					antlr.Tool.stripFrontBack(para.getText(),"\"","\"")
132									para.getText()
133								);
134							}
135						}
136						// if literal found, define that too.
137						if ( s!=null ) {
138							tm.define(s.getText(), value.intValue());
139						}
140						
141			}
142			catch (ParserException ex) {
143				reportError(ex);
144				consume();
145				consumeUntil(_tokenSet_1);
146			}
147		}
148		
149		
150		public static final String[] _tokenNames = {
151			"<0>",
152			"EOF",
153			"<2>",
154			"NULL_TREE_LOOKAHEAD",
155			"ID",
156			"STRING",
157			"ASSIGN",
158			"LPAREN",
159			"RPAREN",
160			"INT",
161			"WS",
162			"SL_COMMENT",
163			"ML_COMMENT",
164			"ESC",
165			"DIGIT",
166			"XDIGIT",
167			"VOCAB"
168		};
169		
170		private static final long _tokenSet_0_data_[] = { 2L, 0L };
171		public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_);
172		private static final long _tokenSet_1_data_[] = { 50L, 0L };
173		public static final BitSet _tokenSet_1 = new BitSet(_tokenSet_1_data_);
174		
175		}
176