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 ¶
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.