grammar

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugSetting

type DebugSetting int

DebugSetting is the debug setting.

const (
	// ShowNone shows no debug information.
	ShowNone DebugSetting = 0

	// ShowLex shows the lexer debug information.
	ShowLex DebugSetting = 1

	// ShowTree shows the parser debug information.
	ShowTree DebugSetting = 2

	// ShowAst shows the ast debug information.
	ShowAst DebugSetting = 4

	// ShowData shows the file reader debug information.
	ShowData DebugSetting = 8

	// ShowAll shows all debug information.
	ShowAll DebugSetting = ShowLex | ShowTree | ShowAst | ShowData

	// ShowParsing runs the parser step by step.
	ShowParsing DebugSetting = 16
)

type Parser

type Parser[T interface {
	comparable
	DirectChild() iter.Seq[T]
	BackwardChild() iter.Seq[T]
	ast.Noder
}, S grammar.TokenTyper] struct {
	// contains filtered or unexported fields
}

Parser is the parser of the grammar.

func (*Parser[T, S]) Init

func (p *Parser[T, S]) Init(lex lexing.Lexer[S], prs parsing.Parser[S], b ast.Make[T, S])

Init initializes the parser with the given lexer, parser and builder.

Parameters:

  • l: The lexer.
  • p: The parser.
  • b: The ast builder.

Also, by default no debug information is shown. Use SetDebug to show debug information.

func (Parser[T, S]) Parse

func (p Parser[T, S]) Parse(data []byte) (T, error)

Parse parses the given data and returns the AST tree.

Parameters:

  • data: The data to parse.

Returns:

  • T: The AST tree.
  • error: An error if the parsing failed.

func (*Parser[T, S]) SetDebug

func (p *Parser[T, S]) SetDebug(debug DebugSetting)

SetDebug sets the debug setting.

Parameters:

  • debug: The debug setting.

Directories

Path Synopsis
Code generated by go generate; do not edit.
Code generated by go generate; do not edit.
cmd
pkg

Jump to

Keyboard shortcuts

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