Documentation
¶
Overview ¶
Package parser exposes the public Parse / ParseString entry points and the typed ParseError returned on failure. Implementation lives in parser.go and translate.go.
ParseError is re-exported from the top-level gobash package as gobash.ParseError via a type alias so consumers can use either spelling interchangeably (see errors.go in the root package).
Index ¶
Constants ¶
const ( // MaxInputSize caps the byte length of a single Parse call. MaxInputSize = 1 << 20 // 1 MiB // MaxTokens caps the number of syntax-tree nodes the parser walks // after a successful parse. We count syntax.Walk visits. MaxTokens = 100000 // MaxParserDepth caps how deep the translator may recurse while // walking nested commands / words / heredocs. MaxParserDepth = 200 // MaxHeredocSize caps the body of any single here-document. // Mirrors the DefaultLimits().MaxHeredocSize used at runtime. MaxHeredocSize = 10 * 1024 * 1024 )
Parser-side hard limits enforced by Parse / ParseString. The values are law; do not adjust without updating The spec.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses src into a typed *ast.Script, enforcing the parser-side hard limits in this package. Returns *ParseError on failure.
func ParseString ¶
ParseString is an alias for Parse, mirroring src/parser/parser.ts.
Types ¶
type Limits ¶
Limits controls parser input and heredoc budgets. A zero value is a real zero-byte budget; use DefaultLimits for the compatibility defaults.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns the parser budgets used by Parse.
type ParseError ¶
ParseError reports a syntactic parse failure produced by the parser front-end. Line and Col are 1-based when known and 0 when the parser did not supply a position.
func (*ParseError) Error ¶
func (e *ParseError) Error() string