dsl

package
v0.264.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dsl provides syntax highlighting and syntax-error diagnostics for OpenFGA DSL text, built on the openfga/language ANTLR lexer and parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Highlight

func Highlight(dsl string) string

Highlight returns dsl with each colored run wrapped in a lipgloss style. Stripping ANSI from Highlight(x) yields exactly x.

Types

type Cell

type Cell struct {
	R     rune
	Color color.Color
}

Cell is a single source rune paired with its syntax color (nil = default foreground). Cells preserves every rune of the input in order, including whitespace, newlines, and comments (which have a style.Faintc Color).

func Cells

func Cells(dsl string) []Cell

Cells lexes dsl with the ANTLR lexer and returns per-rune colors. Text the lexer skips or hides (whitespace, newlines) is preserved with a nil Color by filling gaps between token character offsets. Comments are dimmed (style.Faintc).

type Diagnostic

type Diagnostic struct {
	Line int
	Col  int
	Msg  string
}

Diagnostic is a single syntax error located in DSL source. Line and Col are zero-based (Line matches the library's stored line index; render as Line+1, Col+1 for humans).

func Diagnostics

func Diagnostics(dsl string) []Diagnostic

Diagnostics parses dsl and returns one Diagnostic per syntax error, or nil when the DSL is syntactically valid. It performs no semantic validation.

func UndefinedTypeDiagnostics

func UndefinedTypeDiagnostics(dsl string) []Diagnostic

UndefinedTypeDiagnostics returns a diagnostic for each reference to a type that is not declared in the DSL (e.g. `[user]` when there is no `type user`). It validates types only, not relations. It should be called only when the DSL has no syntax errors, so the token stream is reliable.

Jump to

Keyboard shortcuts

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