Skip to content

Commit 5995022

Browse files
mdehoogparrt
authored andcommitted
Add support to Golang codegen for booleans
Signed-off-by: Michael de Hoog <[email protected]>
1 parent 6e89287 commit 5995022

File tree

1 file changed

+7
-2
lines changed
  • tool/resources/org/antlr/v4/tool/templates/codegen/Go

1 file changed

+7
-2
lines changed

tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
GoTypeMap ::= [
2+
"boolean":"bool",
3+
default : key
4+
]
5+
16
fileHeader(grammarFileName, ANTLRVersion) ::= <<
27
// Code generated from <grammarFileName> by ANTLR <ANTLRVersion>. DO NOT EDIT.
38
>>
@@ -931,14 +936,14 @@ SetNonLocalAttr(s, rhsChunks) ::= "p.GetInvokingContext(<s.ruleIndex>).(*<s.rule
931936

932937
AddToLabelList(a) ::= "<ctx(a.label)>.<a.listName> = append(<ctx(a.label)>.<a.listName>, <labelref(a.label)>)"
933938

934-
TokenDecl(t) ::= "<t.escapedName> <TokenLabelType()>"
939+
TokenDecl(t) ::= "<t.escapedName> <GoTypeMap.(TokenLabelType())>"
935940
TokenTypeDecl(t) ::= "<t.escapedName> int"
936941
TokenListDecl(t) ::= "<t.escapedName> []antlr.Token"
937942

938943
RuleContextDecl(r) ::= "<r.escapedName> I<r.ctxName> "
939944
RuleContextListDecl(rdecl) ::= "<rdecl.escapedName> []I<rdecl.ctxName>"
940945

941-
AttributeDecl(d) ::= "<d.escapedName> <d.type><if(d.initValue)>// TODO = <d.initValue><endif>"
946+
AttributeDecl(d) ::= "<d.escapedName> <GoTypeMap.(d.type)><if(d.initValue)>// TODO = <d.initValue><endif>"
942947

943948
ContextTokenGetterDecl(t) ::= <<
944949
<t.escapedName; format="cap">() antlr.TerminalNode<if(!t.signature)> {

0 commit comments

Comments
 (0)