parser

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Group states
	GrpStart state = iota
	GrpOpen
	GrpEnd

	// Condition states
	ConType
	ConValue
	ConEnd
)

Available states for each type used in parsing

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(l *Lexer) *Parser

New takes a Lexer, creates a Parser with that Lexer, sets the current token and the peek token and returns the Parser.

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() (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.

Jump to

Keyboard shortcuts

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