parser

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

type Lexer struct {
	Input []rune
	// contains filtered or unexported fields
}

Lexer performs lexical analysis/scanning of the JSON

func NewLexer

func NewLexer(input string) *Lexer

NewLexer creates and returns a pointer to the Lexer

func (*Lexer) NextToken

func (l *Lexer) NextToken() model.Token

NextToken switches through the lexer's current char and creates a new model. It then it calls readChar to advance the lexer and it returns the token.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser holds a Lexer, errors, the currentToken, and the peekToken (next token). Parser methods handle iterating through tokens and building and AST.

func NewParser

func NewParser() *Parser

NewParser creates a new Parser instance.

func (*Parser) Errors

func (p *Parser) Errors() string

Errors is simply a helper function that returns the parser's errors

func (*Parser) ParseValidation

func (p *Parser) ParseValidation(validation string) (model.RootNode, error)

ParseValidation parses tokens and creates an AST. It returns the RootNode which holds a Value and in it the rest of the tree. It creates a new Lexer for reset lexer state and initializes the parser's tokens. It returns an error if the parsing fails.

Jump to

Keyboard shortcuts

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