[Swift] fixed compiler warnings about using var instead of let

This commit is contained in:
Mark Lilback 2019-11-18 13:24:40 -05:00 committed by Ewan Mellor
parent a701f2b099
commit 3bd5465881
No known key found for this signature in database
GPG Key ID: 7CE1C6BC9EC8645D
6 changed files with 13 additions and 12 deletions

View File

@ -233,3 +233,4 @@ YYYY/MM/DD, github id, Full name, email
2019/09/28, lmy269, Mingyang Liu, lmy040758@gmail.com
2019/10/31, a-square, Alexei Averchenko, lex.aver@gmail.com
2019/11/11, foxeverl, Liu Xinfeng, liuxf1986[at]gmail[dot]com
2019/11/18, mlilback, Mark Lilback, mark@lilback.com

View File

@ -101,7 +101,7 @@ public class DiagnosticErrorListener: BaseErrorListener {
let decision: Int = dfa.decision
let ruleIndex: Int = dfa.atnStartState.ruleIndex!
var ruleNames: [String] = recognizer.getRuleNames()
let ruleNames: [String] = recognizer.getRuleNames()
if ruleIndex < 0 || ruleIndex >= ruleNames.count {
return String(decision)
}

View File

@ -941,7 +941,7 @@ open class Parser: Recognizer<ParserATNSimulator> {
public func getRuleInvocationStack(_ p: RuleContext?) -> [String] {
var p = p
var ruleNames = getRuleNames()
let ruleNames = getRuleNames()
var stack = [String]()
while let pWrap = p {
// compute what follows who invoked us

View File

@ -40,7 +40,7 @@ public class ParseInfo {
/// full-context predictions during parsing.
///
public func getLLDecisions() -> Array<Int> {
var decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
let decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
var LL: Array<Int> = Array<Int>()
let length = decisions.count
for i in 0..<length {
@ -59,7 +59,7 @@ public class ParseInfo {
/// _org.antlr.v4.runtime.atn.DecisionInfo#timeInPrediction_ for all decisions.
///
public func getTotalTimeInPrediction() -> Int64 {
var decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
let decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
var t: Int64 = 0
let length = decisions.count
for i in 0..<length {
@ -74,7 +74,7 @@ public class ParseInfo {
/// _org.antlr.v4.runtime.atn.DecisionInfo#SLL_TotalLook_ for all decisions.
///
public func getTotalSLLLookaheadOps() -> Int64 {
var decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
let decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
var k: Int64 = 0
let length = decisions.count
for i in 0..<length {
@ -89,7 +89,7 @@ public class ParseInfo {
/// _org.antlr.v4.runtime.atn.DecisionInfo#LL_TotalLook_ for all decisions.
///
public func getTotalLLLookaheadOps() -> Int64 {
var decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
let decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
var k: Int64 = 0
let length = decisions.count
for i in 0..<length {
@ -103,7 +103,7 @@ public class ParseInfo {
/// across all decisions made during parsing.
///
public func getTotalSLLATNLookaheadOps() -> Int64 {
var decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
let decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
var k: Int64 = 0
let length = decisions.count
for i in 0..<length {
@ -117,7 +117,7 @@ public class ParseInfo {
/// across all decisions made during parsing.
///
public func getTotalLLATNLookaheadOps() -> Int64 {
var decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
let decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
var k: Int64 = 0
let length = decisions.count
for i in 0..<length {
@ -135,7 +135,7 @@ public class ParseInfo {
/// _#getTotalLLATNLookaheadOps_.
///
public func getTotalATNLookaheadOps() -> Int64 {
var decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
let decisions: [DecisionInfo] = atnSimulator.getDecisionInfo()
var k: Int64 = 0
let length = decisions.count
for i in 0..<length {

View File

@ -559,7 +559,7 @@ open class ParserATNSimulator: ATNSimulator {
/// already cached
///
func getExistingTargetState(_ previousD: DFAState, _ t: Int) -> DFAState? {
var edges = previousD.edges
let edges = previousD.edges
if edges == nil || (t + 1) < 0 || (t + 1) >= (edges!.count) {
return nil
}

View File

@ -326,8 +326,8 @@ public class IntervalSet: IntSet, Hashable, CustomStringConvertible {
return nil // nothing in common with null set
}
var myIntervals = self.intervals
var theirIntervals = (other as! IntervalSet).intervals
let myIntervals = self.intervals
let theirIntervals = (other as! IntervalSet).intervals
var intersection: IntervalSet? = nil
let mySize = myIntervals.count
let theirSize = theirIntervals.count