[Swift] Minor tidyups in the stream code.

No semantic change.
This commit is contained in:
Ewan Mellor 2017-12-06 13:47:16 -08:00
parent 5c112be2ab
commit 35b9bbfe17
No known key found for this signature in database
GPG Key ID: 7CE1C6BC9EC8645D
4 changed files with 102 additions and 147 deletions

View File

@ -2,17 +2,16 @@
/// Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. /// Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/// Use of this file is governed by the BSD 3-clause license that /// Use of this file is governed by the BSD 3-clause license that
/// can be found in the LICENSE.txt file in the project root. /// can be found in the LICENSE.txt file in the project root.
///
///
/// Vacuum all input from a _java.io.Reader_/_java.io.InputStream_ and then treat it /// Vacuum all input from a _java.io.Reader_/_java.io.InputStream_ and then treat it
/// like a `char[]` buffer. Can also pass in a _String_ or /// like a `char[]` buffer. Can also pass in a _String_ or
/// `char[]` to use. /// `char[]` to use.
/// ///
/// If you need encoding, pass in stream/reader with correct encoding. /// If you need encoding, pass in stream/reader with correct encoding.
/// ///
public class ANTLRInputStream: CharStream { public class ANTLRInputStream: CharStream {
public static let READ_BUFFER_SIZE: Int = 1024
public static let INITIAL_BUFFER_SIZE: Int = 1024
/// ///
/// The data being scanned /// The data being scanned
/// ///
@ -24,9 +23,9 @@ public class ANTLRInputStream: CharStream {
internal var n: Int internal var n: Int
/// ///
/// 0..n-1 index into string of next char /// 0...n-1 index into string of next char
/// ///
internal var p: Int = 0 internal var p = 0
/// ///
/// What is name or source of this char stream? /// What is name or source of this char stream?
@ -62,7 +61,7 @@ public class ANTLRInputStream: CharStream {
if p >= n { if p >= n {
assert(LA(1) == ANTLRInputStream.EOF, "Expected: LA(1)==IntStream.EOF") assert(LA(1) == ANTLRInputStream.EOF, "Expected: LA(1)==IntStream.EOF")
throw ANTLRError.illegalState(msg: "annot consume EOF") throw ANTLRError.illegalState(msg: "cannot consume EOF")
} }
@ -99,7 +98,7 @@ public class ANTLRInputStream: CharStream {
} }
/// ///
/// Return the current input symbol index 0..n where n indicates the /// Return the current input symbol index 0...n where n indicates the
/// last symbol has been read. The index is the index of char to /// last symbol has been read. The index is the index of char to
/// be returned from LA(1). /// be returned from LA(1).
/// ///
@ -136,29 +135,21 @@ public class ANTLRInputStream: CharStream {
// seek forward, consume until p hits index or n (whichever comes first) // seek forward, consume until p hits index or n (whichever comes first)
index = min(index, n) index = min(index, n)
while p < index { while p < index {
try consume() try consume()
} }
} }
public func getText(_ interval: Interval) -> String { public func getText(_ interval: Interval) -> String {
let start: Int = interval.a let start = interval.a
var stop: Int = interval.b
if stop >= n {
stop = n - 1
}
let count = stop - start + 1;
if start >= n { if start >= n {
return "" return ""
} }
let stop = min(n, interval.b + 1)
return String(data[start ..< (start + count)]) return String(data[start ..< stop])
} }
public func getSourceName() -> String { public func getSourceName() -> String {
guard let name = name , !name.isEmpty else { return name ?? ANTLRInputStream.UNKNOWN_SOURCE_NAME
return ANTLRInputStream.UNKNOWN_SOURCE_NAME
}
return name
} }
public func toString() -> String { public func toString() -> String {

View File

@ -30,8 +30,7 @@ public class BufferedTokenStream: TokenStream {
/// considered a complete view of the input once _#fetchedEOF_ is set /// considered a complete view of the input once _#fetchedEOF_ is set
/// to `true`. /// to `true`.
/// ///
internal var tokens: Array<Token> = Array<Token>() internal var tokens = [Token]()
// Array<Token>(100
/// ///
/// The index into _#tokens_ of the current token (next token to /// The index into _#tokens_ of the current token (next token to
@ -44,7 +43,7 @@ public class BufferedTokenStream: TokenStream {
/// see the documentation of _org.antlr.v4.runtime.IntStream_ for a description of /// see the documentation of _org.antlr.v4.runtime.IntStream_ for a description of
/// Initializing Methods. /// Initializing Methods.
/// ///
internal var p: Int = -1 internal var p = -1
/// ///
/// Indicates whether the _org.antlr.v4.runtime.Token#EOF_ token has been fetched from /// Indicates whether the _org.antlr.v4.runtime.Token#EOF_ token has been fetched from
@ -58,10 +57,10 @@ public class BufferedTokenStream: TokenStream {
/// * _#fetch_: The check to prevent adding multiple EOF symbols into /// * _#fetch_: The check to prevent adding multiple EOF symbols into
/// _#tokens_ is trivial with this field. /// _#tokens_ is trivial with this field.
/// ///
internal var fetchedEOF: Bool = false internal var fetchedEOF = false
public init(_ tokenSource: TokenSource) { public init(_ tokenSource: TokenSource) {
self.tokenSource = tokenSource self.tokenSource = tokenSource
} }
@ -135,10 +134,10 @@ public class BufferedTokenStream: TokenStream {
@discardableResult @discardableResult
internal func sync(_ i: Int) throws -> Bool { internal func sync(_ i: Int) throws -> Bool {
assert(i >= 0, "Expected: i>=0") assert(i >= 0, "Expected: i>=0")
let n: Int = i - tokens.count + 1 // how many more elements we need? let n = i - tokens.count + 1 // how many more elements we need?
//print("sync("+i+") needs "+n); //print("sync("+i+") needs "+n);
if n > 0 { if n > 0 {
let fetched: Int = try fetch(n) let fetched = try fetch(n)
return fetched >= n return fetched >= n
} }
@ -156,12 +155,12 @@ public class BufferedTokenStream: TokenStream {
} }
for i in 0..<n { for i in 0..<n {
let t: Token = try tokenSource.nextToken() let t = try tokenSource.nextToken()
if t is WritableToken { if let wt = t as? WritableToken {
(t as! WritableToken).setTokenIndex(tokens.count) wt.setTokenIndex(tokens.count)
} }
tokens.append(t) //add tokens.append(t)
if t.getType() == BufferedTokenStream.EOF { if t.getType() == BufferedTokenStream.EOF {
fetchedEOF = true fetchedEOF = true
return i + 1 return i + 1
@ -173,14 +172,13 @@ public class BufferedTokenStream: TokenStream {
public func get(_ i: Int) throws -> Token { public func get(_ i: Int) throws -> Token {
if i < 0 || i >= tokens.count { if i < 0 || i >= tokens.count {
let index = tokens.count - 1 throw ANTLRError.indexOutOfBounds(msg: "token index \(i) out of range 0 ..< \(tokens.count)")
throw ANTLRError.indexOutOfBounds(msg: "token index \(i) out of range 0..\(index)")
} }
return tokens[i] return tokens[i]
} }
/// ///
/// Get all tokens from start..stop inclusively /// Get all tokens from start...stop inclusively
/// ///
public func get(_ start: Int,_ stop: Int) throws -> Array<Token>? { public func get(_ start: Int,_ stop: Int) throws -> Array<Token>? {
var stop = stop var stop = stop
@ -188,12 +186,12 @@ public class BufferedTokenStream: TokenStream {
return nil return nil
} }
try lazyInit() try lazyInit()
var subset: Array<Token> = Array<Token>() var subset = [Token]()
if stop >= tokens.count { if stop >= tokens.count {
stop = tokens.count - 1 stop = tokens.count - 1
} }
for i in start...stop { for i in start...stop {
let t: Token = tokens[i] let t = tokens[i]
if t.getType() == BufferedTokenStream.EOF { if t.getType() == BufferedTokenStream.EOF {
break break
} }
@ -223,14 +221,13 @@ public class BufferedTokenStream: TokenStream {
return try LB(-k) return try LB(-k)
} }
let i: Int = p + k - 1 let i = p + k - 1
try sync(i) try sync(i)
if i >= tokens.count { if i >= tokens.count {
// return EOF token // return EOF token
// EOF must be last token // EOF must be last token
return tokens[tokens.count - 1] return tokens.last!
} }
// if ( i>range ) range = i;
return tokens[i] return tokens[i]
} }
@ -289,7 +286,7 @@ public class BufferedTokenStream: TokenStream {
try lazyInit() try lazyInit()
if start < 0 || start >= tokens.count || if start < 0 || start >= tokens.count ||
stop < 0 || stop >= tokens.count { stop < 0 || stop >= tokens.count {
throw ANTLRError.indexOutOfBounds(msg: "start \(start) or stop \(stop) not in 0...\(tokens.count - 1)") throw ANTLRError.indexOutOfBounds(msg: "start \(start) or stop \(stop) not in 0 ..< \(tokens.count)")
} }
if start > stop { if start > stop {
@ -330,7 +327,7 @@ public class BufferedTokenStream: TokenStream {
return size() - 1 return size() - 1
} }
var token: Token = tokens[i] var token = tokens[i]
while token.getChannel() != channel { while token.getChannel() != channel {
if token.getType() == BufferedTokenStream.EOF { if token.getType() == BufferedTokenStream.EOF {
return i return i
@ -363,7 +360,7 @@ public class BufferedTokenStream: TokenStream {
} }
while i >= 0 { while i >= 0 {
let token: Token = tokens[i] let token = tokens[i]
if token.getType() == BufferedTokenStream.EOF || token.getChannel() == channel { if token.getType() == BufferedTokenStream.EOF || token.getChannel() == channel {
return i return i
} }
@ -379,45 +376,35 @@ public class BufferedTokenStream: TokenStream {
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or /// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or
/// EOF. If channel is -1, find any non default channel token. /// EOF. If channel is -1, find any non default channel token.
/// ///
public func getHiddenTokensToRight(_ tokenIndex: Int, _ channel: Int) throws -> Array<Token>? { public func getHiddenTokensToRight(_ tokenIndex: Int, _ channel: Int = -1) throws -> [Token]? {
try lazyInit() try lazyInit()
if tokenIndex < 0 || tokenIndex >= tokens.count { if tokenIndex < 0 || tokenIndex >= tokens.count {
throw ANTLRError.indexOutOfBounds(msg: "\(tokenIndex) not in 0..\(tokens.count - 1)") throw ANTLRError.indexOutOfBounds(msg: "\(tokenIndex) not in 0 ..< \(tokens.count)")
} }
let nextOnChannel: Int = let nextOnChannel = try nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL)
try nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL) let from = tokenIndex + 1
var to: Int let to: Int
let from: Int = tokenIndex + 1
// if none onchannel to right, nextOnChannel=-1 so set to = last token // if none onchannel to right, nextOnChannel=-1 so set to = last token
if nextOnChannel == -1 { if nextOnChannel == -1 {
to = size() - 1 to = size() - 1
} else { }
else {
to = nextOnChannel to = nextOnChannel
} }
return filterForChannel(from, to, channel) return filterForChannel(from, to, channel)
} }
///
/// Collect all hidden tokens (any off-default channel) to the right of
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL
/// or EOF.
///
public func getHiddenTokensToRight(_ tokenIndex: Int) throws -> Array<Token>? {
return try getHiddenTokensToRight(tokenIndex, -1)
}
/// ///
/// Collect all tokens on specified channel to the left of /// Collect all tokens on specified channel to the left of
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL. /// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
/// If channel is -1, find any non default channel token. /// If channel is -1, find any non default channel token.
/// ///
public func getHiddenTokensToLeft(_ tokenIndex: Int, _ channel: Int) throws -> Array<Token>? { public func getHiddenTokensToLeft(_ tokenIndex: Int, _ channel: Int = -1) throws -> [Token]? {
try lazyInit() try lazyInit()
if tokenIndex < 0 || tokenIndex >= tokens.count { if tokenIndex < 0 || tokenIndex >= tokens.count {
throw ANTLRError.indexOutOfBounds(msg: "\(tokenIndex) not in 0..\(tokens.count - 1)") throw ANTLRError.indexOutOfBounds(msg: "\(tokenIndex) not in 0 ..< \(tokens.count)")
} }
if tokenIndex == 0 { if tokenIndex == 0 {
@ -425,26 +412,16 @@ public class BufferedTokenStream: TokenStream {
return nil return nil
} }
let prevOnChannel: Int = let prevOnChannel = try previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL)
try previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL)
if prevOnChannel == tokenIndex - 1 { if prevOnChannel == tokenIndex - 1 {
return nil return nil
} }
// if none onchannel to left, prevOnChannel=-1 then from=0 // if none onchannel to left, prevOnChannel=-1 then from=0
let from: Int = prevOnChannel + 1 let from = prevOnChannel + 1
let to: Int = tokenIndex - 1 let to = tokenIndex - 1
return filterForChannel(from, to, channel) return filterForChannel(from, to, channel)
} }
///
/// Collect all hidden tokens (any off-default channel) to the left of
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
///
public func getHiddenTokensToLeft(_ tokenIndex: Int) throws -> [Token]? {
return try getHiddenTokensToLeft(tokenIndex, -1)
}
internal func filterForChannel(_ from: Int, _ to: Int, _ channel: Int) -> [Token]? { internal func filterForChannel(_ from: Int, _ to: Int, _ channel: Int) -> [Token]? {
var hidden = [Token]() var hidden = [Token]()
for t in tokens[from...to] { for t in tokens[from...to] {
@ -478,17 +455,13 @@ public class BufferedTokenStream: TokenStream {
public func getText(_ interval: Interval) throws -> String { public func getText(_ interval: Interval) throws -> String {
let start = interval.a let start = interval.a
var stop = interval.b if start < 0 {
if start < 0 || stop < 0 {
return "" return ""
} }
try fill() try fill()
if stop >= tokens.count { let stop = min(tokens.count, interval.b + 1)
stop = tokens.count - 1
}
var buf = "" var buf = ""
for t in tokens[start...stop] { for t in tokens[start ..< stop] {
if t.getType() == BufferedTokenStream.EOF { if t.getType() == BufferedTokenStream.EOF {
break break
} }

View File

@ -79,10 +79,10 @@ public class ListTokenSource: TokenSource {
else if let eofToken = eofToken { else if let eofToken = eofToken {
return eofToken.getCharPositionInLine() return eofToken.getCharPositionInLine()
} }
else if tokens.count > 0 { else if !tokens.isEmpty {
// have to calculate the result from the line/column of the previous // have to calculate the result from the line/column of the previous
// token, along with the text of the token. // token, along with the text of the token.
let lastToken = tokens[tokens.count - 1] let lastToken = tokens.last!
if let tokenText = lastToken.getText() { if let tokenText = lastToken.getText() {
if let lastNewLine = tokenText.lastIndex(of: "\n") { if let lastNewLine = tokenText.lastIndex(of: "\n") {
@ -93,10 +93,11 @@ public class ListTokenSource: TokenSource {
lastToken.getStopIndex() - lastToken.getStopIndex() -
lastToken.getStartIndex() + 1) lastToken.getStartIndex() + 1)
} }
else {
// only reach this if tokens is empty, meaning EOF occurs at the first // only reach this if tokens is empty, meaning EOF occurs at the first
// position in the input // position in the input
return 0 return 0
}
} }
public func nextToken() -> Token { public func nextToken() -> Token {
@ -130,33 +131,32 @@ public class ListTokenSource: TokenSource {
public func getLine() -> Int { public func getLine() -> Int {
if i < tokens.count { if i < tokens.count {
return tokens[i].getLine() return tokens[i].getLine()
} else { }
if let eofToken = eofToken { else if let eofToken = eofToken {
return eofToken.getLine() return eofToken.getLine()
} else { }
if tokens.count > 0 { else if !tokens.isEmpty {
// have to calculate the result from the line/column of the previous // have to calculate the result from the line/column of the previous
// token, along with the text of the token. // token, along with the text of the token.
let lastToken = tokens[tokens.count - 1] let lastToken = tokens.last!
var line = lastToken.getLine() var line = lastToken.getLine()
if let tokenText = lastToken.getText() { if let tokenText = lastToken.getText() {
for c in tokenText { for c in tokenText {
if c == "\n" { if c == "\n" {
line += 1 line += 1
}
}
} }
// if no text is available, assume the token did not contain any newline characters.
return line
} }
} }
}
// only reach this if tokens is empty, meaning EOF occurs at the first // if no text is available, assume the token did not contain any newline characters.
// position in the input return line
return 1 }
else {
// only reach this if tokens is empty, meaning EOF occurs at the first
// position in the input
return 1
}
} }
public func getInputStream() -> CharStream? { public func getInputStream() -> CharStream? {
@ -166,8 +166,8 @@ public class ListTokenSource: TokenSource {
else if let eofToken = eofToken { else if let eofToken = eofToken {
return eofToken.getInputStream() return eofToken.getInputStream()
} }
else if tokens.count > 0 { else if !tokens.isEmpty {
return tokens[tokens.count - 1].getInputStream() return tokens.last!.getInputStream()
} }
// no input stream information is available // no input stream information is available

View File

@ -12,22 +12,22 @@ public class UnbufferedTokenStream: TokenStream {
/// we keep adding to buffer. Otherwise, _#consume consume()_ resets so /// we keep adding to buffer. Otherwise, _#consume consume()_ resets so
/// we start filling at index 0 again. /// we start filling at index 0 again.
/// ///
internal var tokens: [Token] internal var tokens = [Token]()
/// ///
/// The number of tokens currently in _#tokens tokens_. /// The number of tokens currently in `self.tokens`.
/// ///
/// This is not the buffer capacity, that's `tokens.length`. /// This is not the buffer capacity, that's `self.tokens.count`.
/// ///
internal var n: Int internal var n = 0
/// ///
/// 0..n-1 index into _#tokens tokens_ of next token. /// `0...n-1` index into `self.tokens` of next token.
/// ///
/// The `LT(1)` token is `tokens[p]`. If `p == n`, we are /// The `LT(1)` token is `tokens[p]`. If `p == n`, we are
/// out of buffered tokens. /// out of buffered tokens.
/// ///
internal var p: Int = 0 internal var p = 0
/// ///
/// Count up with _#mark mark()_ and down with /// Count up with _#mark mark()_ and down with
@ -35,7 +35,7 @@ public class UnbufferedTokenStream: TokenStream {
/// `numMarkers` reaches 0 and we reset the buffer. Copy /// `numMarkers` reaches 0 and we reset the buffer. Copy
/// `tokens[p]..tokens[n-1]` to `tokens[0]..tokens[(n-1)-p]`. /// `tokens[p]..tokens[n-1]` to `tokens[0]..tokens[(n-1)-p]`.
/// ///
internal var numMarkers: Int = 0 internal var numMarkers = 0
/// ///
/// This is the `LT(-1)` token for the current position. /// This is the `LT(-1)` token for the current position.
@ -56,24 +56,18 @@ public class UnbufferedTokenStream: TokenStream {
/// This value is used to set the token indexes if the stream provides tokens /// This value is used to set the token indexes if the stream provides tokens
/// that implement _org.antlr.v4.runtime.WritableToken_. /// that implement _org.antlr.v4.runtime.WritableToken_.
/// ///
internal var currentTokenIndex: Int = 0 internal var currentTokenIndex = 0
public convenience init(_ tokenSource: TokenSource) throws {
try self.init(tokenSource, 256) public init(_ tokenSource: TokenSource) throws {
}
//TODO: bufferSize don't be use
public init(_ tokenSource: TokenSource, _ bufferSize: Int) throws {
self.tokenSource = tokenSource self.tokenSource = tokenSource
//tokens = [Token](count: bufferSize, repeatedValue: Token) ;
tokens = [Token]()
n = 0
try fill(1) // prime the pump try fill(1) // prime the pump
} }
public func get(_ i: Int) throws -> Token { public func get(_ i: Int) throws -> Token {
// get absolute index // get absolute index
let bufferStartIndex: Int = getBufferStartIndex() let bufferStartIndex = getBufferStartIndex()
if i < bufferStartIndex || i >= bufferStartIndex + n { if i < bufferStartIndex || i >= bufferStartIndex + n {
throw ANTLRError.indexOutOfBounds(msg: "get(\(i)) outside buffer: \(bufferStartIndex)..\(bufferStartIndex + n)") throw ANTLRError.indexOutOfBounds(msg: "get(\(i)) outside buffer: \(bufferStartIndex)..\(bufferStartIndex + n)")
} }
@ -103,7 +97,7 @@ public class UnbufferedTokenStream: TokenStream {
public func LA(_ i: Int) throws -> Int { public func LA(_ i: Int) throws -> Int {
return try LT(i)!.getType() return try LT(i)!.getType()
} }
@ -184,8 +178,8 @@ public class UnbufferedTokenStream: TokenStream {
//tokens = Arrays.copyOf(tokens, tokens.length * 2); //tokens = Arrays.copyOf(tokens, tokens.length * 2);
} }
if t is WritableToken { if let wt = t as? WritableToken {
(t as! WritableToken).setTokenIndex(getBufferStartIndex() + n) wt.setTokenIndex(getBufferStartIndex() + n)
} }
tokens[n] = t tokens[n] = t
@ -205,14 +199,14 @@ public class UnbufferedTokenStream: TokenStream {
lastTokenBufferStart = lastToken lastTokenBufferStart = lastToken
} }
let mark: Int = -numMarkers - 1 let mark = -numMarkers - 1
numMarkers += 1 numMarkers += 1
return mark return mark
} }
public func release(_ marker: Int) throws { public func release(_ marker: Int) throws {
let expectedMark: Int = -numMarkers let expectedMark = -numMarkers
if marker != expectedMark { if marker != expectedMark {
throw ANTLRError.illegalState(msg: "release() called with an invalid marker.") throw ANTLRError.illegalState(msg: "release() called with an invalid marker.")
} }
@ -224,7 +218,6 @@ public class UnbufferedTokenStream: TokenStream {
// Copy tokens[p]..tokens[n-1] to tokens[0]..tokens[(n-1)-p], reset ptrs // Copy tokens[p]..tokens[n-1] to tokens[0]..tokens[(n-1)-p], reset ptrs
// p is last valid token; move nothing if p==n as we have no valid char // p is last valid token; move nothing if p==n as we have no valid char
tokens = Array(tokens[p ... n - 1]) tokens = Array(tokens[p ... n - 1])
//System.arraycopy(tokens, p, tokens, 0, n - p); // shift n-p tokens from p to 0
n = n - p n = n - p
p = 0 p = 0
} }
@ -251,16 +244,14 @@ public class UnbufferedTokenStream: TokenStream {
index = min(index, getBufferStartIndex() + n - 1) index = min(index, getBufferStartIndex() + n - 1)
} }
let bufferStartIndex: Int = getBufferStartIndex() let bufferStartIndex = getBufferStartIndex()
let i: Int = index - bufferStartIndex let i = index - bufferStartIndex
if i < 0 { if i < 0 {
throw ANTLRError.illegalState(msg: "cannot seek to negative index \(index)") throw ANTLRError.illegalState(msg: "cannot seek to negative index \(index)")
} else { }
if i >= n { else if i >= n {
throw ANTLRError.unsupportedOperation(msg: "seek to index outside buffer: \(index) not in \(bufferStartIndex)..\(bufferStartIndex + n)") throw ANTLRError.unsupportedOperation(msg: "seek to index outside buffer: \(index) not in \(bufferStartIndex)..<\(bufferStartIndex + n)")
}
} }
p = i p = i
@ -290,7 +281,7 @@ public class UnbufferedTokenStream: TokenStream {
let start = interval.a let start = interval.a
let stop = interval.b let stop = interval.b
if start < bufferStartIndex || stop > bufferStopIndex { if start < bufferStartIndex || stop > bufferStopIndex {
throw ANTLRError.unsupportedOperation(msg: "interval \(interval) not in token buffer window: \(bufferStartIndex)..bufferStopIndex)") throw ANTLRError.unsupportedOperation(msg: "interval \(interval) not in token buffer window: \(bufferStartIndex)...\(bufferStopIndex)")
} }
let a = start - bufferStartIndex let a = start - bufferStartIndex