Documentation
¶
Overview ¶
Package parser turns .gwdk source files into syntax trees.
Index ¶
- Constants
- func ParseComponent(src []byte) (gwdkir.Component, error)
- func ParseLayout(path string, src []byte) (gwdkir.Layout, error)
- func ParsePage(source []byte) (gwdkir.Page, error)
- func ParsePageWithDefaultID(source []byte, defaultID string) (gwdkir.Page, error)
- type APIStatement
- type ActionStatement
- type BraceDepth
- type BuildCall
- type DiagnosticError
- type DiagnosticErrors
- type Emit
- type EmitParam
- type Export
- type GoFuncRef
- type GoTypeRef
- type LiteralRecord
- type Prop
- type StateContract
- type SyntaxBlock
- type SyntaxEndpoint
- type SyntaxFile
- type SyntaxFragmentEndpoint
- type SyntaxImport
- type SyntaxMetadata
- type SyntaxPackage
- type SyntaxUse
- type WASMContract
Constants ¶
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 ¶
ParseComponent extracts component metadata and top-level block declarations.
func ParseLayout ¶
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.
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 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 LiteralRecord ¶
type LiteralRecord = gwdkast.LiteralRecord
type StateContract ¶ added in v0.1.5
type StateContract = gwdkast.StateContract
type SyntaxBlock ¶
type SyntaxEndpoint ¶ added in v0.1.5
type SyntaxFile ¶
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 SyntaxMetadata ¶ added in v0.3.0
type SyntaxMetadata = gwdkast.MetadataDecl
type SyntaxPackage ¶ added in v0.1.5
type WASMContract ¶ added in v0.1.5
type WASMContract = gwdkast.WASMContract