Getting started with gocc

298 views
Skip to first unread message

Tong Sun

unread,
Jan 9, 2022, 12:37:53 PM1/9/22
to golang-nuts
Hi,

I'm following with
https://github.com/goccmack/gocc/blob/master/doc/gocc_user_guide.pdf

and I'm at the step of trying to install gocc:

```
$ go get -v github.com/goccmack/gocc
github.com/goccmack/gocc (download)
get "golang.org/x/mod/modfile": found meta tag
vcs.metaImport{Prefix:"golang.org/x/mod", VCS:"git",
RepoRoot:"https://go.googlesource.com/mod"} at
//golang.org/x/mod/modfile?go-get=1
get "golang.org/x/mod/modfile": verifying non-authoritative meta tag
golang.org/x/mod (download)
cannot find package "golang.org/x/mod/modfile" in any of:
/usr/lib/go-1.17/src/golang.org/x/mod/modfile (from $GOROOT)
/.../Go/src/golang.org/x/mod/modfile (from $GOPATH)

$ go get -v golang.org/x/mod/modfile
get "golang.org/x/mod/modfile": found meta tag
vcs.metaImport{Prefix:"golang.org/x/mod", VCS:"git",
RepoRoot:"https://go.googlesource.com/mod"} at
//golang.org/x/mod/modfile?go-get=1
get "golang.org/x/mod/modfile": verifying non-authoritative meta tag
golang.org/x/mod (download)
cannot find package "golang.org/x/mod/modfile" in any of:
/usr/lib/go-1.17/src/golang.org/x/mod/modfile (from $GOROOT)
/.../Go/src/golang.org/x/mod/modfile (from $GOPATH)

$ go get -v golang.org/x/mod/
package golang.org/x/mod: no Go files in /.../Go/src/golang.org/x/mod
```

How to overcome such hurdle? thx!

Brian Candler

unread,
Jan 9, 2022, 1:26:04 PM1/9/22
to golang-nuts
Try this instead:
Reference:
go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

Tong Sun

unread,
Jan 9, 2022, 4:26:09 PM1/9/22
to golang-nuts
and I'm at the step of trying to provide my own ast:

For a single bnf of:

Hello: "hello" id << ast.NewHello($1) >> ;

(https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/hello.bnf)

How to provide the corresponding ast.go?

My first try was:

https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/ast/ast.go

and I've made several other attempts, but still unable to make it work.

please help.

On Sun, Jan 9, 2022 at 12:37 PM Tong Sun wrote:

> How to overcome such hurdle? thx!

Set

GO111MODULE=on

fixed it.

Ian Lance Taylor

unread,
Jan 9, 2022, 4:56:44 PM1/9/22
to Tong Sun, golang-nuts
On Sun, Jan 9, 2022, 1:26 PM Tong Sun <sunto...@gmail.com> wrote:
Hi,

I'm following with
https://github.com/goccmack/gocc/blob/master/doc/gocc_user_guide.pdf

and I'm at the step of trying to provide my own ast:

For a single bnf of:

Hello:  "hello" id << ast.NewHello($1) >> ;

(https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/hello.bnf)

How to provide the corresponding ast.go?

My first try was:

https://github.com/suntong/lang/blob/master/lang/Go/src/parsers/gocc/ex3-hello/ast/ast.go

and I've made several other attempts, but still unable to make it work.

These kinds of questions might be better directed to the people who maintain gocc.  I don't know whether they read this mailing list, which is about the Go language in general.

Ian

Tong Sun

unread,
Jan 9, 2022, 4:58:46 PM1/9/22
to Ian Lance Taylor, golang-nuts
OK, I'll keep that in mind next time. BTW, I've fixed it --

https://github.com/suntong/lang/tree/master/lang/Go/src/parsers/gocc/ex3-hello
Reply all
Reply to author
Forward
0 new messages