00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package org.antlr.runtime;
00029
00033 public class Parser extends BaseRecognizer {
00034 public TokenStream input;
00035
00036 public Parser(TokenStream input) {
00037 super();
00038 setTokenStream(input);
00039 }
00040
00041 public Parser(TokenStream input, RecognizerSharedState state) {
00042 super(state);
00043 setTokenStream(input);
00044 }
00045
00046 public void reset() {
00047 super.reset();
00048 if ( input!=null ) {
00049 input.seek(0);
00050 }
00051 }
00052
00053 protected Object getCurrentInputSymbol(IntStream input) {
00054 return ((TokenStream)input).LT(1);
00055 }
00056
00057 protected Object getMissingSymbol(IntStream input,
00058 RecognitionException e,
00059 int expectedTokenType,
00060 BitSet follow)
00061 {
00062 String tokenText = null;
00063 if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
00064 else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">";
00065 CommonToken t = new CommonToken(expectedTokenType, tokenText);
00066 Token current = ((TokenStream)input).LT(1);
00067 if ( current.getType() == Token.EOF ) {
00068 current = ((TokenStream)input).LT(-1);
00069 }
00070 t.line = current.getLine();
00071 t.charPositionInLine = current.getCharPositionInLine();
00072 t.channel = DEFAULT_TOKEN_CHANNEL;
00073 return t;
00074 }
00075
00077 public void setTokenStream(TokenStream input) {
00078 this.input = null;
00079 reset();
00080 this.input = input;
00081 }
00082
00083 public TokenStream getTokenStream() {
00084 return input;
00085 }
00086
00087 public String getSourceName() {
00088 return input.getSourceName();
00089 }
00090
00091 public void traceIn(String ruleName, int ruleIndex) {
00092 super.traceIn(ruleName, ruleIndex, input.LT(1));
00093 }
00094
00095 public void traceOut(String ruleName, int ruleIndex) {
00096 super.traceOut(ruleName, ruleIndex, input.LT(1));
00097 }
00098 }