/** * Reposition the scanner on some portion of the original source. The given endPosition is the last valid position. * Beyond this position, the scanner will answer EOF tokens (<code>ITerminalSymbols.TokenNameEOF</code>). * * @param begin the given start position * @param end the given end position */ public void resetTo(int begin, int end) { resetTo(begin, end, isInModuleDeclaration()); } public void resetTo(int begin, int end, boolean isModuleInfo) {
/** * Reposition the scanner on some portion of the original source. The given endPosition is the last valid position. * Beyond this position, the scanner will answer EOF tokens (<code>ITerminalSymbols.TokenNameEOF</code>). * * @param begin the given start position * @param end the given end position */ public void resetTo(int begin, int end) { resetTo(begin, end, isInModuleDeclaration()); } public void resetTo(int begin, int end, boolean isModuleInfo) {
private ScanContext getScanContext(int begin) { if (!isInModuleDeclaration()) return ScanContext.INACTIVE; if (begin == 0) return ScanContext.EXPECTING_KEYWORD; CompilerOptions options = new CompilerOptions(); options.complianceLevel = this.complianceLevel; options.sourceLevel = this.sourceLevel; ScanContextDetector parser = new ScanContextDetector(options); return parser.getScanContext(this.source, begin - 1); }
private ScanContext getScanContext(int begin) { if (!isInModuleDeclaration()) return ScanContext.INACTIVE; if (begin == 0) return ScanContext.EXPECTING_KEYWORD; CompilerOptions options = new CompilerOptions(); options.complianceLevel = this.complianceLevel; options.sourceLevel = this.sourceLevel; ScanContextDetector parser = new ScanContextDetector(options); return parser.getScanContext(this.source, begin - 1); }
private VanguardParser getVanguardParser() { if (this.vanguardParser == null) { this.vanguardScanner = new VanguardScanner(this.sourceLevel, this.complianceLevel); this.vanguardParser = new VanguardParser(this.vanguardScanner); this.vanguardScanner.setActiveParser(this.vanguardParser); } this.vanguardScanner.setSource(this.source); this.vanguardScanner.resetTo(this.startPosition, this.eofPosition - 1, isInModuleDeclaration(), this.scanContext); return this.vanguardParser; }
private VanguardParser getVanguardParser() { if (this.vanguardParser == null) { this.vanguardScanner = new VanguardScanner(this.sourceLevel, this.complianceLevel); this.vanguardParser = new VanguardParser(this.vanguardScanner); this.vanguardScanner.setActiveParser(this.vanguardParser); } this.vanguardScanner.setSource(this.source); this.vanguardScanner.resetTo(this.startPosition, this.eofPosition - 1, isInModuleDeclaration(), this.scanContext); return this.vanguardParser; }
public int getNextToken() throws InvalidInputException { int token; if (this.nextToken != TokenNameNotAToken) { token = this.nextToken; this.nextToken = TokenNameNotAToken; return token; // presumed to be unambiguous. } if (this.scanContext == null) { // init lazily, since isInModuleDeclaration needs the parser to be known this.scanContext = isInModuleDeclaration() ? ScanContext.EXPECTING_KEYWORD : ScanContext.INACTIVE; } token = getNextToken0(); if (areRestrictedModuleKeywordsActive()) { if (isRestrictedKeyword(token)) token = disambiguatedRestrictedKeyword(token); updateScanContext(token); } if (this.activeParser == null) { // anybody interested in the grammatical structure of the program should have registered. return token; } if (token == TokenNameLPAREN || token == TokenNameLESS || token == TokenNameAT) { token = disambiguatedToken(token); } else if (token == TokenNameELLIPSIS) { this.consumingEllipsisAnnotations = false; } this.lookBack[0] = this.lookBack[1]; this.lookBack[1] = token; return token; } protected int getNextToken0() throws InvalidInputException {
public int getNextToken() throws InvalidInputException { int token; if (this.nextToken != TokenNameNotAToken) { token = this.nextToken; this.nextToken = TokenNameNotAToken; return token; // presumed to be unambiguous. } if (this.scanContext == null) { // init lazily, since isInModuleDeclaration needs the parser to be known this.scanContext = isInModuleDeclaration() ? ScanContext.EXPECTING_KEYWORD : ScanContext.INACTIVE; } token = getNextToken0(); if (areRestrictedModuleKeywordsActive()) { if (isRestrictedKeyword(token)) token = disambiguatedRestrictedKeyword(token); updateScanContext(token); } if (this.activeParser == null) { // anybody interested in the grammatical structure of the program should have registered. return token; } if (token == TokenNameLPAREN || token == TokenNameLESS || token == TokenNameAT) { token = disambiguatedToken(token); } else if (token == TokenNameELLIPSIS) { this.consumingEllipsisAnnotations = false; } this.lookBack[0] = this.lookBack[1]; this.lookBack[1] = token; return token; } protected int getNextToken0() throws InvalidInputException {