Removing dead code, malformed documentations, etc.
This commit is contained in:
parent
0ff5ad6f4c
commit
0137218930
|
@ -10,7 +10,7 @@ public protocol ANTLRErrorListener: class {
|
|||
/// messages. This listener's job is simply to emit a computed message,
|
||||
/// though it has enough information to create its own message in many cases.
|
||||
///
|
||||
/// <p>The {@link org.antlr.v4.runtime.RecognitionException} is non-null for all syntax errors except
|
||||
/// <p>The {@link RecognitionException} is non-null for all syntax errors except
|
||||
/// when we discover mismatched token errors that we can recover from
|
||||
/// in-line, without returning from the surrounding rule (via the single
|
||||
/// token insertion and deletion mechanism).</p>
|
||||
|
@ -40,7 +40,7 @@ public protocol ANTLRErrorListener: class {
|
|||
_ line: Int,
|
||||
_ charPositionInLine: Int,
|
||||
_ msg: String,
|
||||
_ e: AnyObject?// RecognitionException?
|
||||
_ e: AnyObject?
|
||||
)
|
||||
|
||||
/// This method is called by the parser when a full-context prediction
|
||||
|
|
|
@ -36,10 +36,10 @@ public protocol ANTLRErrorStrategy {
|
|||
/// for calling {@link org.antlr.v4.runtime.Parser#notifyErrorListeners} as appropriate.</p>
|
||||
///
|
||||
/// - parameter recognizer: the parser instance
|
||||
/// - org.antlr.v4.runtime.RecognitionException if the error strategy was not able to
|
||||
/// - throws: _RecognitionException_ if the error strategy was not able to
|
||||
/// recover from the unexpected input symbol
|
||||
@discardableResult
|
||||
func recoverInline(_ recognizer: Parser) throws -> Token // RecognitionException;
|
||||
func recoverInline(_ recognizer: Parser) throws -> Token
|
||||
|
||||
/// This method is called to recover from exception {@code e}. This method is
|
||||
/// called after {@link #reportError} by the default exception handler
|
||||
|
@ -49,9 +49,9 @@ public protocol ANTLRErrorStrategy {
|
|||
///
|
||||
/// - parameter recognizer: the parser instance
|
||||
/// - parameter e: the recognition exception to recover from
|
||||
/// - org.antlr.v4.runtime.RecognitionException if the error strategy could not recover from
|
||||
/// - throws: _RecognitionException_ if the error strategy could not recover from
|
||||
/// the recognition exception
|
||||
func recover(_ recognizer: Parser, _ e: AnyObject) throws // RecognitionException;
|
||||
func recover(_ recognizer: Parser, _ e: AnyObject) throws
|
||||
|
||||
/// This method provides the error handler with an opportunity to handle
|
||||
/// syntactic or semantic errors in the input stream before they result in a
|
||||
|
@ -67,10 +67,10 @@ public protocol ANTLRErrorStrategy {
|
|||
/// - seealso: org.antlr.v4.runtime.DefaultErrorStrategy#sync
|
||||
///
|
||||
/// - parameter recognizer: the parser instance
|
||||
/// - org.antlr.v4.runtime.RecognitionException if an error is detected by the error
|
||||
/// - throws: _RecognitionException_ if an error is detected by the error
|
||||
/// strategy but cannot be automatically recovered at the current state in
|
||||
/// the parsing process
|
||||
func sync(_ recognizer: Parser) throws // RecognitionException;
|
||||
func sync(_ recognizer: Parser) throws
|
||||
|
||||
/// Tests whether or not recognizer} is in the process of recovering
|
||||
/// from an error. In error recovery mode, {@link org.antlr.v4.runtime.Parser#consume} adds
|
||||
|
|
|
@ -10,7 +10,6 @@ public class ANTLRFileStream: ANTLRInputStream {
|
|||
internal var fileName: String
|
||||
|
||||
public convenience override init(_ fileName: String) {
|
||||
// throws; IOException
|
||||
self.init(fileName, nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -39,76 +39,11 @@ public class ANTLRInputStream: CharStream {
|
|||
self.data = data
|
||||
self.n = numberOfActualCharsInArray
|
||||
}
|
||||
/// public convenience init(_ r : Reader) throws; IOException {
|
||||
/// self.init(r, INITIAL_BUFFER_SIZE, READ_BUFFER_SIZE);
|
||||
/// }
|
||||
///
|
||||
/// public convenience init(_ r : Reader, _ initialSize : Int) throws; IOException {
|
||||
/// self.init(r, initialSize, READ_BUFFER_SIZE);
|
||||
/// }
|
||||
///
|
||||
/// public init(_ r : Reader, _ initialSize : Int, _ readChunkSize : Int) throws; IOException {
|
||||
/// load(r, initialSize, readChunkSize);
|
||||
/// }
|
||||
///
|
||||
/// public convenience init(_ input : InputStream) throws; IOException {
|
||||
/// self.init(InputStreamReader(input), INITIAL_BUFFER_SIZE);
|
||||
/// }
|
||||
///
|
||||
/// public convenience init(_ input : InputStream, _ initialSize : Int) throws; IOException {
|
||||
/// self.init(InputStreamReader(input), initialSize);
|
||||
/// }
|
||||
///
|
||||
/// public convenience init(_ input : InputStream, _ initialSize : Int, _ readChunkSize : Int) throws; IOException {
|
||||
/// self.init(InputStreamReader(input), initialSize, readChunkSize);
|
||||
/// }
|
||||
///
|
||||
/// public func load(r : Reader, _ size : Int, _ readChunkSize : Int)
|
||||
/// throws; IOException
|
||||
/// {
|
||||
/// if ( r==nil ) {
|
||||
/// return;
|
||||
/// }
|
||||
/// if ( size<=0 ) {
|
||||
/// size = INITIAL_BUFFER_SIZE;
|
||||
/// }
|
||||
/// if ( readChunkSize<=0 ) {
|
||||
/// readChunkSize = READ_BUFFER_SIZE;
|
||||
/// }
|
||||
/// // print("load "+size+" in chunks of "+readChunkSize);
|
||||
/// try {
|
||||
/// // alloc initial buffer size.
|
||||
/// data = new char[size];
|
||||
/// // read all the data in chunks of readChunkSize
|
||||
/// var numRead : Int=0;
|
||||
/// var p : Int = 0;
|
||||
/// do {
|
||||
/// if ( p+readChunkSize > data.length ) { // overflow?
|
||||
/// // print("### overflow p="+p+", data.length="+data.length);
|
||||
/// data = Arrays.copyOf(data, data.length * 2);
|
||||
/// }
|
||||
/// numRead = r.read(data, p, readChunkSize);
|
||||
/// // print("read "+numRead+" chars; p was "+p+" is now "+(p+numRead));
|
||||
/// p += numRead;
|
||||
/// } while (numRead!=-1); // while not EOF
|
||||
/// // set the actual size of the data available;
|
||||
/// // EOF subtracted one above in p+=numRead; add one back
|
||||
/// n = p+1;
|
||||
/// //print("n="+n);
|
||||
/// }
|
||||
/// finally {
|
||||
/// r.close();
|
||||
/// }
|
||||
/// }
|
||||
/// Reset the stream so that it's in the same state it was
|
||||
/// when the object was created *except* the data array is not
|
||||
/// touched.
|
||||
|
||||
public func reset() {
|
||||
p = 0
|
||||
}
|
||||
|
||||
|
||||
public func consume() throws {
|
||||
if p >= n {
|
||||
assert(LA(1) == ANTLRInputStream.EOF, "Expected: LA(1)==IntStream.EOF")
|
||||
|
@ -124,7 +59,6 @@ public class ANTLRInputStream: CharStream {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public func LA(_ i: Int) -> Int {
|
||||
var i = i
|
||||
if i == 0 {
|
||||
|
@ -186,7 +120,6 @@ public class ANTLRInputStream: CharStream {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public func getText(_ interval: Interval) -> String {
|
||||
let start: Int = interval.a
|
||||
var stop: Int = interval.b
|
||||
|
@ -201,7 +134,6 @@ public class ANTLRInputStream: CharStream {
|
|||
return String(data[start ..< (start + count)])
|
||||
}
|
||||
|
||||
|
||||
public func getSourceName() -> String {
|
||||
guard let name = name , !name.isEmpty else {
|
||||
return ANTLRInputStream.UNKNOWN_SOURCE_NAME
|
||||
|
@ -209,7 +141,6 @@ public class ANTLRInputStream: CharStream {
|
|||
return name
|
||||
}
|
||||
|
||||
|
||||
public func toString() -> String {
|
||||
return String(data)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ open class BaseErrorListener: ANTLRErrorListener {
|
|||
_ line: Int,
|
||||
_ charPositionInLine: Int,
|
||||
_ msg: String,
|
||||
_ e: AnyObject?//RecognitionException
|
||||
_ e: AnyObject?
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ public class BufferedTokenStream: TokenStream {
|
|||
return 0
|
||||
}
|
||||
|
||||
|
||||
public func release(_ marker: Int) {
|
||||
// no resources to release
|
||||
}
|
||||
|
@ -108,8 +107,6 @@ public class BufferedTokenStream: TokenStream {
|
|||
|
||||
if try !skipEofCheck && LA(1) == BufferedTokenStream.EOF {
|
||||
throw ANTLRError.illegalState(msg: "cannot consume EOF")
|
||||
//RuntimeException("cannot consume EOF")
|
||||
//throw ANTLRError.IllegalState /* throw IllegalStateException("cannot consume EOF"); */
|
||||
}
|
||||
|
||||
if try sync(p + 1) {
|
||||
|
@ -159,7 +156,6 @@ public class BufferedTokenStream: TokenStream {
|
|||
return n
|
||||
}
|
||||
|
||||
|
||||
public func get(_ i: Int) throws -> Token {
|
||||
if i < 0 || i >= tokens.count {
|
||||
let index = tokens.count - 1
|
||||
|
@ -394,8 +390,6 @@ public class BufferedTokenStream: TokenStream {
|
|||
try lazyInit()
|
||||
if tokenIndex < 0 || tokenIndex >= tokens.count {
|
||||
throw ANTLRError.indexOutOfBounds(msg: "\(tokenIndex) not in 0..\(tokens.count - 1)")
|
||||
//RuntimeException("\(tokenIndex) not in 0..\(tokens.count-1)")
|
||||
//throw ANTLRError.IndexOutOfBounds /* throw IndexOutOfBoundsException(tokenIndex+" not in 0.."+(tokens.count-1)); */
|
||||
}
|
||||
|
||||
if tokenIndex == 0 {
|
||||
|
@ -447,13 +441,10 @@ public class BufferedTokenStream: TokenStream {
|
|||
}
|
||||
|
||||
/// Get the text of all tokens in this buffer.
|
||||
|
||||
|
||||
public func getText() throws -> String {
|
||||
return try getText(Interval.of(0, size() - 1))
|
||||
}
|
||||
|
||||
|
||||
public func getText(_ interval: Interval) throws -> String {
|
||||
let start: Int = interval.a
|
||||
var stop: Int = interval.b
|
||||
|
|
|
@ -14,11 +14,11 @@ public protocol CharStream: IntStream {
|
|||
/// - parameter interval: an interval within the stream
|
||||
/// - returns: the text of the specified interval
|
||||
///
|
||||
/// - NullPointerException if {@code interval} is {@code null}
|
||||
/// - IllegalArgumentException if {@code interval.a < 0}, or if
|
||||
/// - throws: _ANTLRError.nullPointer_ if {@code interval} is {@code null}
|
||||
/// - throws: _ANTLRError.illegalArgument_ if {@code interval.a < 0}, or if
|
||||
/// {@code interval.b < interval.a - 1}, or if {@code interval.b} lies at or
|
||||
/// past the end of the stream
|
||||
/// - UnsupportedOperationException if the stream does not support
|
||||
/// - throws: _ANTLRError.unsupportedOperation_ if the stream does not support
|
||||
/// getting the text of the specified interval
|
||||
func getText(_ interval: Interval) -> String
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
/// 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.
|
||||
|
||||
|
||||
|
||||
/// This is the default implementation of {@link org.antlr.v4.runtime.ANTLRErrorStrategy} used for
|
||||
/// error reporting and recovery in ANTLR parsers.
|
||||
|
||||
|
@ -26,11 +24,8 @@ public class DefaultErrorStrategy: ANTLRErrorStrategy {
|
|||
|
||||
internal var lastErrorStates: IntervalSet?
|
||||
|
||||
/// {@inheritDoc}
|
||||
///
|
||||
/// <p>The default implementation simply calls {@link #endErrorCondition} to
|
||||
/// ensure that the handler is not in error recovery mode.</p>
|
||||
|
||||
public func reset(_ recognizer: Parser) {
|
||||
endErrorCondition(recognizer)
|
||||
}
|
||||
|
@ -43,8 +38,6 @@ public class DefaultErrorStrategy: ANTLRErrorStrategy {
|
|||
errorRecoveryMode = true
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func inErrorRecoveryMode(_ recognizer: Parser) -> Bool {
|
||||
return errorRecoveryMode
|
||||
}
|
||||
|
@ -59,15 +52,11 @@ public class DefaultErrorStrategy: ANTLRErrorStrategy {
|
|||
lastErrorIndex = -1
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
///
|
||||
/// <p>The default implementation simply calls {@link #endErrorCondition}.</p>
|
||||
|
||||
public func reportMatch(_ recognizer: Parser) {
|
||||
endErrorCondition(recognizer)
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
///
|
||||
/// <p>The default implementation returns immediately if the handler is already
|
||||
/// in error recovery mode. Otherwise, it calls {@link #beginErrorCondition}
|
||||
|
@ -84,7 +73,6 @@ public class DefaultErrorStrategy: ANTLRErrorStrategy {
|
|||
/// <li>All other types: calls {@link org.antlr.v4.runtime.Parser#notifyErrorListeners} to report
|
||||
/// the exception</li>
|
||||
/// </ul>
|
||||
|
||||
public func reportError(_ recognizer: Parser,
|
||||
_ e: AnyObject) {
|
||||
// if we've already reported an error and have not matched a token
|
||||
|
@ -94,7 +82,6 @@ public class DefaultErrorStrategy: ANTLRErrorStrategy {
|
|||
return // don't report spurious errors
|
||||
}
|
||||
beginErrorCondition(recognizer)
|
||||
//TODO: exception handler
|
||||
if (e is NoViableAltException) {
|
||||
try! reportNoViableAlternative(recognizer, e as! NoViableAltException);
|
||||
} else {
|
||||
|
@ -112,12 +99,9 @@ public class DefaultErrorStrategy: ANTLRErrorStrategy {
|
|||
}
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
///
|
||||
/// <p>The default implementation resynchronizes the parser by consuming tokens
|
||||
/// until we find one in the resynchronization set--loosely the set of tokens
|
||||
/// that can follow the current rule.</p>
|
||||
|
||||
public func recover(_ recognizer: Parser, _ e: AnyObject) throws {
|
||||
// print("recover in "+recognizer.getRuleInvocationStack()+
|
||||
// " index="+getTokenStream(recognizer).index()+
|
||||
|
@ -507,7 +491,6 @@ public class DefaultErrorStrategy: ANTLRErrorStrategy {
|
|||
/// a CommonToken of the appropriate type. The text will be the token.
|
||||
/// If you change what tokens must be created by the lexer,
|
||||
/// override this method to create the appropriate tokens.
|
||||
|
||||
internal func getTokenStream(_ recognizer: Parser) -> TokenStream {
|
||||
return recognizer.getInputStream() as! TokenStream
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public protocol IntStream: class {
|
|||
/// filtering streams (e.g. {@link org.antlr.v4.runtime.CommonTokenStream} which distinguishes
|
||||
/// between "on-channel" and "off-channel" tokens).
|
||||
///
|
||||
/// - IllegalStateException if an attempt is made to consume the the
|
||||
/// - throws: _ANTLRError.illegalState_ if an attempt is made to consume the the
|
||||
/// end of the stream (i.e. if {@code LA(1)==}{@link #EOF EOF} before calling
|
||||
/// {@code consume}).
|
||||
func consume() throws
|
||||
|
@ -80,7 +80,7 @@ public protocol IntStream: class {
|
|||
/// calls to {@link #consume consume()} have occurred from the beginning of
|
||||
/// the stream before calling this method.</p>
|
||||
///
|
||||
/// - UnsupportedOperationException if the stream does not support
|
||||
/// - throws: _ANTLRError.unsupportedOperation_ if the stream does not support
|
||||
/// retrieving the value of the specified symbol
|
||||
func LA(_ i: Int) throws -> Int
|
||||
|
||||
|
@ -173,21 +173,20 @@ public protocol IntStream: class {
|
|||
///
|
||||
/// - parameter index: The absolute index to seek to.
|
||||
///
|
||||
/// - IllegalArgumentException if {@code index} is less than 0
|
||||
/// - UnsupportedOperationException if the stream does not support
|
||||
/// - throws: _ANTLRError.illegalArgument_ if {@code index} is less than 0
|
||||
/// - throws: _ANTLRError.unsupportedOperation_ if the stream does not support
|
||||
/// seeking to the specified index
|
||||
func seek(_ index: Int) throws
|
||||
|
||||
/// Returns the total number of symbols in the stream, including a single EOF
|
||||
/// symbol.
|
||||
///
|
||||
/// - UnsupportedOperationException if the size of the stream is
|
||||
/// - throws: _ANTLRError.unsupportedOperation_ if the size of the stream is
|
||||
/// unknown.
|
||||
func size() -> Int
|
||||
|
||||
/// Gets the name of the underlying symbol source. This method returns a
|
||||
/// non-null, non-empty string. If such a name is not known, this method
|
||||
/// returns {@link #UNKNOWN_SOURCE_NAME}.
|
||||
|
||||
func getSourceName() -> String
|
||||
}
|
||||
|
|
|
@ -384,9 +384,6 @@ open class Lexer: Recognizer<LexerATNSimulator>
|
|||
s = "<EOF>"
|
||||
}
|
||||
switch s {
|
||||
// case CommonToken.EOF :
|
||||
// s = "<EOF>";
|
||||
// break;
|
||||
case "\n":
|
||||
s = "\\n"
|
||||
case "\t":
|
||||
|
@ -408,11 +405,7 @@ open class Lexer: Recognizer<LexerATNSimulator>
|
|||
/// a token, so do the easy thing and just kill a character and hope
|
||||
/// it all works out. You can instead use the rule invocation stack
|
||||
/// to do sophisticated error recovery if you are in a fragment rule.
|
||||
//public func recover(re : RecognitionException) {
|
||||
|
||||
open func recover(_ re: AnyObject) throws {
|
||||
//System.out.println("consuming char "+(char)input.LA(1)+" during recovery");
|
||||
//re.printStackTrace();
|
||||
// TODO: Do we lose character or line position information?
|
||||
try _input!.consume()
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ public class ListTokenSource: TokenSource {
|
|||
///
|
||||
/// - parameter tokens: The collection of {@link org.antlr.v4.runtime.Token} objects to provide as a
|
||||
/// {@link org.antlr.v4.runtime.TokenSource}.
|
||||
/// - NullPointerException if {@code tokens} is {@code null}
|
||||
public convenience init(_ tokens: Array<Token>) {
|
||||
self.init(tokens, nil)
|
||||
}
|
||||
|
@ -50,16 +49,12 @@ public class ListTokenSource: TokenSource {
|
|||
/// {@code null}, {@link #getSourceName} will attempt to infer the name from
|
||||
/// the next {@link org.antlr.v4.runtime.Token} (or the previous token if the end of the input has
|
||||
/// been reached).
|
||||
///
|
||||
/// - NullPointerException if {@code tokens} is {@code null}
|
||||
public init(_ tokens: Array<Token>, _ sourceName: String?) {
|
||||
|
||||
self.tokens = tokens
|
||||
self.sourceName = sourceName
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func getCharPositionInLine() -> Int {
|
||||
if i < tokens.count {
|
||||
return tokens[i].getCharPositionInLine()
|
||||
|
@ -92,8 +87,6 @@ public class ListTokenSource: TokenSource {
|
|||
return 0
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func nextToken() -> Token {
|
||||
if i >= tokens.count {
|
||||
if eofToken == nil {
|
||||
|
@ -121,8 +114,6 @@ public class ListTokenSource: TokenSource {
|
|||
return t
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func getLine() -> Int {
|
||||
if i < tokens.count {
|
||||
return tokens[i].getLine()
|
||||
|
@ -156,8 +147,6 @@ public class ListTokenSource: TokenSource {
|
|||
return 1
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func getInputStream() -> CharStream? {
|
||||
if i < tokens.count {
|
||||
return tokens[i].getInputStream()
|
||||
|
@ -175,8 +164,6 @@ public class ListTokenSource: TokenSource {
|
|||
return nil
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func getSourceName() -> String {
|
||||
if sourceName != nil {
|
||||
return sourceName!
|
||||
|
@ -189,14 +176,10 @@ public class ListTokenSource: TokenSource {
|
|||
return "List"
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func setTokenFactory(_ factory: TokenFactory) {
|
||||
self._factory = factory
|
||||
}
|
||||
|
||||
/// {@inheritDoc}
|
||||
|
||||
public func getTokenFactory() -> TokenFactory {
|
||||
return _factory
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ public class NoViableAltException: RecognitionException<ParserATNSimulator> {
|
|||
* time the error occurred, of course the stream needs to keep a
|
||||
* buffer all of the tokens but later we might not have access to those.)
|
||||
*/
|
||||
|
||||
private final var startToken: Token
|
||||
|
||||
public convenience init(_ recognizer: Parser?) throws {
|
||||
|
|
|
@ -217,7 +217,7 @@ open class Parser: Recognizer<ParserATNSimulator> {
|
|||
* @throws org.antlr.v4.runtime.RecognitionException if the current input symbol did not match
|
||||
* a wildcard and the error strategy could not recover from the mismatched
|
||||
* symbol
|
||||
*///; RecognitionException
|
||||
*/
|
||||
@discardableResult
|
||||
public func matchWildcard() throws -> Token {
|
||||
var t: Token = try getCurrentToken()
|
||||
|
@ -330,7 +330,7 @@ open class Parser: Recognizer<ParserATNSimulator> {
|
|||
*
|
||||
* @param listener the listener to add
|
||||
*
|
||||
* @throws NullPointerException if {@code} listener is {@code null}
|
||||
* @throws _ANTLRError.nullPointer_ if listener is {@code null}
|
||||
*/
|
||||
public func addParseListener(_ listener: ParseTreeListener) {
|
||||
if _parseListeners == nil {
|
||||
|
@ -432,7 +432,7 @@ open class Parser: Recognizer<ParserATNSimulator> {
|
|||
* The ATN with bypass alternatives is expensive to create so we create it
|
||||
* lazily.
|
||||
*
|
||||
* @throws UnsupportedOperationException if the current parser does not
|
||||
* @throws _ANTLRError.unsupportedOperation_ if the current parser does not
|
||||
* implement the {@link #getSerializedATN()} method.
|
||||
*/
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
* group values such as this aggregate. The getters/setters are there to
|
||||
* satisfy the superclass interface.
|
||||
*/
|
||||
|
||||
open class ParserRuleContext: RuleContext {
|
||||
public var visited = false
|
||||
/** If we are debugging or building a parse tree for a visitor,
|
||||
|
@ -55,8 +54,6 @@ open class ParserRuleContext: RuleContext {
|
|||
*
|
||||
* This does not trace states visited during prediction.
|
||||
*/
|
||||
// public List<Integer> states;
|
||||
|
||||
public var start: Token?, stop: Token?
|
||||
|
||||
/**
|
||||
|
@ -64,7 +61,6 @@ open class ParserRuleContext: RuleContext {
|
|||
* completed, this is {@code null}.
|
||||
*/
|
||||
public var exception: AnyObject!
|
||||
//RecognitionException<ATNSimulator>!;
|
||||
|
||||
public override init() {
|
||||
super.init()
|
||||
|
@ -198,7 +194,9 @@ open class ParserRuleContext: RuleContext {
|
|||
|
||||
|
||||
override
|
||||
/** Override to make type more specific */
|
||||
/**
|
||||
* Override to make type more specific
|
||||
*/
|
||||
open func getParent() -> Tree? {
|
||||
return super.getParent()
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ public class ProxyErrorListener: ANTLRErrorListener {
|
|||
self.delegates = delegates
|
||||
}
|
||||
|
||||
//_ e : RecognitionException
|
||||
public func syntaxError<T:ATNSimulator>(_ recognizer: Recognizer<T>,
|
||||
_ offendingSymbol: AnyObject?,
|
||||
_ line: Int,
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
*/
|
||||
|
||||
public class RecognitionException<T:ATNSimulator> {
|
||||
/** The {@link org.antlr.v4.runtime.Recognizer} where this exception originated. */
|
||||
/**
|
||||
* The {@link org.antlr.v4.runtime.Recognizer} where this exception originated.
|
||||
*/
|
||||
private final var recognizer: Recognizer<T>?
|
||||
//Recognizer<AnyObject,ATNSimulator>? ;
|
||||
|
||||
|
|
|
@ -128,7 +128,6 @@ open class Recognizer<ATNInterpreter:ATNSimulator> {
|
|||
open func getSerializedATN() -> String {
|
||||
RuntimeException("there is no serialized ATN")
|
||||
fatalError()
|
||||
///throw ANTLRError.UnsupportedOperation /* throw UnsupportedOperationException("there is no /serialized ATN"); */
|
||||
}
|
||||
|
||||
/** For debugging and other purposes, might want the grammar name.
|
||||
|
@ -177,9 +176,9 @@ open class Recognizer<ATNInterpreter:ATNSimulator> {
|
|||
_interp = interpreter
|
||||
}
|
||||
|
||||
/** What is the error header, normally line/character position information? */
|
||||
//public func getErrorHeader(e : RecognitionException
|
||||
|
||||
/**
|
||||
* What is the error header, normally line/character position information?
|
||||
*/
|
||||
open func getErrorHeader(_ e: AnyObject) -> String {
|
||||
let line: Int = (e as! RecognitionException).getOffendingToken().getLine()
|
||||
let charPositionInLine: Int = (e as! RecognitionException).getOffendingToken().getCharPositionInLine()
|
||||
|
@ -222,7 +221,7 @@ open class Recognizer<ATNInterpreter:ATNSimulator> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @exception NullPointerException if {@code listener} is {@code null}.
|
||||
* @exception ANTLRError.nullPointer if {@code listener} is {@code null}.
|
||||
*/
|
||||
open func addErrorListener(_ listener: ANTLRErrorListener) {
|
||||
|
||||
|
@ -285,22 +284,18 @@ open class Recognizer<ATNInterpreter:ATNSimulator> {
|
|||
fatalError()
|
||||
}
|
||||
|
||||
|
||||
open func setInputStream(_ input: IntStream) throws {
|
||||
RuntimeException(#function + "Must be overridden")
|
||||
|
||||
}
|
||||
|
||||
|
||||
open func getTokenFactory() -> TokenFactory {
|
||||
RuntimeException(#function + "Must be overridden")
|
||||
fatalError()
|
||||
}
|
||||
|
||||
|
||||
open func setTokenFactory(_ input: TokenFactory) {
|
||||
RuntimeException(#function + "Must be overridden")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -159,50 +159,49 @@ open class RuleContext: RuleNode {
|
|||
return visitor.visitChildren(self)
|
||||
}
|
||||
|
||||
/*
|
||||
/** Call this method to view a parse tree in a dialog box visually. */
|
||||
public func inspect(parser : Parser) -> Future<JDialog> {
|
||||
var ruleNames : Array<String> = parser != nil ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
return inspect(ruleNames);
|
||||
}
|
||||
|
||||
public func inspect(ruleNames : Array<String>) -> Future<JDialog> {
|
||||
var viewer : TreeViewer = TreeViewer(ruleNames, self);
|
||||
return viewer.open();
|
||||
}
|
||||
|
||||
/** Save this tree in a postscript file */
|
||||
public func save(parser : Parser, _ fileName : String)
|
||||
throws; IOException, PrintException
|
||||
{
|
||||
var ruleNames : Array<String> = parser != nil ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
save(ruleNames, fileName);
|
||||
}
|
||||
|
||||
/** Save this tree in a postscript file using a particular font name and size */
|
||||
public func save(parser : Parser, _ fileName : String,
|
||||
_ fontName : String, _ fontSize : Int)
|
||||
throws; IOException
|
||||
{
|
||||
var ruleNames : Array<String> = parser != nil ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
save(ruleNames, fileName, fontName, fontSize);
|
||||
}
|
||||
|
||||
/** Save this tree in a postscript file */
|
||||
public func save(ruleNames : Array<String>, _ fileName : String)
|
||||
throws; IOException, PrintException
|
||||
{
|
||||
Trees.writePS(self, ruleNames, fileName);
|
||||
}
|
||||
|
||||
/** Save this tree in a postscript file using a particular font name and size */
|
||||
public func save(ruleNames : Array<String>, _ fileName : String,
|
||||
_ fontName : String, _ fontSize : Int)
|
||||
throws; IOException
|
||||
{
|
||||
Trees.writePS(self, ruleNames, fileName, fontName, fontSize);
|
||||
}
|
||||
*/
|
||||
// /** Call this method to view a parse tree in a dialog box visually. */
|
||||
// public func inspect(parser : Parser) -> Future<JDialog> {
|
||||
// var ruleNames : Array<String> = parser != nil ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
// return inspect(ruleNames);
|
||||
// }
|
||||
//
|
||||
// public func inspect(ruleNames : Array<String>) -> Future<JDialog> {
|
||||
// var viewer : TreeViewer = TreeViewer(ruleNames, self);
|
||||
// return viewer.open();
|
||||
// }
|
||||
//
|
||||
// /** Save this tree in a postscript file */
|
||||
// public func save(parser : Parser, _ fileName : String)
|
||||
// throws; IOException, PrintException
|
||||
// {
|
||||
// var ruleNames : Array<String> = parser != nil ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
// save(ruleNames, fileName);
|
||||
// }
|
||||
//
|
||||
// /** Save this tree in a postscript file using a particular font name and size */
|
||||
// public func save(parser : Parser, _ fileName : String,
|
||||
// _ fontName : String, _ fontSize : Int)
|
||||
// throws; IOException
|
||||
// {
|
||||
// var ruleNames : Array<String> = parser != nil ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
// save(ruleNames, fileName, fontName, fontSize);
|
||||
// }
|
||||
//
|
||||
// /** Save this tree in a postscript file */
|
||||
// public func save(ruleNames : Array<String>, _ fileName : String)
|
||||
// throws; IOException, PrintException
|
||||
// {
|
||||
// Trees.writePS(self, ruleNames, fileName);
|
||||
// }
|
||||
//
|
||||
// /** Save this tree in a postscript file using a particular font name and size */
|
||||
// public func save(ruleNames : Array<String>, _ fileName : String,
|
||||
// _ fontName : String, _ fontSize : Int)
|
||||
// throws; IOException
|
||||
// {
|
||||
// Trees.writePS(self, ruleNames, fileName, fontName, fontSize);
|
||||
// }
|
||||
|
||||
/** Print out a whole tree, not just a node, in LISP format
|
||||
* (root child1 .. childN). Print just a node if this is a leaf.
|
||||
* We have to know the recognizer so we can get rule names.
|
||||
|
|
|
@ -35,8 +35,8 @@ public protocol TokenStream: IntStream {
|
|||
* of the stream. Unlike {@code seek()}, this method does not adjust
|
||||
* {@code index} to point to a non-ignored symbol.</p>
|
||||
*
|
||||
* @throws IllegalArgumentException if {code index} is less than 0
|
||||
* @throws UnsupportedOperationException if the stream does not support
|
||||
* @throws ANTLRError.illegalArgument if {code index} is less than 0
|
||||
* @throws ANTLRError.unsupportedOperation if the stream does not support
|
||||
* retrieving the token at the specified index
|
||||
*/
|
||||
func get(_ index: Int) throws -> Token
|
||||
|
@ -66,7 +66,7 @@ public protocol TokenStream: IntStream {
|
|||
* @return The text of all tokens within the specified interval in this
|
||||
* stream.
|
||||
*
|
||||
* @throws NullPointerException if {@code interval} is {@code null}
|
||||
* @throws ANTLRError.nullPointer if {@code interval} is {@code null}
|
||||
*/
|
||||
func getText(_ interval: Interval) throws -> String
|
||||
|
||||
|
@ -131,7 +131,7 @@ public protocol TokenStream: IntStream {
|
|||
* @return The text of all tokens lying between the specified {@code start}
|
||||
* and {@code stop} tokens.
|
||||
*
|
||||
* @throws UnsupportedOperationException if this stream does not support
|
||||
* @throws ANTLRError.unsupportedOperation if this stream does not support
|
||||
* this method for the specified tokens
|
||||
*/
|
||||
func getText(_ start: Token?, _ stop: Token?) throws -> String
|
||||
|
|
|
@ -119,16 +119,14 @@ public class ATN {
|
|||
/// - parameter context: the full parse context
|
||||
/// - returns: The set of potentially valid input symbols which could follow the
|
||||
/// specified state in the specified context.
|
||||
/// - IllegalArgumentException if the ATN does not contain a state with
|
||||
/// - throws: _ANTLRError.illegalArgument_ if the ATN does not contain a state with
|
||||
/// number {@code stateNumber}
|
||||
public func getExpectedTokens(_ stateNumber: Int, _ context: RuleContext) throws -> IntervalSet {
|
||||
if stateNumber < 0 || stateNumber >= states.count {
|
||||
throw ANTLRError.illegalArgument(msg: "Invalid state number.")
|
||||
/// throw IllegalArgumentException("Invalid state number.");
|
||||
}
|
||||
|
||||
var ctx: RuleContext? = context
|
||||
//TODO: s may be nil
|
||||
let s: ATNState = states[stateNumber]!
|
||||
var following: IntervalSet = try nextTokens(s)
|
||||
if !following.contains(CommonToken.EPSILON) {
|
||||
|
|
|
@ -20,7 +20,6 @@ open class ATNSimulator {
|
|||
|
||||
|
||||
/// Must distinguish between missing edge and edge we know leads nowhere
|
||||
|
||||
public static let ERROR: DFAState = {
|
||||
let error = DFAState(ATNConfigSet())
|
||||
error.stateNumber = Int.max
|
||||
|
@ -50,11 +49,6 @@ open class ATNSimulator {
|
|||
/// so it's not worth the complexity.</p>
|
||||
internal final var sharedContextCache: PredictionContextCache?
|
||||
|
||||
//static; {
|
||||
//ERROR = DFAState(ATNConfigSet());
|
||||
// ERROR.stateNumber = Integer.MAX_VALUE;
|
||||
//}
|
||||
|
||||
public init(_ atn: ATN,
|
||||
_ sharedContextCache: PredictionContextCache) {
|
||||
|
||||
|
@ -71,7 +65,7 @@ open class ATNSimulator {
|
|||
/// performance (but not accuracy) of other parsers which are being used
|
||||
/// concurrently.
|
||||
///
|
||||
/// - UnsupportedOperationException if the current instance does not
|
||||
/// - throws: ANTLRError.unsupportedOperation if the current instance does not
|
||||
/// support clearing the DFA.
|
||||
///
|
||||
/// - 4.3
|
||||
|
@ -100,50 +94,35 @@ open class ATNSimulator {
|
|||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#deserialize} instead.
|
||||
////@Deprecated
|
||||
public static func deserialize(_ data: [Character]) throws -> ATN {
|
||||
return try ATNDeserializer().deserialize(data)
|
||||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#checkCondition(boolean)} instead.
|
||||
////@Deprecated
|
||||
public static func checkCondition(_ condition: Bool) throws {
|
||||
try ATNDeserializer().checkCondition(condition)
|
||||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#checkCondition(boolean, String)} instead.
|
||||
////@Deprecated
|
||||
public static func checkCondition(_ condition: Bool, _ message: String) throws {
|
||||
try ATNDeserializer().checkCondition(condition, message)
|
||||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#toInt} instead.
|
||||
////@Deprecated
|
||||
public func toInt(_ c: Character) -> Int {
|
||||
return toInt(c)
|
||||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#toInt32} instead.
|
||||
////@Deprecated
|
||||
public func toInt32(_ data: [Character], _ offset: Int) -> Int {
|
||||
return toInt32(data, offset)
|
||||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#toLong} instead.
|
||||
////@Deprecated
|
||||
public func toLong(_ data: [Character], _ offset: Int) -> Int64 {
|
||||
return toLong(data, offset)
|
||||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#toUUID} instead.
|
||||
////@Deprecated
|
||||
//public class func toUUID(data : [Character], _ offset : Int) -> NSUUID {
|
||||
//return ATNDeserializer.toUUID(data, offset);
|
||||
//}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#edgeFactory} instead.
|
||||
////@Deprecated
|
||||
|
||||
public static func edgeFactory(_ atn: ATN,
|
||||
_ type: Int, _ src: Int, _ trg: Int,
|
||||
_ arg1: Int, _ arg2: Int, _ arg3: Int,
|
||||
|
@ -152,7 +131,6 @@ open class ATNSimulator {
|
|||
}
|
||||
|
||||
/// - Use {@link org.antlr.v4.runtime.atn.ATNDeserializer#stateFactory} instead.
|
||||
////@Deprecated
|
||||
public static func stateFactory(_ type: Int, _ ruleIndex: Int) throws -> ATNState {
|
||||
return try ATNDeserializer().stateFactory(type, ruleIndex)!
|
||||
}
|
||||
|
|
|
@ -1924,16 +1924,6 @@ open class ParserATNSimulator: ATNSimulator {
|
|||
}
|
||||
|
||||
internal static func getUniqueAlt(_ configs: ATNConfigSet) -> Int {
|
||||
// var alt: Int = ATN.INVALID_ALT_NUMBER
|
||||
// for c: ATNConfig in configs.configs {
|
||||
// if alt == ATN.INVALID_ALT_NUMBER {
|
||||
// alt = c.alt // found first alt
|
||||
// } else {
|
||||
// if c.alt != alt {
|
||||
// return ATN.INVALID_ALT_NUMBER
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
let alt = configs.getUniqueAlt()
|
||||
return alt
|
||||
}
|
||||
|
|
|
@ -66,9 +66,8 @@ public class DFA: CustomStringConvertible {
|
|||
/// - returns: The start state corresponding to the specified precedence, or
|
||||
/// {@code null} if no start state exists for the specified precedence.
|
||||
///
|
||||
/// - IllegalStateException if this is not a precedence DFA.
|
||||
/// - throws: _ANTLRError.illegalState_ if this is not a precedence DFA.
|
||||
/// - seealso: #isPrecedenceDfa()
|
||||
////@SuppressWarnings("null")
|
||||
public final func getPrecedenceStartState(_ precedence: Int) throws -> DFAState? {
|
||||
if !isPrecedenceDfa() {
|
||||
throw ANTLRError.illegalState(msg: "Only precedence DFAs may contain a precedence start state.")
|
||||
|
@ -91,9 +90,8 @@ public class DFA: CustomStringConvertible {
|
|||
/// - parameter startState: The start state corresponding to the specified
|
||||
/// precedence.
|
||||
///
|
||||
/// - IllegalStateException if this is not a precedence DFA.
|
||||
/// - throws: _ANTLRError.illegalState_ if this is not a precedence DFA.
|
||||
/// - seealso: #isPrecedenceDfa()
|
||||
////@SuppressWarnings({"SynchronizeOnNonFinalField", "null"})
|
||||
public final func setPrecedenceStartState(_ precedence: Int, _ startState: DFAState) throws {
|
||||
if !isPrecedenceDfa() {
|
||||
throw ANTLRError.illegalState(msg: "Only precedence DFAs may contain a precedence start state.")
|
||||
|
@ -121,11 +119,10 @@ public class DFA: CustomStringConvertible {
|
|||
/// - parameter precedenceDfa: {@code true} if this is a precedence DFA; otherwise,
|
||||
/// {@code false}
|
||||
///
|
||||
/// - UnsupportedOperationException if {@code precedenceDfa} does not
|
||||
/// - throws: ANTLRError.unsupportedOperation if {@code precedenceDfa} does not
|
||||
/// match the value of {@link #isPrecedenceDfa} for the current DFA.
|
||||
///
|
||||
/// - This method no longer performs any action.
|
||||
////@Deprecated
|
||||
/// - note: This method no longer performs any action.
|
||||
public final func setPrecedenceDfa(_ precedenceDfa: Bool) throws {
|
||||
if precedenceDfa != isPrecedenceDfa() {
|
||||
throw ANTLRError.unsupportedOperation(msg: "The precedenceDfa field cannot change after a DFA is constructed.")
|
||||
|
@ -134,7 +131,6 @@ public class DFA: CustomStringConvertible {
|
|||
}
|
||||
|
||||
/// Return a list of all states in this DFA, ordered by state number.
|
||||
|
||||
public func getStates() -> Array<DFAState> {
|
||||
var result: Array<DFAState> = Array<DFAState>(states.keys)
|
||||
|
||||
|
@ -155,7 +151,6 @@ public class DFA: CustomStringConvertible {
|
|||
}
|
||||
|
||||
/// - Use {@link #toString(org.antlr.v4.runtime.Vocabulary)} instead.
|
||||
////@Deprecated
|
||||
public func toString(_ tokenNames: [String?]?) -> String {
|
||||
if s0 == nil {
|
||||
return ""
|
||||
|
|
|
@ -31,15 +31,15 @@ import Foundation
|
|||
///
|
||||
/// <p>Unless otherwise noted, passing a null parameter to any of the
|
||||
/// methods in a {@code BitSet} will result in a
|
||||
/// {@code NullPointerException}.
|
||||
/// {@code ANTLRError.nullPointer}.
|
||||
///
|
||||
/// <p>A {@code BitSet} is not safe for multithreaded use without
|
||||
/// external synchronization.
|
||||
///
|
||||
/// - Arthur van Hoff
|
||||
/// - Michael McCloskey
|
||||
/// - Martin Buchholz
|
||||
/// - JDK1.0
|
||||
/// - note: Arthur van Hoff
|
||||
/// - note: Michael McCloskey
|
||||
/// - note: Martin Buchholz
|
||||
/// - note: JDK1.0
|
||||
|
||||
public class BitSet: Hashable, CustomStringConvertible {
|
||||
/// BitSets are packed into arrays of "words." Currently a word is
|
||||
|
@ -119,7 +119,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// {@code nbits-1}. All bits are initially {@code false}.
|
||||
///
|
||||
/// - parameter nbits: the initial size of the bit set
|
||||
/// - NegativeArraySizeException if the specified initial size
|
||||
/// - throws: _ANTLRError.negativeArraySize_ if the specified initial size
|
||||
/// is negative
|
||||
public init(_ nbits: Int) throws {
|
||||
// nbits can't be negative; size 0 is OK
|
||||
|
@ -158,7 +158,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - returns: a long array containing a little-endian representation
|
||||
/// of all the bits in this bit set
|
||||
/// - 1.7
|
||||
public func toLongArray() -> [Int64] {
|
||||
return copyOf(words, wordsInUse)
|
||||
}
|
||||
|
@ -214,8 +213,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// current value.
|
||||
///
|
||||
/// - parameter bitIndex: the index of the bit to flip
|
||||
/// - IndexOutOfBoundsException if the specified index is negative
|
||||
/// - 1.4
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if the specified index is negative
|
||||
public func flip(_ bitIndex: Int) throws {
|
||||
if bitIndex < 0 {
|
||||
throw ANTLRError.indexOutOfBounds(msg: "bitIndex < 0: \(bitIndex)")
|
||||
|
@ -237,10 +235,9 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - parameter fromIndex: index of the first bit to flip
|
||||
/// - parameter toIndex: index after the last bit to flip
|
||||
/// - IndexOutOfBoundsException if {@code fromIndex} is negative,
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if {@code fromIndex} is negative,
|
||||
/// or {@code toIndex} is negative, or {@code fromIndex} is
|
||||
/// larger than {@code toIndex}
|
||||
/// - 1.4
|
||||
public func flip(_ fromIndex: Int, _ toIndex: Int) throws {
|
||||
try BitSet.checkRange(fromIndex, toIndex)
|
||||
|
||||
|
@ -280,8 +277,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// Sets the bit at the specified index to {@code true}.
|
||||
///
|
||||
/// - parameter bitIndex: a bit index
|
||||
/// - IndexOutOfBoundsException if the specified index is negative
|
||||
/// - JDK1.0
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if the specified index is negative
|
||||
public func set(_ bitIndex: Int) throws {
|
||||
if bitIndex < 0 {
|
||||
throw ANTLRError.indexOutOfBounds(msg: "bitIndex < 0: \(bitIndex)")
|
||||
|
@ -300,8 +296,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - parameter bitIndex: a bit index
|
||||
/// - parameter value: a boolean value to set
|
||||
/// - IndexOutOfBoundsException if the specified index is negative
|
||||
/// - 1.4
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if the specified index is negative
|
||||
public func set(_ bitIndex: Int, _ value: Bool) throws {
|
||||
if value {
|
||||
try set(bitIndex)
|
||||
|
@ -315,10 +310,9 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - parameter fromIndex: index of the first bit to be set
|
||||
/// - parameter toIndex: index after the last bit to be set
|
||||
/// - IndexOutOfBoundsException if {@code fromIndex} is negative,
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if {@code fromIndex} is negative,
|
||||
/// or {@code toIndex} is negative, or {@code fromIndex} is
|
||||
/// larger than {@code toIndex}
|
||||
/// - 1.4
|
||||
public func set(_ fromIndex: Int, _ toIndex: Int) throws {
|
||||
try BitSet.checkRange(fromIndex, toIndex)
|
||||
|
||||
|
@ -361,10 +355,9 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// - parameter fromIndex: index of the first bit to be set
|
||||
/// - parameter toIndex: index after the last bit to be set
|
||||
/// - parameter value: value to set the selected bits to
|
||||
/// - IndexOutOfBoundsException if {@code fromIndex} is negative,
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if {@code fromIndex} is negative,
|
||||
/// or {@code toIndex} is negative, or {@code fromIndex} is
|
||||
/// larger than {@code toIndex}
|
||||
/// - 1.4
|
||||
public func set(_ fromIndex: Int, _ toIndex: Int, _ value: Bool) throws {
|
||||
if value {
|
||||
try set(fromIndex, toIndex)
|
||||
|
@ -376,7 +369,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// Sets the bit specified by the index to {@code false}.
|
||||
///
|
||||
/// - parameter bitIndex: the index of the bit to be cleared
|
||||
/// - IndexOutOfBoundsException if the specified index is negative
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if the specified index is negative
|
||||
/// - JDK1.0
|
||||
public func clear(_ bitIndex: Int) throws {
|
||||
if bitIndex < 0 {
|
||||
|
@ -398,10 +391,9 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - parameter fromIndex: index of the first bit to be cleared
|
||||
/// - parameter toIndex: index after the last bit to be cleared
|
||||
/// - IndexOutOfBoundsException if {@code fromIndex} is negative,
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if {@code fromIndex} is negative,
|
||||
/// or {@code toIndex} is negative, or {@code fromIndex} is
|
||||
/// larger than {@code toIndex}
|
||||
/// - 1.4
|
||||
public func clear(_ fromIndex: Int, _ toIndex: Int) throws {
|
||||
var toIndex = toIndex
|
||||
try BitSet.checkRange(fromIndex, toIndex)
|
||||
|
@ -447,8 +439,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
}
|
||||
|
||||
/// Sets all of the bits in this BitSet to {@code false}.
|
||||
///
|
||||
/// - 1.4
|
||||
public func clear() {
|
||||
while wordsInUse > 0 {
|
||||
wordsInUse -= 1
|
||||
|
@ -463,7 +453,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - parameter bitIndex: the bit index
|
||||
/// - returns: the value of the bit with the specified index
|
||||
/// - IndexOutOfBoundsException if the specified index is negative
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if the specified index is negative
|
||||
public func get(_ bitIndex: Int) throws -> Bool {
|
||||
if bitIndex < 0 {
|
||||
throw ANTLRError.indexOutOfBounds(msg: "bitIndex < 0: \(bitIndex)")
|
||||
|
@ -483,10 +473,9 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// - parameter fromIndex: index of the first bit to include
|
||||
/// - parameter toIndex: index after the last bit to include
|
||||
/// - returns: a new {@code BitSet} from a range of this {@code BitSet}
|
||||
/// - IndexOutOfBoundsException if {@code fromIndex} is negative,
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if {@code fromIndex} is negative,
|
||||
/// or {@code toIndex} is negative, or {@code fromIndex} is
|
||||
/// larger than {@code toIndex}
|
||||
/// - 1.4
|
||||
public func get(_ fromIndex: Int, _ toIndex: Int) throws -> BitSet {
|
||||
var toIndex = toIndex
|
||||
try BitSet.checkRange(fromIndex, toIndex)
|
||||
|
@ -562,8 +551,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// - parameter fromIndex: the index to start checking from (inclusive)
|
||||
/// - returns: the index of the next set bit, or {@code -1} if there
|
||||
/// is no such bit
|
||||
/// - IndexOutOfBoundsException if the specified index is negative
|
||||
/// - 1.4
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds_ if the specified index is negative
|
||||
public func nextSetBit(_ fromIndex: Int) throws -> Int {
|
||||
if fromIndex < 0 {
|
||||
throw ANTLRError.indexOutOfBounds(msg: "fromIndex < 0: \(fromIndex)")
|
||||
|
@ -634,8 +622,7 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - parameter fromIndex: the index to start checking from (inclusive)
|
||||
/// - returns: the index of the next clear bit
|
||||
/// - IndexOutOfBoundsException if the specified index is negative
|
||||
/// - 1.4
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds if the specified index is negative
|
||||
public func nextClearBit(_ fromIndex: Int) throws -> Int {
|
||||
// Neither spec nor implementation handle bitsets of maximal length.
|
||||
// See 4816253.
|
||||
|
@ -681,9 +668,9 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// - parameter fromIndex: the index to start checking from (inclusive)
|
||||
/// - returns: the index of the previous set bit, or {@code -1} if there
|
||||
/// is no such bit
|
||||
/// - IndexOutOfBoundsException if the specified index is less
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds if the specified index is less
|
||||
/// than {@code -1}
|
||||
/// - 1.7
|
||||
/// - note: 1.7
|
||||
public func previousSetBit(_ fromIndex: Int) throws -> Int {
|
||||
if fromIndex < 0 {
|
||||
if fromIndex == -1 {
|
||||
|
@ -721,9 +708,9 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// - parameter fromIndex: the index to start checking from (inclusive)
|
||||
/// - returns: the index of the previous clear bit, or {@code -1} if there
|
||||
/// is no such bit
|
||||
/// - IndexOutOfBoundsException if the specified index is less
|
||||
/// - throws: _ANTLRError.IndexOutOfBounds if the specified index is less
|
||||
/// than {@code -1}
|
||||
/// - 1.7
|
||||
/// - note: 1.7
|
||||
public func previousClearBit(_ fromIndex: Int) throws -> Int {
|
||||
if fromIndex < 0 {
|
||||
if fromIndex == -1 {
|
||||
|
@ -791,7 +778,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// if the {@code BitSet} contains no set bits.
|
||||
///
|
||||
/// - returns: the logical size of this {@code BitSet}
|
||||
/// - 1.2
|
||||
public func length() -> Int {
|
||||
if wordsInUse == 0 {
|
||||
return 0
|
||||
|
@ -805,7 +791,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// to {@code true}.
|
||||
///
|
||||
/// - returns: boolean indicating whether this {@code BitSet} is empty
|
||||
/// - 1.4
|
||||
public func isEmpty() -> Bool {
|
||||
return wordsInUse == 0
|
||||
}
|
||||
|
@ -816,7 +801,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// - parameter set: {@code BitSet} to intersect with
|
||||
/// - returns: boolean indicating whether this {@code BitSet} intersects
|
||||
/// the specified {@code BitSet}
|
||||
/// - 1.4
|
||||
public func intersects(_ set: BitSet) -> Bool {
|
||||
var i: Int = min(wordsInUse, set.wordsInUse) - 1
|
||||
while i >= 0 {
|
||||
|
@ -831,7 +815,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
/// Returns the number of bits set to {@code true} in this {@code BitSet}.
|
||||
///
|
||||
/// - returns: the number of bits set to {@code true} in this {@code BitSet}
|
||||
/// - 1.4
|
||||
public func cardinality() -> Int {
|
||||
var sum: Int = 0
|
||||
for i in 0..<wordsInUse {
|
||||
|
@ -954,7 +937,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
///
|
||||
/// - parameter set: the {@code BitSet} with which to mask this
|
||||
/// {@code BitSet}
|
||||
/// - 1.2
|
||||
public func andNot(_ set: BitSet) {
|
||||
// Perform logical (a & !b) on words in common
|
||||
var i: Int = min(wordsInUse, set.wordsInUse) - 1
|
||||
|
@ -1060,12 +1042,6 @@ public class BitSet: Hashable, CustomStringConvertible {
|
|||
} while i < endOfRun
|
||||
i = try nextSetBit(i + 1)
|
||||
}
|
||||
// for ; i >= 0; i = try nextSetBit(i + 1) {
|
||||
// let endOfRun: Int = try nextClearBit(i)
|
||||
// repeat {
|
||||
// b.append(", ").append(i)
|
||||
// } while ++i < endOfRun
|
||||
// }
|
||||
}
|
||||
} catch {
|
||||
print("BitSet description error")
|
||||
|
|
|
@ -12,7 +12,7 @@ public protocol IntSet {
|
|||
///
|
||||
/// - parameter el: the value to add
|
||||
///
|
||||
/// - IllegalStateException if the current set is read-only
|
||||
/// - throws: _ANTLRError.illegalState_ if the current set is read-only
|
||||
func add(_ el: Int) throws
|
||||
|
||||
/// Modify the current {@link org.antlr.v4.runtime.misc.IntSet} object to contain all elements that are
|
||||
|
@ -22,7 +22,7 @@ public protocol IntSet {
|
|||
/// treated as though it were an empty set.
|
||||
/// - returns: {@code this} (to support chained calls)
|
||||
///
|
||||
/// - IllegalStateException if the current set is read-only
|
||||
/// - throws: _ANTLRError.illegalState_ if the current set is read-only
|
||||
|
||||
func addAll(_ set: IntSet?) throws -> IntSet
|
||||
|
||||
|
@ -122,7 +122,7 @@ public protocol IntSet {
|
|||
///
|
||||
/// - parameter el: the value to remove
|
||||
///
|
||||
/// - IllegalStateException if the current set is read-only
|
||||
/// - throws: _ANTLRError.illegalState_ if the current set is read-only
|
||||
func remove(_ el: Int) throws
|
||||
|
||||
/// Return a list containing the elements represented by the current set. The
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
* and deletion as well as during "consume until error recovery set"
|
||||
* upon no viable alternative exceptions.
|
||||
*/
|
||||
//public class ErrorNodeImpl : TerminalNodeImpl,ErrorNode{
|
||||
|
||||
public class ErrorNode: TerminalNodeImpl {
|
||||
public override init(_ token: Token) {
|
||||
super.init(token)
|
||||
|
|
|
@ -40,9 +40,9 @@ public class ParseTreeMatch: CustomStringConvertible {
|
|||
* @param mismatchedNode The first node which failed to match the tree
|
||||
* pattern during the matching process.
|
||||
*
|
||||
* @exception IllegalArgumentException if {@code tree} is {@code null}
|
||||
* @exception IllegalArgumentException if {@code pattern} is {@code null}
|
||||
* @exception IllegalArgumentException if {@code labels} is {@code null}
|
||||
* @exception ANTLRError.ilegalArgument if {@code tree} is {@code null}
|
||||
* @exception ANTLRError.ilegalArgument if {@code pattern} is {@code null}
|
||||
* @exception ANTLRError.ilegalArgument if {@code labels} is {@code null}
|
||||
*/
|
||||
public init(_ tree: ParseTree, _ pattern: ParseTreePattern, _ labels: MultiMap<String, ParseTree>, _ mismatchedNode: ParseTree?) {
|
||||
|
||||
|
|
|
@ -64,16 +64,6 @@
|
|||
*/
|
||||
|
||||
public class ParseTreePatternMatcher {
|
||||
// public class CannotInvokeStartRule : RuntimeException {
|
||||
// public convenience init(_ e : Throwable) {
|
||||
// super.init(e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Fixes https://github.com/antlr/antlr4/issues/413
|
||||
// // "Tree pattern compilation doesn't check for a complete parse"
|
||||
// public class StartRuleDoesNotConsumeFullPattern : RuntimeException {
|
||||
// }
|
||||
|
||||
/**
|
||||
* This is the backing field for {@link #getLexer()}.
|
||||
|
@ -88,7 +78,6 @@ public class ParseTreePatternMatcher {
|
|||
internal var start: String = "<"
|
||||
internal var stop: String = ">"
|
||||
internal var escape: String = "\\"
|
||||
// e.g., \< and \> must escape BOTH!
|
||||
|
||||
/**
|
||||
* Constructs a {@link org.antlr.v4.runtime.tree.pattern.ParseTreePatternMatcher} or from a {@link org.antlr.v4.runtime.Lexer} and
|
||||
|
@ -109,22 +98,15 @@ public class ParseTreePatternMatcher {
|
|||
* @param stop The stop delimiter.
|
||||
* @param escapeLeft The escape sequence to use for escaping a start or stop delimiter.
|
||||
*
|
||||
* @exception IllegalArgumentException if {@code start} is {@code null} or empty.
|
||||
* @exception IllegalArgumentException if {@code stop} is {@code null} or empty.
|
||||
* @exception ANTLRError.ilegalArgument if {@code start} is {@code null} or empty.
|
||||
* @exception ANTLRError.ilegalArgument if {@code stop} is {@code null} or empty.
|
||||
*/
|
||||
public func setDelimiters(_ start: String, _ stop: String, _ escapeLeft: String) throws {
|
||||
//start == nil ||
|
||||
if start.isEmpty {
|
||||
throw ANTLRError.illegalArgument(msg: "start cannot be null or empty")
|
||||
// RuntimeException("start cannot be null or empty")
|
||||
//throwException() /* throw IllegalArgumentException("start cannot be null or empty"); */
|
||||
}
|
||||
//stop == nil ||
|
||||
if stop.isEmpty {
|
||||
throw ANTLRError.illegalArgument(msg: "stop cannot be null or empty")
|
||||
//RuntimeException("stop cannot be null or empty")
|
||||
|
||||
//throwException() /* throw IllegalArgumentException("stop cannot be null or empty"); */
|
||||
}
|
||||
|
||||
self.start = start
|
||||
|
@ -132,14 +114,17 @@ public class ParseTreePatternMatcher {
|
|||
self.escape = escapeLeft
|
||||
}
|
||||
|
||||
/** Does {@code pattern} matched as rule {@code patternRuleIndex} match {@code tree}? */
|
||||
/**
|
||||
* Does {@code pattern} matched as rule {@code patternRuleIndex} match {@code tree}?
|
||||
*/
|
||||
public func matches(_ tree: ParseTree, _ pattern: String, _ patternRuleIndex: Int) throws -> Bool {
|
||||
let p: ParseTreePattern = try compile(pattern, patternRuleIndex)
|
||||
return try matches(tree, p)
|
||||
}
|
||||
|
||||
/** Does {@code pattern} matched as rule patternRuleIndex match tree? Pass in a
|
||||
* compiled pattern instead of a string representation of a tree pattern.
|
||||
/**
|
||||
* Does {@code pattern} matched as rule patternRuleIndex match tree? Pass in a
|
||||
* compiled pattern instead of a string representation of a tree pattern.
|
||||
*/
|
||||
public func matches(_ tree: ParseTree, _ pattern: ParseTreePattern) throws -> Bool {
|
||||
let labels: MultiMap<String, ParseTree> = MultiMap<String, ParseTree>()
|
||||
|
@ -163,7 +148,6 @@ public class ParseTreePatternMatcher {
|
|||
* node at which the match failed. Pass in a compiled pattern instead of a
|
||||
* string representation of a tree pattern.
|
||||
*/
|
||||
|
||||
public func match(_ tree: ParseTree, _ pattern: ParseTreePattern) throws -> ParseTreeMatch {
|
||||
let labels: MultiMap<String, ParseTree> = MultiMap<String, ParseTree>()
|
||||
let mismatchedNode: ParseTree? = try matchImpl(tree, pattern.getPatternTree(), labels)
|
||||
|
@ -185,29 +169,13 @@ public class ParseTreePatternMatcher {
|
|||
parser.getATNWithBypassAlts(),
|
||||
tokens)
|
||||
|
||||
var tree: ParseTree //= nil;
|
||||
//TODO: exception handler
|
||||
//try {
|
||||
var tree: ParseTree
|
||||
parserInterp.setErrorHandler(BailErrorStrategy())
|
||||
tree = try parserInterp.parse(patternRuleIndex)
|
||||
// print("pattern tree = "+tree.toStringTree(parserInterp));
|
||||
// }
|
||||
// catch (ParseCancellationException e) {
|
||||
// throwException() /* throw e.getCause() as RecognitionException; */
|
||||
// }
|
||||
// catch (RecognitionException re) {
|
||||
// throwException() /* throw re; */
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// throwException() /* throw CannotInvokeStartRule(e); */
|
||||
// }
|
||||
|
||||
// Make sure tree pattern compilation checks for a complete parse
|
||||
if try tokens.LA(1) != CommonToken.EOF {
|
||||
throw ANTLRError.illegalState(msg: "Tree pattern compilation doesn't check for a complete parse")
|
||||
// RuntimeException("Tree pattern compilation doesn't check for a complete parse")
|
||||
//throw ANTLRException.StartRuleDoesNotConsumeFullPattern
|
||||
//throwException() /* throw StartRuleDoesNotConsumeFullPattern(); */
|
||||
}
|
||||
|
||||
return ParseTreePattern(self, pattern, patternRuleIndex, tree)
|
||||
|
@ -217,7 +185,6 @@ public class ParseTreePatternMatcher {
|
|||
* Used to convert the tree pattern string into a series of tokens. The
|
||||
* input stream is reset.
|
||||
*/
|
||||
|
||||
public func getLexer() -> Lexer {
|
||||
return lexer
|
||||
}
|
||||
|
@ -226,7 +193,6 @@ public class ParseTreePatternMatcher {
|
|||
* Used to collect to the grammar file name, token names, rule names for
|
||||
* used to parse the pattern into a parse tree.
|
||||
*/
|
||||
|
||||
public func getParser() -> Parser {
|
||||
return parser
|
||||
}
|
||||
|
@ -242,7 +208,6 @@ public class ParseTreePatternMatcher {
|
|||
* was successful. The specific node returned depends on the matching
|
||||
* algorithm used by the implementation, and may be overridden.
|
||||
*/
|
||||
|
||||
internal func matchImpl(_ tree: ParseTree,
|
||||
_ patternTree: ParseTree,
|
||||
_ labels: MultiMap<String, ParseTree>) throws -> ParseTree? {
|
||||
|
@ -391,12 +356,13 @@ public class ParseTreePatternMatcher {
|
|||
return tokens
|
||||
}
|
||||
|
||||
/** Split {@code <ID> = <e:expr> ;} into 4 chunks for tokenizing by {@link #tokenize}. */
|
||||
/**
|
||||
* Split {@code <ID> = <e:expr> ;} into 4 chunks for tokenizing by {@link #tokenize}.
|
||||
*/
|
||||
public func split(_ pattern: String) throws -> Array<Chunk> {
|
||||
var p: Int = 0
|
||||
let n: Int = pattern.length
|
||||
var chunks: Array<Chunk> = Array<Chunk>()
|
||||
//var buf : StringBuilder = StringBuilder();
|
||||
// find all start and stop indexes first, then collect
|
||||
var starts: Array<Int> = Array<Int>()
|
||||
var stops: Array<Int> = Array<Int>()
|
||||
|
|
|
@ -35,7 +35,7 @@ public class RuleTagToken: Token, CustomStringConvertible {
|
|||
* @param ruleName The name of the parser rule this rule tag matches.
|
||||
* @param bypassTokenType The bypass token type assigned to the parser rule.
|
||||
*
|
||||
* @exception IllegalArgumentException if {@code ruleName} is {@code null}
|
||||
* @exception ANTLRError.illegalArgument if {@code ruleName} is {@code null}
|
||||
* or empty.
|
||||
*/
|
||||
public convenience init(_ ruleName: String, _ bypassTokenType: Int) {
|
||||
|
@ -51,7 +51,7 @@ public class RuleTagToken: Token, CustomStringConvertible {
|
|||
* @param label The label associated with the rule tag, or {@code null} if
|
||||
* the rule tag is unlabeled.
|
||||
*
|
||||
* @exception IllegalArgumentException if {@code ruleName} is {@code null}
|
||||
* @exception ANTLRError.illegalArgument if {@code ruleName} is {@code null}
|
||||
* or empty.
|
||||
*/
|
||||
public init(_ ruleName: String, _ bypassTokenType: Int, _ label: String?) {
|
||||
|
@ -67,7 +67,6 @@ public class RuleTagToken: Token, CustomStringConvertible {
|
|||
*
|
||||
* @return The name of the parser rule associated with this rule tag.
|
||||
*/
|
||||
|
||||
public final func getRuleName() -> String {
|
||||
return ruleName
|
||||
}
|
||||
|
@ -78,28 +77,21 @@ public class RuleTagToken: Token, CustomStringConvertible {
|
|||
* @return The name of the label associated with the rule tag, or
|
||||
* {@code null} if this is an unlabeled rule tag.
|
||||
*/
|
||||
|
||||
public final func getLabel() -> String? {
|
||||
return label
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>Rule tag tokens are always placed on the {@link #DEFAULT_CHANNEL}.</p>
|
||||
*/
|
||||
|
||||
public func getChannel() -> Int {
|
||||
return RuleTagToken.DEFAULT_CHANNEL
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This method returns the rule tag formatted with {@code <} and {@code >}
|
||||
* delimiters.</p>
|
||||
*/
|
||||
|
||||
public func getText() -> String? {
|
||||
if label != nil {
|
||||
return "<" + label! + ":" + ruleName + ">"
|
||||
|
@ -109,32 +101,23 @@ public class RuleTagToken: Token, CustomStringConvertible {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>Rule tag tokens have types assigned according to the rule bypass
|
||||
* transitions created during ATN deserialization.</p>
|
||||
*/
|
||||
|
||||
public func getType() -> Int {
|
||||
return bypassTokenType
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} always returns 0.</p>
|
||||
*/
|
||||
|
||||
public func getLine() -> Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} always returns -1.</p>
|
||||
*/
|
||||
|
||||
public func getCharPositionInLine() -> Int {
|
||||
return -1
|
||||
}
|
||||
|
@ -144,59 +127,42 @@ public class RuleTagToken: Token, CustomStringConvertible {
|
|||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} always returns -1.</p>
|
||||
*/
|
||||
|
||||
public func getTokenIndex() -> Int {
|
||||
return -1
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} always returns -1.</p>
|
||||
*/
|
||||
|
||||
public func getStartIndex() -> Int {
|
||||
return -1
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} always returns -1.</p>
|
||||
*/
|
||||
|
||||
public func getStopIndex() -> Int {
|
||||
return -1
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} always returns {@code null}.</p>
|
||||
*/
|
||||
|
||||
public func getTokenSource() -> TokenSource? {
|
||||
return nil
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} always returns {@code null}.</p>
|
||||
*/
|
||||
|
||||
public func getInputStream() -> CharStream? {
|
||||
return nil
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The implementation for {@link org.antlr.v4.runtime.tree.pattern.RuleTagToken} returns a string of the form
|
||||
* {@code ruleName:bypassTokenType}.</p>
|
||||
*/
|
||||
|
||||
|
||||
public var description: String {
|
||||
return ruleName + ":" + String(bypassTokenType)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TagChunk: Chunk, CustomStringConvertible {
|
|||
* @param tag The tag, which should be the name of a parser rule or token
|
||||
* type.
|
||||
*
|
||||
* @exception IllegalArgumentException if {@code tag} is {@code null} or
|
||||
* @exception ANTLRError.illegalArgument if {@code tag} is {@code null} or
|
||||
* empty.
|
||||
*/
|
||||
public convenience init(_ tag: String) throws {
|
||||
|
@ -52,7 +52,7 @@ public class TagChunk: Chunk, CustomStringConvertible {
|
|||
* @param tag The tag, which should be the name of a parser rule or token
|
||||
* type.
|
||||
*
|
||||
* @exception IllegalArgumentException if {@code tag} is {@code null} or
|
||||
* @exception ANTLRError.illegalArgument if {@code tag} is {@code null} or
|
||||
* empty.
|
||||
*/
|
||||
public init(_ label: String?, _ tag: String) throws {
|
||||
|
@ -70,7 +70,6 @@ public class TagChunk: Chunk, CustomStringConvertible {
|
|||
*
|
||||
* @return The tag for the chunk.
|
||||
*/
|
||||
|
||||
public final func getTag() -> String {
|
||||
return tag
|
||||
}
|
||||
|
@ -81,7 +80,6 @@ public class TagChunk: Chunk, CustomStringConvertible {
|
|||
* @return The label assigned to this chunk, or {@code null} if no label is
|
||||
* assigned to the chunk.
|
||||
*/
|
||||
|
||||
public final func getLabel() -> String? {
|
||||
return label
|
||||
}
|
||||
|
@ -91,8 +89,6 @@ public class TagChunk: Chunk, CustomStringConvertible {
|
|||
* are returned in the form {@code label:tag}, and unlabeled tags are
|
||||
* returned as just the tag name.
|
||||
*/
|
||||
|
||||
|
||||
public var description: String {
|
||||
if label != nil {
|
||||
return label! + ":" + tag
|
||||
|
|
|
@ -20,7 +20,7 @@ public class TextChunk: Chunk, CustomStringConvertible {
|
|||
* Constructs a new instance of {@link org.antlr.v4.runtime.tree.pattern.TextChunk} with the specified text.
|
||||
*
|
||||
* @param text The text of this chunk.
|
||||
* @exception IllegalArgumentException if {@code text} is {@code null}.
|
||||
* @exception ANTLRError.illegalArgument if {@code text} is {@code null}.
|
||||
*/
|
||||
public init(_ text: String) {
|
||||
self.text = text
|
||||
|
|
Loading…
Reference in New Issue