Skip to content

Commit

Permalink
Merge pull request #1204 from ritchiecarroll/master
Browse files Browse the repository at this point in the history
golang: Fixed issue parsing structures with functionType parameters
  • Loading branch information
teverett committed Aug 8, 2018
2 parents 046427d + 479c303 commit 5a5a72c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions golang/Golang.g4
Expand Up @@ -164,7 +164,7 @@ grammar Golang;

//SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .
sourceFile
: packageClause eos ( importDecl eos )* ( topLevelDecl eos)*
: packageClause eos ( importDecl eos )* ( topLevelDecl eos )*
;

//PackageClause = "package" PackageName .
Expand Down Expand Up @@ -553,7 +553,8 @@ functionType
;

signature
: parameters result?
: {noTerminatorAfterParams(1)}? parameters result
| parameters
;

result
Expand Down
14 changes: 14 additions & 0 deletions golang/examples/struct_with_func_type.go
@@ -0,0 +1,14 @@
package main

import "fmt"

type Person struct {
work func()
name string
age int32
}

func main() {
person := Person{work: nil, name: "Michał", age: 29}
fmt.Println(person) // {<nil> Michał 29}
}

0 comments on commit 5a5a72c

Please sign in to comment.