parser

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package parser implements spok's parser.

Spok is a very simple mostly declarative language and as such, the parser is incredibly simple. It is a simple top-down parser with a very small initial state space and requires only 1 token of lookahead.

It switches on the token it encounters to process the appropriate ast.Node (parseXXX methods), appending each to the list of nodes as it goes.

If the parser encounters an error, either an ERROR token from the lexer, or an error of it's own making it will immediately return with the AST it's managed to parse so far and the error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

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

Parser is spok's AST parser.

func New

func New(input string) *Parser

New creates and returns a new Parser for an input string.

func (*Parser) Parse

func (p *Parser) Parse() (ast.Tree, error)

Parse is the top level parse method. It parses the entire input text to EOF or Error and returns the full AST.

Jump to

Keyboard shortcuts

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