parser

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package parser — build-tag scanning.

ExtractBuildTags reads the leading contiguous comment block of a `.hzn` source file and pulls out any `//hzn:build <expr>` directives. Multiple directives are caller-ANDed (the matcher in `compiler/buildmatrix.go` joins them with `&&`). Scanning stops at the first non-comment, non-blank line — directives after the `package` clause are ignored.

The scanner is intentionally permissive of leading whitespace (a `.hzn` file authored with a stray indent on the directive line still parses) and of non-directive comment lines (doc comments interleaved with directives do not break the scan). The directive prefix is `//hzn:build ` (note the trailing space) — `//hzn:buildx`-style pseudo-directives are skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractBuildTags added in v0.3.0

func ExtractBuildTags(source []byte) []string

ExtractBuildTags returns the list of `//hzn:build <expr>` expressions declared in the leading comment block of source, in source order. Returns an empty slice when no directives are present.

func NodeText

func NodeText(n *gotreesitter.Node, source []byte) string

Types

type File

type File struct {
	Source  SourceFile
	Tree    *gotreesitter.Tree
	Lang    *gotreesitter.Language
	Package string
}

func ParsePath

func ParsePath(path string) (*File, error)

func ParseSource

func ParseSource(source SourceFile) (*File, error)

type ParseError

type ParseError struct {
	Path      string
	Line      int
	Column    int
	EndLine   int
	EndColumn int
	StartByte int
	EndByte   int
	Message   string
}

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Span

func (e *ParseError) Span() span.Span

type SourceFile

type SourceFile struct {
	Path   string
	Bytes  []byte
	FileID span.FileID
}

func ReadSource

func ReadSource(path string) (SourceFile, error)

Jump to

Keyboard shortcuts

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