parser

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package parser turns .gwdk source files into syntax trees.

Index

Constants

View Source
const (
	DiagnosticMalformedGOWDKUse            = "malformed_gowdk_use"
	DiagnosticMalformedLegacyMetadata      = "malformed_legacy_metadata"
	DiagnosticOldActionBlockSyntax         = "old_action_block_syntax"
	DiagnosticOldAPIBlockSyntax            = "old_api_block_syntax"
	DiagnosticPackageMustBeFirst           = "package_must_be_first"
	DiagnosticUnsupportedLiteralRecord     = "unsupported_literal_record_syntax"
	DiagnosticUnsupportedTopLevelBlock     = "unsupported_top_level_block"
	DiagnosticUnsupportedLayoutMetadata    = "unsupported_layout_metadata"
	DiagnosticInvalidComponentProp         = "invalid_component_prop"
	DiagnosticUnsupportedComponentPropType = "unsupported_component_prop_type"
)

Variables

This section is empty.

Functions

func ParseComponent

func ParseComponent(src []byte) (gwdkir.Component, error)

ParseComponent extracts component metadata and top-level block declarations.

func ParseLayout

func ParseLayout(path string, src []byte) (gwdkir.Layout, error)

ParseLayout extracts layout metadata and top-level block declarations. Layout identity is derived from the file name (`root.layout.gwdk` -> `root`); any `layout` metadata declaration declares parent layouts this layout nests within.

func ParsePage

func ParsePage(source []byte) (gwdkir.Page, error)

ParsePage extracts page metadata and top-level block declarations.

func ParsePageWithDefaultID added in v0.2.6

func ParsePageWithDefaultID(source []byte, defaultID string) (gwdkir.Page, error)

ParsePageWithDefaultID extracts page metadata and uses defaultID when the source omits page.

Types

type APIStatement

type APIStatement = gwdkast.APIStatement

type ActionStatement

type ActionStatement = gwdkast.ActionStatement

type BraceDepth added in v0.3.0

type BraceDepth struct {
	// contains filtered or unexported fields
}

BraceDepth tracks net brace depth across the lines of a .gwdk file for tooling such as the formatter, skipping braces that appear inside string literals, comments, Go raw strings, and JS template literals. It carries multi-line state across Delta calls. It uses Go lexical rules, which cover the top-level `.gwdk` surface and Go/JS block bodies; the one accepted edge is a `//` sequence inside a CSS value (e.g. a `url(http://...)`), which truncates brace counting for the rest of that line only.

func NewBraceDepth added in v0.3.0

func NewBraceDepth() *BraceDepth

NewBraceDepth returns a brace-depth tracker using Go lexical rules.

func (*BraceDepth) Delta added in v0.3.0

func (b *BraceDepth) Delta(line string) int

Delta scans one line and returns the net change in brace depth it contributes, skipping braces inside strings and comments.

func (*BraceDepth) InMultiline added in v0.3.0

func (b *BraceDepth) InMultiline() bool

InMultiline reports whether the tracker is currently inside a multi-line construct (block comment, Go raw string, or JS template literal). A line that is textually "}" while InMultiline is body content, not a block terminator.

type BuildCall

type BuildCall = gwdkast.BuildCall

type DiagnosticError added in v0.3.0

type DiagnosticError struct {
	Code    string
	Span    source.SourceSpan
	Message string
}

DiagnosticError carries parser diagnostic metadata without forcing callers to recover line numbers and codes by parsing Error strings.

func ParserDiagnostic added in v0.3.0

func ParserDiagnostic(err error) (*DiagnosticError, bool)

ParserDiagnostic extracts a typed parser diagnostic from err when available.

func ParserDiagnostics added in v0.3.0

func ParserDiagnostics(err error) []*DiagnosticError

ParserDiagnostics extracts every typed parser diagnostic from err. Untyped parse failures are returned as nil entries by callers through their fallback diagnostic path.

func (*DiagnosticError) Error added in v0.3.0

func (err *DiagnosticError) Error() string

type DiagnosticErrors added in v0.3.0

type DiagnosticErrors []error

DiagnosticErrors carries every parser diagnostic recovered from one file.

func (DiagnosticErrors) Error added in v0.3.0

func (errs DiagnosticErrors) Error() string

func (DiagnosticErrors) Unwrap added in v0.3.0

func (errs DiagnosticErrors) Unwrap() []error

type Emit added in v0.1.5

type Emit = gwdkast.Emit

type EmitParam added in v0.1.5

type EmitParam = gwdkast.EmitParam

type Export added in v0.1.5

type Export = gwdkast.Export

type GoFuncRef added in v0.1.5

type GoFuncRef = gwdkast.GoFuncRef

type GoTypeRef added in v0.1.5

type GoTypeRef = gwdkast.GoTypeRef

type LiteralRecord

type LiteralRecord = gwdkast.LiteralRecord

type Prop added in v0.1.5

type Prop = gwdkast.Prop

type StateContract added in v0.1.5

type StateContract = gwdkast.StateContract

type SyntaxBlock

type SyntaxBlock = gwdkast.Block

type SyntaxEndpoint added in v0.1.5

type SyntaxEndpoint = gwdkast.Endpoint

type SyntaxFile

type SyntaxFile = gwdkast.File

func ParseSyntax

func ParseSyntax(src []byte) (SyntaxFile, error)

ParseSyntax parses a .gwdk source file into a typed syntax AST for the current compiler subset.

type SyntaxFragmentEndpoint added in v0.1.5

type SyntaxFragmentEndpoint = gwdkast.FragmentEndpoint

type SyntaxImport

type SyntaxImport = gwdkast.Import

type SyntaxMetadata added in v0.3.0

type SyntaxMetadata = gwdkast.MetadataDecl

type SyntaxPackage added in v0.1.5

type SyntaxPackage = gwdkast.Package

type SyntaxUse added in v0.1.5

type SyntaxUse = gwdkast.Use

type WASMContract added in v0.1.5

type WASMContract = gwdkast.WASMContract

Jump to

Keyboard shortcuts

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