[Swift] Update codegen template

Update Swift codegen template to resolve warning:

> Variable '_localctx' was never mutated; consider changing to 'let' constant
> Variable '_parentState' was never mutated; consider changing to 'let' constant
> Variable '_startState' was never mutated; consider changing to 'let' constant

Since there is no path where they can be changed I would say its best to just generate without the warnings.
This commit is contained in:
Martin van Wingerden 2020-04-23 10:40:27 +02:00 committed by GitHub
parent 8c50731894
commit 71103fc652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -395,7 +395,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">
@ -438,9 +438,9 @@ LeftRecursiveRuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs,
@discardableResult
private func <currentRule.name>(_ _p<args:{a | , <a>}>: Int) throws -> <currentRule.ctxType> {
let _parentctx: ParserRuleContext? = _ctx
var _parentState: Int = getState()
let _parentState: Int = getState()
var _localctx: <currentRule.ctxType> = <currentRule.ctxType>(_ctx, _parentState<currentRule.args:{a | , <a.name>}>)
var _prevctx: <currentRule.ctxType> = _localctx
let _prevctx: <currentRule.ctxType> = _localctx
var _startState: Int = <currentRule.startState>
try enterRecursionRule(_localctx, <currentRule.startState>, <parser.name>.RULE_<currentRule.name>, _p)
<namedActions.init>