Пример #1
0
 @Override
 protected IParseResult parse(String ruleName, ANTLRInputStream in) {
   org.xtext.cg2009.parser.antlr.internal.InternalEntitiesLexer lexer =
       new org.xtext.cg2009.parser.antlr.internal.InternalEntitiesLexer(in);
   XtextTokenStream stream = new XtextTokenStream(lexer, antlrTokenDefProvider);
   stream.setInitialHiddenTokens("RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT");
   org.xtext.cg2009.parser.antlr.internal.InternalEntitiesParser parser =
       new org.xtext.cg2009.parser.antlr.internal.InternalEntitiesParser(
           stream, getElementFactory(), grammarAccess);
   parser.setTokenTypeMap(antlrTokenDefProvider.getTokenDefMap());
   try {
     if (ruleName != null) return parser.parse(ruleName);
     return parser.parse();
   } catch (Exception re) {
     throw new ParseException(re.getMessage(), re);
   }
 }
 @Override
 public void consume() {
   if (getListener() != null) {
     if (getFirstMarker() == -1 && getCurrentLookAhead() <= 1 && p >= tokens.size()) {
       if (!attemptedToConsumePastEof) {
         attemptedToConsumePastEof = true;
         getListener().announceConsume();
       }
     } else {
       getListener().announceConsume();
     }
   }
   super.consume();
 }
Пример #3
0
 @Override
 protected void setInitialHiddenTokens(XtextTokenStream tokenStream) {
   tokenStream.setInitialHiddenTokens("RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT");
 }
 @Override
 public void rewind(int marker) {
   if (marker != tokens.size()) attemptedToConsumePastEof = false;
   if (getListener() != null) getListener().announceRewind(marker);
   super.rewind(marker);
 }