glr support in goyacc?

230 views
Skip to first unread message

David Wahlstedt

unread,
Mar 8, 2018, 1:44:04 PM3/8/18
to golang-nuts
Hi,
I wonder if there are any plans to add the "glr" option to goyacc (it doesn't look as if this is the case) ?

According to this thread,

golang is "not LALR(1), nor LR(k) for any k".

So, if golang has been bootstrapped, compiled with itself, how did they write the parser?
By hand, or by using an LR parser and tweaking the grammar?

Then, shouldn't be a good idea for goyacc to have "glr" support, as there is in e.g. bison?

Sorry if my question is naive (it is, probably), I am new to golang.

BR,
David

Jan Mercl

unread,
Mar 8, 2018, 2:06:44 PM3/8/18
to David Wahlstedt, golang-nuts
On Thu, Mar 8, 2018 at 7:44 PM David Wahlstedt <david.wah...@gmail.com> wrote:

> So, if golang has been bootstrapped, compiled with itself, how did they write the parser?
> By hand, or by using an LR parser and tweaking the grammar?

Go authors initially used a modified grammar (distilled version at https://github.com/cznic/gc/blob/b007e32c610fc39d850653c9b09d7515507f2b6e/testdata/parser/parser.y) in combination with a simple transformation of the input token stream in the lexer (functionally equivalent Go implementation can be seen also at https://github.com/cznic/gc/blob/b007e32c610fc39d850653c9b09d7515507f2b6e/all_test.go#L976).

Nowadays the gc uses a handwritten parser, so the class of the language no more matters [that much]. (Alternative experimental implementation also at https://github.com/cznic/gc/blob/b007e32c610fc39d850653c9b09d7515507f2b6e/parser.go)

IMHO, GLR would be an overkill for a Go parser.



--

-j

David Wahlstedt

unread,
Mar 9, 2018, 3:27:56 AM3/9/18
to golang-nuts
Ok, I see!

But it would still be nice to have GLR in goyacc, for instance in order to write an ASN.1 parser.

Ian Lance Taylor

unread,
Mar 9, 2018, 8:47:59 AM3/9/18
to David Wahlstedt, golang-nuts
On Fri, Mar 9, 2018 at 12:27 AM, David Wahlstedt
<david.wah...@gmail.com> wrote:
>
> But it would still be nice to have GLR in goyacc, for instance in order to
> write an ASN.1 parser.

I'm not aware of anybody working on that.

Ian

David Wahlstedt

unread,
Mar 12, 2018, 4:23:12 AM3/12/18
to golang-nuts
There are people working on it. This for instance:

Furthermore, if you want to write telecom applications in go(where ASN.1 is common), it is quite natural to want an ASN.1 parser.

BR,
David

Matt Harden

unread,
Mar 18, 2018, 4:02:15 PM3/18/18
to David Wahlstedt, golang-nuts
I believe Ian was saying he's not aware of anybody working on adding GLR support to goyacc.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages