parser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestRefSimple

func TestRefSimple(t *testing.T)

Types

type Diagnostic

type Diagnostic struct {
	Span    source.Span
	Message string
	// Code classifies a warning for the consumers that report it; errors carry
	// the "syntax" code their reporters give them.
	Code string
	// Fixes are the unambiguous edits resolving the diagnostic, offered by an
	// editor as quick fixes.
	Fixes []quickfix.Fix
}

Diagnostic is a parser-emitted syntax error. It is unified with the pass/validation diagnostic model in Plan 4; kept local here to avoid a premature cross-package dependency.

type Parser

type Parser struct {

	// Diagnostics are syntax errors: input the parser could not read as
	// well-formed SysML.
	Diagnostics []Diagnostic
	// Warnings are findings on input that parsed into the tree the author
	// intended but is not well-formed SysML, such as a reserved keyword written
	// as a declaration name.
	Warnings []Diagnostic
	// contains filtered or unexported fields
}

Parser is a hand-written recursive-descent parser over a lexer token stream. It buffers non-trivia tokens for lookahead and collects diagnostics; it always produces a tree (ErrorNodes for bad input).

func New

func New(sf *source.SourceFile) *Parser

New creates a Parser for the given source file.

func (*Parser) Offset

func (p *Parser) Offset() int

Offset returns the source offset of the next unconsumed token, which is where a caller parsing a sequence of productions continues from. A node's span is not that position: a parenthesized expression's span is its contents.

func (*Parser) ParseExpression

func (p *Parser) ParseExpression() ast.Node

ParseExpression parses a full expression (conditional at the lowest level).

func (*Parser) ParseFile

func (p *Parser) ParseFile() *ast.RootNamespace

ParseFile parses the whole source as a RootNamespace (brace-less member list).

Jump to

Keyboard shortcuts

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