Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix swift warnings #3043

Merged
merged 4 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/Swift/Sources/Antlr4/Lexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ open class Lexer: Recognizer<LexerATNSimulator>, TokenSource {

// Mark start location in char stream so unbuffered streams are
// guaranteed at least have text of current token
var tokenStartMarker = _input.mark()
let tokenStartMarker = _input.mark()
defer {
// make sure we release marker after match or
// unbuffered char stream will keep buffering
Expand Down
10 changes: 5 additions & 5 deletions runtime/Swift/Sources/Antlr4/atn/LexerATNSimulator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ open class LexerATNSimulator: ATNSimulator {
LexerATNSimulator.match_calls += 1

self.mode = mode
var mark = input.mark()
let mark = input.mark()
defer {
try! input.release(mark)
}
Expand Down Expand Up @@ -609,10 +609,10 @@ open class LexerATNSimulator: ATNSimulator {
return try recog.sempred(nil, ruleIndex, predIndex)
}

var savedCharPositionInLine = charPositionInLine
var savedLine = line
var index = input.index()
var marker = input.mark()
let savedCharPositionInLine = charPositionInLine
let savedLine = line
let index = input.index()
let marker = input.mark()
do {
try consume(input)
defer
Expand Down
2 changes: 1 addition & 1 deletion runtime/Swift/Sources/Antlr4/atn/LexerActionExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public class LexerActionExecutor: Hashable {
///
public func execute(_ lexer: Lexer, _ input: CharStream, _ startIndex: Int) throws {
var requiresSeek: Bool = false
var stopIndex: Int = input.index()
let stopIndex: Int = input.index()
defer {
if requiresSeek {
try! input.seek(stopIndex)
Expand Down
12 changes: 6 additions & 6 deletions runtime/Swift/Sources/Antlr4/atn/ProfilingATNSimulator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ public class ProfilingATNSimulator: ParserATNSimulator {

override
public func adaptivePredict(_ input: TokenStream, _ decision: Int,_ outerContext: ParserRuleContext?) throws -> Int {
var outerContext = outerContext
let outerContext = outerContext
self._sllStopIndex = -1
self._llStopIndex = -1
self.currentDecision = decision
var start: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime(); // expensive but useful info
var alt: Int = try super.adaptivePredict(input, decision, outerContext)
var stop: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime();
let start: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime(); // expensive but useful info
let alt: Int = try super.adaptivePredict(input, decision, outerContext)
let stop: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime();
decisions[decision].timeInPrediction += (stop - start)
decisions[decision].invocations += 1

var SLL_k: Int64 = Int64(_sllStopIndex - _startIndex + 1)
let SLL_k: Int64 = Int64(_sllStopIndex - _startIndex + 1)
decisions[decision].SLL_TotalLook += SLL_k
decisions[decision].SLL_MinLook = decisions[decision].SLL_MinLook == 0 ? SLL_k : min(decisions[decision].SLL_MinLook, SLL_k)
if SLL_k > decisions[decision].SLL_MaxLook {
Expand All @@ -73,7 +73,7 @@ public class ProfilingATNSimulator: ParserATNSimulator {
}

if _llStopIndex >= 0 {
var LL_k: Int64 = Int64(_llStopIndex - _startIndex + 1)
let LL_k: Int64 = Int64(_llStopIndex - _startIndex + 1)
decisions[decision].LL_TotalLook += LL_k
decisions[decision].LL_MinLook = decisions[decision].LL_MinLook == 0 ? LL_k : min(decisions[decision].LL_MinLook, LL_k)
if LL_k > decisions[decision].LL_MaxLook {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ RuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs,namedActions,fina
<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n">
@discardableResult
<if(currentRule.modifiers)><currentRule.modifiers:{f | <f> }><else> <accessLevelOpenOK(parser)> func <endif><currentRule.name>(<if(first(args))>_ <endif><args; separator=", _">) throws -> <currentRule.ctxType> {
var _localctx: <currentRule.ctxType> = <currentRule.ctxType>(_ctx, getState()<currentRule.args:{a | , <a.name>}>)
let _localctx: <currentRule.ctxType> = <currentRule.ctxType>(_ctx, getState()<currentRule.args:{a | , <a.name>}>)
try enterRule(_localctx, <currentRule.startState>, <parser.name>.RULE_<currentRule.name>)
<namedActions.init>
<locals; separator="\n">
Expand Down