@@ -57,6 +57,7 @@ import org.antlr.v4.kotlinruntime.atn.ATN.Companion.INVALID_ALT_NUMBER
57
57
import org.antlr.v4.kotlinruntime.dfa.*
58
58
import org.antlr.v4.kotlinruntime.misc.*
59
59
import org.antlr.v4.kotlinruntime.tree.*
60
+ import kotlin.jvm.JvmField
60
61
61
62
<parser>
62
63
>>
@@ -416,11 +417,11 @@ LeftRecursiveRuleFunction(currentRule, args, code, locals, ruleCtx, altLabelCtxs
416
417
<ruleCtx>
417
418
<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n">
418
419
419
- <if(currentRule.modifiers)><currentRule.modifiers:{f | <f> }><else>public<endif> fun <currentRule.name >(<args; separator=", ">): <currentRule.ctxType> {
420
- return <currentRule.name >(0<currentRule.args:{a | , <a.name>}>)
420
+ <if(currentRule.modifiers)><currentRule.modifiers:{f | <f> }><else>public<endif> fun <currentRule.escapedName >(<args; separator=", ">): <currentRule.ctxType> {
421
+ return <currentRule.escapedName >(0<currentRule.args:{a | , <a.name>}>)
421
422
}
422
423
423
- private fun <currentRule.name >(_p: Int<args:{a | , <a>}>): <currentRule.ctxType> {
424
+ private fun <currentRule.escapedName >(_p: Int<args:{a | , <a>}>): <currentRule.ctxType> {
424
425
var _parentctx = context
425
426
var _parentState = state
426
427
var _localctx = <currentRule.ctxType>(context, _parentState<currentRule.args:{a | , <a.name>}>)
@@ -625,11 +626,11 @@ offsetShift(shiftAmount, offset) ::= <%
625
626
626
627
// produces more efficient bytecode when bits.tokens contains at most two items
627
628
bitsetInlineComparison(s, bits) ::= <%
628
- <bits.tokens:{t | <s.varName> == <t.name>}; separator=" || ">
629
+ <bits.tokens:{t | <s.varName> == Tokens. <t.name>}; separator=" || ">
629
630
%>
630
631
631
632
cases(tokens) ::= <<
632
- <tokens:{t | <t.name>}; separator=", "> -> >>
633
+ <tokens:{t | Tokens. <t.name>}; separator=", "> -> >>
633
634
634
635
InvokeRule(r, argExprsChunks) ::= <<
635
636
this.state = <r.stateNumber>
@@ -644,10 +645,10 @@ _ctx = <r.escapedName>(<if(r.ast.options.p)><r.ast.options.p><if(argExprsChunks)
644
645
MatchToken(m) ::= <<
645
646
this.state = <m.stateNumber>
646
647
<if(m.labels)>
647
- _token = match(<m.name>)
648
+ _token = match(Tokens. <m.name>)
648
649
<m.labels:{l | <labelref(l)> = _token}; separator="\n">
649
650
<else>
650
- match(<m.name>)
651
+ match(Tokens. <m.name>)
651
652
<endif>
652
653
>>
653
654
@@ -726,13 +727,13 @@ ActionText(t) ::= "<t.text>"
726
727
ActionTemplate(t) ::= "<t.st>"
727
728
ArgRef(a) ::= "_localctx.<a.name>"
728
729
LocalRef(a) ::= "_localctx.<a.name>"
729
- RetValueRef(a) ::= "_localctx.<a.name >"
730
+ RetValueRef(a) ::= "_localctx.<a.escapedName >"
730
731
QRetValueRef(a) ::= "<ctx(a)>.<a.dict>!!.<a.name>"
731
732
732
733
/** How to translate $tokenLabel */
733
734
TokenRef(t) ::= "<ctx(t)>.<t.name>"
734
735
LabelRef(t) ::= "<ctx(t)>.<t.name>"
735
- ListLabelRef(t) ::= "<ctx(t)>.<ListLabelName(t.name )>"
736
+ ListLabelRef(t) ::= "<ctx(t)>.<ListLabelName(t.escapedName )>"
736
737
SetAttr(s, rhsChunks) ::= "<ctx(s)>.<s.name> = <rhsChunks>"
737
738
738
739
TokenLabelType() ::= "<file.TokenLabelType; null={Token}>"
@@ -748,13 +749,13 @@ TokenPropertyRef_int(t) ::= "(<ctx(t)>.<t.label>?.text!!.toInt() ?: 0)"
748
749
749
750
RulePropertyRef_start(r) ::= "(<ctx(r)>.<r.label>?.start)"
750
751
RulePropertyRef_stop(r) ::= "(<ctx(r)>.<r.label>?.stop)"
751
- RulePropertyRef_text(r) ::= "(<ctx(r)>.<r.label>?.let { _input.getText(it.start!! , it.stop!! ) })"
752
+ RulePropertyRef_text(r) ::= "(<ctx(r)>.<r.label>?.let { _input.getText(it.start, it.stop) })"
752
753
RulePropertyRef_ctx(r) ::= "<ctx(r)>.<r.label>"
753
754
RulePropertyRef_parser(r) ::= "this"
754
755
755
756
ThisRulePropertyRef_start(r) ::= "_localctx.start"
756
757
ThisRulePropertyRef_stop(r) ::= "_localctx.stop"
757
- ThisRulePropertyRef_text(r) ::= "_input.getText(_localctx.start!! , _input.LT(-1)!! )"
758
+ ThisRulePropertyRef_text(r) ::= "_input.getText(_localctx.start, _input.LT(-1))"
758
759
ThisRulePropertyRef_ctx(r) ::= "_localctx"
759
760
ThisRulePropertyRef_parser(r) ::= "this"
760
761
@@ -805,11 +806,11 @@ StructDecl(struct, ctorAttrs, attrs, getters, dispatchMethods, interfaces, exten
805
806
public open class <struct.name> : <if(contextSuperClass)><contextSuperClass><else>ParserRuleContext<endif><if(interfaces)> : <interfaces; separator=", "><endif> {
806
807
override val ruleIndex: Int = Rules.<struct.derivedFromName; format="cap">
807
808
808
- <attrs:{a | public var <a>}; separator="\n">
809
+ <attrs:{a | @JvmField public var <a>}; separator="\n">
809
810
<getters:{g | <g>}; separator="\n">
810
811
811
812
public constructor(parent: ParserRuleContext?, invokingState: Int<ctorAttrs:{a | , <a>}>) : super(parent, invokingState) {
812
- <struct.ctorAttrs:{a | this.<a.name > = <a.name >}; separator="\n">
813
+ <struct.ctorAttrs:{a | this.<a.escapedName > = <a.escapedName >}; separator="\n">
813
814
}
814
815
815
816
<! Don't need copy unless we have subclasses !>
@@ -818,7 +819,7 @@ public open class <struct.name> : <if(contextSuperClass)><contextSuperClass><els
818
819
819
820
public fun copyFrom(ctx: <struct.name>) {
820
821
super.copyFrom(ctx)
821
- <struct.attrs:{a | this.<a.name > = ctx.<a.name >}; separator="\n">
822
+ <struct.attrs:{a | this.<a.escapedName > = ctx.<a.escapedName >}; separator="\n">
822
823
}
823
824
<endif>
824
825
<dispatchMethods; separator="\n\n">
@@ -829,7 +830,7 @@ public open class <struct.name> : <if(contextSuperClass)><contextSuperClass><els
829
830
830
831
AltLabelStructDecl(struct, attrs, getters, dispatchMethods) ::= <<
831
832
public open class <struct.name> : <currentRule.name; format="cap">Context {
832
- <attrs:{a | public var <a>}; separator="\n">
833
+ <attrs:{a | @JvmField public var <a>}; separator="\n">
833
834
<getters:{g | <g>}; separator="\n">
834
835
835
836
public constructor(ctx: <currentRule.name; format="cap">Context) {
@@ -963,7 +964,7 @@ public open class <lexer.name>(input: CharStream) : <superClass; null="Lexer">(i
963
964
public object Modes {
964
965
public const val DEFAULT_MODE: Int = 0
965
966
<if(rest(lexer.modes))>
966
- <rest(lexer.modes):{m | public const val <m>: Int = <i>}; separator="\n">
967
+ <rest(lexer.modes):{m | public const val <m; format="upper" >: Int = <i>}; separator="\n">
967
968
<endif>
968
969
}
969
970
0 commit comments