parser

package
v0.5.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package parser is Krate's TSX/JSX parser. It parses ES2024 plus JSX into the ast package's tree and skips TypeScript-only syntax (annotations, generics, interfaces, type aliases, casts), counting each skipped construct in DroppedTypes. TypeScript constructs that carry runtime semantics and cannot be represented (enums, namespaces with values, parameter properties, decorators) are reported as diagnostics instead of being dropped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDiagnostics

func FormatDiagnostics(errs []error) string

Types

type Diagnostic

type Diagnostic = diag.Diagnostic

Diagnostic is an alias for the shared compiler diagnostic type.

type Parser

type Parser struct {
	Filename string
	// contains filtered or unexported fields
}

func New

func New(tokens []lexer.Token) *Parser

New creates a parser over a token stream produced by lexer.Tokenize. Whitespace tokens are dropped; layout information the parser needs is carried by Token.NewlineBefore.

func (*Parser) DroppedTypes added in v0.4.0

func (p *Parser) DroppedTypes() int

DroppedTypes reports how many type-only constructs the parse discarded.

func (*Parser) Errors

func (p *Parser) Errors() []error

func (*Parser) ParseProgram

func (p *Parser) ParseProgram() (prog *ast.Program)

ParseProgram parses the whole token stream.

func (*Parser) SetSource

func (p *Parser) SetSource(src string)

SetSource provides the original source so diagnostics can show the offending line.

Jump to

Keyboard shortcuts

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