parser

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package parser implements the Vibescript lexer and recursive-descent parser. It produces an AST (see internal/ast) from .vibe source text and is not part of the embedder API surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MemberReceiverFor added in v0.60.0

func MemberReceiverFor(source, probe string) (ast.Expression, []ast.Param, bool)

MemberReceiverFor parses source and returns the receiver expression of the member access whose property is probe, together with the parameters of the function whose body encloses it.

Editor tooling needs the receiver at the cursor, and a bare trailing dot -- exactly what the buffer holds when completion fires -- is a syntax error that yields no member node at all. The caller therefore splices a probe name in at the cursor and asks for that member here.

The receiver is captured while parsing rather than found afterwards: the parser holds it at the moment it builds the member access, so recovering it later would mean walking the tree, and this package exposes no traversal. Parse errors elsewhere in the document are ignored, since a buffer under edit rarely parses cleanly as a whole.

func Parse

func Parse(source string) (*ast.Program, []error)

Parse lexes and parses the given source text and returns the resulting AST together with any parse errors encountered. It is the stable entry point used by callers within the module.

func ParseTypeExpr added in v0.60.0

func ParseTypeExpr(source string) (*ast.TypeExpr, error)

ParseTypeExpr parses a standalone type annotation spelling ("array<int>", "{ name: string }", "int | nil") the way parameter and return annotations parse inside a script. The whole input must be a single type expression.

Types

type Lexer

type Lexer = lexer

Lexer is the public name for the package-private lexer state.

func NewLexer

func NewLexer(input string) *Lexer

NewLexer returns a new lexer over the given source text.

Jump to

Keyboard shortcuts

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