Help us shape the future of Go! Take the 2026 Go Developer Survey

parse

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parse is the hand-written recursive-descent port of the pinned grammar (internal/reference/gram.y, libpg_query 18.0.0). One parse* method per production, each with an attribution comment naming the gram.y rule it implements; the support functions at the bottom of gram.y live in gram_support.go with the same names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(input string) (res *ast.ParseResult, err *lexer.Error)

Parse is raw_parser for RAW_PARSE_DEFAULT: parse_toplevel/stmtmulti.

func ParseTracked

func ParseTracked(input string) (res *ast.ParseResult, emptyStrings map[any]bool, err *lexer.Error)

ParseTracked is Parse plus the present-but-empty string set (see parser.emptyStrings) for the fingerprint walk.

func ParseTypeName

func ParseTypeName(input string) (res *ast.TypeName, err *lexer.Error)

ParseTypeName is raw_parser for RAW_PARSE_TYPE_NAME: parse_toplevel: MODE_TYPE_NAME Typename. The result is the bare TypeName (libpg_query's plpgsql support calls this through typeStringToTypeName).

func ParseWithMode

func ParseWithMode(input string, mode Mode) (res *ast.ParseResult, err *lexer.Error)

ParseWithMode is raw_parser: parse_toplevel's MODE_* alternatives, each wrapping its result in a RawStmt exactly as the grammar actions do.

func SystemFuncName

func SystemFuncName(name string) []*ast.Node

gram.y: SystemFuncName

func SystemTypeName

func SystemTypeName(name string) *ast.TypeName

gram.y: SystemTypeName

Types

type Mode

type Mode int

Mode mirrors RawParseMode for the entry points raw_parser exposes beyond RAW_PARSE_DEFAULT. The PL/pgSQL compiler's check_sql_expr drives the non-default modes; RAW_PARSE_TYPE_NAME has no caller here (libpg_query mocks parse_datatype away).

const (
	ModeDefault Mode = iota
	ModeTypeName
	ModePlpgsqlExpr
	ModePlpgsqlAssign1
	ModePlpgsqlAssign2
	ModePlpgsqlAssign3
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL