dsl

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 3 Imported by: 0

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