Does Golang have LR(1) grammar?

Does Golang have LR(1) grammar? In other words, can any Golang code be parsed by LR(1) parser? If yes, can we get this grammar rules?

The question is about the latest Go versions 1.20+

I have tried to find Golang grammar or grammar type for the latest versions but have not found anything

Hi and welcome! A cool question :wink: ! Golang is been written keeping in mind the simplicity and self-hosting and fast compilation time capabilities of the language so a pure LR(1) specific grammar for external tools OR deduced by the recursive descending parser it uses is uncommon to see around the web. But Go has it’s deduced one technical spec, in Wirth notation as an EBNF, and reading it you can easily verify if some ambiguities are present or not (and I think there are). By nature of RDPs usually, if a pure notation is deduced, there shouldn’t be an ambiguity in it making it a suitable LR element (not sure! You can try).

No, Go does not have LR(1) grammar. This means that Go code cannot be parsed by an LR(1) parser. LR(1) parsers are a type of parser that can handle a limited amount of ambiguity in grammar. However, Go grammar is too ambiguous to be parsed by an LR(1) parser.