parser

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package parser provides command and expression parsing.

Index

Constants

View Source
const (
	CharacterToken = "character"
	ParameterToken = "parameter"
	EOFToken       = "eof"
)

Variables

This section is empty.

Functions

func SyntaxCheck

func SyntaxCheck(define string, actual []*Token) (bool, error)

Types

type Lexer

type Lexer struct {
	Scanner
}

func NewLexer

func NewLexer(text []rune) *Lexer

func (*Lexer) GetNextToken

func (l *Lexer) GetNextToken() (*Token, error)

func (*Lexer) String

func (l *Lexer) String() (*Token, error)

type Scanner added in v0.92.0

type Scanner struct {
	Text        []rune
	Pos         int
	CurrentChar rune
	LineNo      int
	Column      int
}

Scanner holds the shared cursor state and common scanning methods for tokenizers.

func NewScanner added in v0.92.0

func NewScanner(text []rune) Scanner

NewScanner initializes a Scanner with the given input text.

func (*Scanner) Advance added in v0.92.0

func (s *Scanner) Advance()

Advance moves the cursor forward by one rune, tracking line and column numbers.

func (*Scanner) Character added in v0.92.0

func (s *Scanner) Character() (*Token, error)

Character consumes a run of non-space characters into a Token.

func (*Scanner) Peek added in v0.92.0

func (s *Scanner) Peek() rune

Peek returns the next rune without advancing the cursor.

func (*Scanner) SkipWhitespace added in v0.92.0

func (s *Scanner) SkipWhitespace()

SkipWhitespace advances past all whitespace characters.

type Syntax

type Syntax struct {
	Scanner
}

func NewSyntax

func NewSyntax(text []rune) *Syntax

func (*Syntax) GetNextToken

func (l *Syntax) GetNextToken() (*Token, error)

func (*Syntax) Parameter

func (l *Syntax) Parameter() (*Token, error)

type Token

type Token struct {
	Type   string
	Value  Value
	LineNo int
	Column int
}

func ParseString

func ParseString(in string) ([]*Token, error)

type Value

type Value struct {
	Source any
}

func Variable

func Variable(i any) Value

func (Value) Bool

func (v Value) Bool() (bool, bool)

func (Value) Int64

func (v Value) Int64() (int64, bool)

func (Value) String

func (v Value) String() (string, bool)

Jump to

Keyboard shortcuts

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