5 /*ANTLR Translator Generator
6 * Project led by Terence Parr at http://www.jGuru.com
7 * Software rights: http://www.antlr.org/license.html
13 // ANTLR C# Code Generator by Micheal Jordan
14 // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com
15 // Anthony Oguntimehin
17 // With many thanks to Eric V. Smith from the ANTLR list.
23 * @see antlr.TokenBuffer
24 * @see antlr.LL1Parser
26 public class LLkParser
: Parser
30 public LLkParser(int k_
)
34 public LLkParser(ParserSharedInputState state
, int k_
)
39 public LLkParser(TokenBuffer tokenBuf
, int k_
)
42 setTokenBuffer(tokenBuf
);
44 public LLkParser(TokenStream lexer
, int k_
)
47 TokenBuffer tokenBuf
= new TokenBuffer(lexer
);
48 setTokenBuffer(tokenBuf
);
50 /*Consume another token from the input stream. Can only write sequentially!
51 * If you need 3 tokens ahead, you must consume() 3 times.
53 * Note that it is possible to overwrite tokens that have not been matched.
54 * For example, calling consume() 3 times when k=2, means that the first token
55 * consumed will be overwritten with the 3rd.
57 override public void consume()
59 inputState
.input
.consume();
61 override public int LA(int i
)
63 return inputState
.input
.LA(i
);
65 override public IToken
LT(int i
)
67 return inputState
.input
.LT(i
);
69 private void trace(string ee
, string rname
)
72 Console
.Out
.Write(ee
+ rname
+ ((inputState
.guessing
> 0)?"; [guessing]":"; "));
73 for (int i
= 1; i
<= k
; i
++)
77 Console
.Out
.Write(", ");
80 Console
.Out
.Write("LA(" + i
+ ")==" + LT(i
).getText());
84 Console
.Out
.Write("LA(" + i
+ ")==ull");
87 Console
.Out
.WriteLine("");
89 override public void traceIn(string rname
)
94 override public void traceOut(string rname
)