dsl

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dsl is the boolean rule-expression engine: lexer, parser (! > && > ||), AST, dive splitting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsDiveToken

func ContainsDiveToken(input string, isRawArg IsRawArgFunc) bool

ContainsDiveToken reports whether a standalone `dive` leaf appears at any depth.

func DefaultIsRawArg

func DefaultIsRawArg(name string) bool

func HasTopLevelOr

func HasTopLevelOr(input string, isRawArg IsRawArgFunc) bool

HasTopLevelOr reports whether input has a `||` outside parentheses. Lex error yields true: safe to wrap a malformed expr before &&-joining.

func RemoveTopLevelLeaves

func RemoveTopLevelLeaves(input string, names map[string]bool, isRawArg IsRawArgFunc) string

RemoveTopLevelLeaves drops top-level bare-leaf segments whose name (or trimmed source) is in names, re-joining survivors with " && ". Lexer-driven so a separator inside a quoted/raw arg isn't mistaken for structural.

func SplitDive

func SplitDive(input string, isRawArg IsRawArgFunc) (container, element string, hasDive bool, err error)

SplitDive splits on a top-level standalone `dive` into container/element exprs. Malformed dive placement fails closed.

Types

type And

type And struct {
	L, R Node
}

And is logical conjunction: L && R.

type IsRawArgFunc

type IsRawArgFunc func(name string) bool

IsRawArgFunc reports whether a rule reads its argument raw (one arg, commas literal).

type Leaf

type Leaf struct {
	Name string
	Args []string
	Pos  int
}

Leaf is a single rule invocation, e.g. in:a,b,c.

type Node

type Node interface {
	// contains filtered or unexported methods
}

Node is a node in a parsed rule expression.

func Parse

func Parse(input string, isRawArg IsRawArgFunc) (Node, error)

Parse builds an AST from a rule expression. Precedence: ! > && > ||, left-associative.

type Not

type Not struct {
	X Node
}

Not is logical negation: !X.

type Or

type Or struct {
	L, R Node
}

Or is logical disjunction: L || R.

type ParseError

type ParseError struct {
	Pos int
	Msg string
}

ParseError is a lexing/parsing failure with its position.

func (*ParseError) Error

func (e *ParseError) Error() string

Jump to

Keyboard shortcuts

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