Skip to content

Commit

Permalink
Add support to Golang codegen for booleans
Browse files Browse the repository at this point in the history
Signed-off-by: Michael de Hoog <michael.dehoog@coinbase.com>
  • Loading branch information
mdehoog authored and parrt committed Apr 18, 2023
1 parent 6e89287 commit 5995022
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
GoTypeMap ::= [
"boolean":"bool",
default : key
]

fileHeader(grammarFileName, ANTLRVersion) ::= <<
// Code generated from <grammarFileName> by ANTLR <ANTLRVersion>. DO NOT EDIT.
>>
Expand Down Expand Up @@ -931,14 +936,14 @@ SetNonLocalAttr(s, rhsChunks) ::= "p.GetInvokingContext(<s.ruleIndex>).(*<s.rule

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

TokenDecl(t) ::= "<t.escapedName> <TokenLabelType()>"
TokenDecl(t) ::= "<t.escapedName> <GoTypeMap.(TokenLabelType())>"
TokenTypeDecl(t) ::= "<t.escapedName> int"
TokenListDecl(t) ::= "<t.escapedName> []antlr.Token"

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

AttributeDecl(d) ::= "<d.escapedName> <d.type><if(d.initValue)>// TODO = <d.initValue><endif>"
AttributeDecl(d) ::= "<d.escapedName> <GoTypeMap.(d.type)><if(d.initValue)>// TODO = <d.initValue><endif>"

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

0 comments on commit 5995022

Please sign in to comment.