diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg index da1586e3ad..59855f1558 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg @@ -861,6 +861,7 @@ CaptureNextTokenType(d) ::= " = TokenStream.LA(1);" StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers,signatures, superClass={ParserRuleContext}) ::= << public partial class : ParserRuleContext, { + ;}; separator="\n"> ;}; separator="\n"> }; separator="\n"> public (ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } @@ -874,6 +875,7 @@ public partial class : () { } public virtual void CopyFrom( context) { base.CopyFrom(context); + = context.;}; separator="\n"> = context.;}; separator="\n"> } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg index 6fc4419d02..223e7d9180 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg @@ -583,6 +583,7 @@ LeftRecursiveRuleFunction(currentRule, args, code, locals, ruleCtx, altLabelCtxs StructDeclHeader(struct, ctorAttrs, attrs, getters, dispatchMethods, interfaces, extensionMembers) ::= << class : public antlr4::ParserRuleContext, { public: + ;}; separator = "\n"> ;}; separator = "\n"> (antlr4::ParserRuleContext *parent, size_t invokingState); (antlr4::ParserRuleContext *parent, size_t invokingState}>); @@ -624,6 +625,7 @@ size_t ::::getRuleIndex() const { void ::::copyFrom( *ctx) { ParserRuleContext::copyFrom(ctx); + = ctx->;}; separator = "\n"> = ctx->;}; separator = "\n"> } @@ -1172,4 +1174,3 @@ previousContext = _localctx; initValue(typeName) ::= << >> - diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Dart/Dart.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Dart/Dart.stg index 7e20cd1f1d..fc3c9dbadb 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Dart/Dart.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Dart/Dart.stg @@ -684,6 +684,7 @@ CaptureNextTokenType(d) ::= " = tokenStream.LA(1)!;" StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers,signatures) ::= << class extends ParserRuleContext implements { + ;}; separator="\n"> ;}; separator="\n"> }; separator="\n"> ([ParserRuleContext? parent, int? invokingState}>]) : super(parent, invokingState) { @@ -696,6 +697,7 @@ class extends ParserRuleContext ctx) { super.copyFrom(ctx); + ). != null) this. = (ctx as ).;}; separator="\n"> ). != null) this. = (ctx as ).;}; separator="\n"> } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg index 19dcc3f435..ae7731dae6 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg @@ -1121,12 +1121,22 @@ Get() []I}; separator="\n\n"> Set([]I) }; separator="\n\n"> + + + returns the attribute. +Get() }; separator="\n\n"> + returns the attribute. Get() }; separator="\n\n"> + + + sets the attribute. +Set()}; separator="\n\n"> + sets the attribute. @@ -1146,6 +1156,9 @@ Set()}; separator="\n\n"> type struct { *antlr.BaseParserRuleContext parser antlr.Parser + + + @@ -1243,11 +1256,19 @@ func (s *) GetParser() antlr.Parser { return s.parser } ) Set(v []I) { s. = v \}}; separator="\n\n"> + + +) Get() { return s. \}}; separator="\n\n"> + ) Get() { return s. \}}; separator="\n\n"> + + +) Set(v ) { s. = v \}}; separator="\n\n"> + ) Set(v ) { s. = v \}}; separator="\n\n"> @@ -1262,6 +1283,7 @@ func (s *) GetParser() antlr.Parser { return s.parser } func (s *) CopyAll(ctx *) { s.CopyFrom(&ctx.BaseParserRuleContext) + = ctx.}; separator="\n"> = ctx.}; separator="\n"> } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg index 3a97a1fa27..78a64d8efb 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg @@ -786,6 +786,7 @@ StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMe ::= << @SuppressWarnings("CheckReturnValue") public static class extends ParserRuleContext implements { + ;}; separator="\n"> ;}; separator="\n"> }; separator="\n"> public (ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -798,6 +799,7 @@ public static class extends () { } public void copyFrom( ctx) { super.copyFrom(ctx); + = ctx.;}; separator="\n"> = ctx.;}; separator="\n"> } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg index c976bfc617..0f9c68732f 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg @@ -675,6 +675,7 @@ class extends copyFrom(ctx) { super.copyFrom(ctx); + = ctx.;}; separator="\n"> = ctx.;}; separator="\n"> } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/PHP/PHP.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/PHP/PHP.stg index b58024b4a2..75f1a92b3d 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/PHP/PHP.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/PHP/PHP.stg @@ -848,9 +848,18 @@ public $;}; separator="\n\n"> */ public $;}; separator="\n\n"> - + + + |null $ + */ +public $ = ;}; separator="\n\n"> + + + + |null $ @@ -949,6 +958,7 @@ class extends Pars { parent::copyFrom($context); + = $context->;}; separator="\n"> = $context->;}; separator="\n"> } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg index 972b88b6d0..0b10d24a1a 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg @@ -668,6 +668,7 @@ class (Parse def copyFrom(self, ctx:ParserRuleContext): super().copyFrom(ctx) + = ctx.}; separator="\n"> = ctx.}; separator="\n"> diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg index c064a57329..ecbe8ef83b 100755 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg @@ -816,6 +816,7 @@ StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMe superClass={ParserRuleContext}) ::= << class : ParserRuleContext, { + var }; separator="\n"> var }; separator="\n"> }; separator="\n"> init(_ parent: ParserRuleContext,_ invokingState: Int) { super.init(parent, invokingState) } !> @@ -835,6 +836,7 @@ StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMe override func copyFrom(_ ctx_: ParserRuleContext) { super.copyFrom(ctx_) let ctx = ctx_ as! + = ctx.;}; separator="\n"> = ctx.;}; separator="\n"> } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/TypeScript/TypeScript.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/TypeScript/TypeScript.stg index c3fc469fd6..cee4313f3d 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/TypeScript/TypeScript.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/TypeScript/TypeScript.stg @@ -731,6 +731,7 @@ CaptureNextTokenType(d) ::= " = this._input.LA(1);" StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers,signatures) ::= << export class extends ParserRuleContext implements { + ;}; separator="\n"> ;}; separator="\n"> constructor(parser: , parent: ParserRuleContext, invokingState: number: }>) { @@ -751,6 +752,7 @@ export class extends public copyFrom(ctx: ): void { super.copyFrom(ctx); + = ctx.;}; separator="\n"> = ctx.;}; separator="\n"> } diff --git a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java index 281ad4fd4c..550655f1d9 100644 --- a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java +++ b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java @@ -89,7 +89,6 @@ public RuleFunction(OutputModelFactory factory, Rule r) { Collection decls = r.args.attributes.values(); if ( decls.size()>0 ) { args = new ArrayList(); - ruleCtx.addDecls(decls); for (Attribute a : decls) { args.add(new AttributeDecl(factory, a)); }