Go 2026-06

Source: golang/GoParser.g4 @ 5a9a89fa7274878bdb93877c4be5d56859c08e5e (5a9a89f) / antlr4 antlr4-parser-v1 / 2026-06-20

These diagrams describe a parser grammar, rather than the complete language specification. Lexer state and semantic checks may impose additional restrictions.

This is an upstream ANTLR grammar snapshot. Its date identifies the grammar revision, rather than a language release.

BSD-3-Clause

Readable Original grammar

sourceFile

packageClause

packageName

identifier

importDecl

importSpec

importPath

declaration

constDecl

constSpec

identifierList

expressionList

typeDecl

typeSpec

aliasDecl

typeDef

typeParameters

typeParameterDecl

typeElement

typeTerm

functionDecl

methodDecl

receiver

varDecl

varSpec

block

statementList

statement

simpleStmt

expressionStmt

sendStmt

incDecStmt

assignment

assign_op

shortVarDecl

labeledStmt

returnStmt

breakStmt

continueStmt

gotoStmt

fallthroughStmt

deferStmt

ifStmt

switchStmt

exprSwitchStmt

exprCaseClause

exprSwitchCase

typeSwitchStmt

typeSwitchGuard

typeCaseClause

typeSwitchCase

typeList

selectStmt

commClause

commCase

recvStmt

forStmt

condition

forClause

rangeClause

goStmt

type_

typeArgs

typeName

typeLit

arrayType

arrayLength

elementType

pointerType

interfaceType

sliceType

mapType

channelType

methodSpec

functionType

signature

result

parameters

parameterDecl

expression

primaryExpr

conversion

operand

literal

basicLit

integer

operandName

qualifiedIdent

compositeLit

literalType

literalValue

elementList

keyedElement

key

element

structType

fieldDecl

string_

embeddedField

functionLit

index

slice_

typeAssertion

arguments

methodExpr

eos

sourceFile__1

sourceFile__2

sourceFile__3

importDecl__1

importDecl__2

importSpec__1

constDecl__1

constDecl__2

constSpec__1

constSpec__2

identifierList__1

expressionList__1

typeDecl__1

typeDecl__2

aliasDecl__1

typeDef__1

typeParameters__1

typeParameters__2

typeElement__1

typeTerm__1

functionDecl__1

functionDecl__2

methodDecl__1

varDecl__1

varDecl__2

varSpec__1

varSpec__2

statementList__1

statementList__2

incDecStmt__1

assign_op__1

labeledStmt__1

returnStmt__1

breakStmt__1

continueStmt__1

ifStmt__1

ifStmt__2

ifStmt__3

ifStmt__4

ifStmt__5

exprSwitchStmt__1

exprSwitchStmt__2

exprSwitchStmt__3

exprSwitchStmt__4

exprSwitchStmt__5

typeSwitchStmt__1

typeSwitchStmt__2

typeSwitchGuard__1

typeList__1

typeList__2

typeList__3

selectStmt__1

commCase__1

recvStmt__1

forStmt__1

forClause__1

forClause__2

forClause__3

rangeClause__1

type___1

typeArgs__1

interfaceType__1

interfaceType__2

channelType__1

signature__1

parameters__1

parameters__2

parameters__3

parameterDecl__1

parameterDecl__2

expression__1

expression__2

expression__3

expression__4

primaryExpr__1

primaryExpr__2

conversion__1

operand__1

literalType__1

literalValue__1

literalValue__2

elementList__1

keyedElement__1

structType__1

fieldDecl__1

fieldDecl__2

embeddedField__1

embeddedField__2

slice___1

slice___2

slice___3

slice___4

arguments__1

arguments__2

arguments__3

arguments__4

arguments__5

Keyboard shortcuts

/ focuses search. j and k move between rules. ? opens this help. Escape closes it.