parser

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package parser defines basic parser utilities. It defines a parser type which may be embedded to create specialized parsers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	Token lexer.Token
	Lexer lexer.Lexer
}

Parser is an embeddable type that contains parsing utilities. It is used to build more specialized parsers.

func (*Parser) EOF

func (this *Parser) EOF() bool

EOF returns whether or not the lexer has been exhausted.

func (*Parser) Expect

func (this *Parser) Expect(allowed ...lexer.TokenKind) error

Expect checks the current token to see if it matches a list of token kind(s), else it returns an error describing what it expected.

func (*Parser) ExpectDesc

func (this *Parser) ExpectDesc(description string, allowed ...lexer.TokenKind) error

ExpectDesc is like Expect, but the expected entitie(s) are described manually. This can be helpful when a large syntactical entity is expected and the first token(s) of it would offer useless information to the user.

func (*Parser) ExpectNext

func (this *Parser) ExpectNext(allowed ...lexer.TokenKind) error

ExpectNext is like Expect, but gets the next token first.

func (*Parser) ExpectNextDesc

func (this *Parser) ExpectNextDesc(description string, allowed ...lexer.TokenKind) error

ExpectNextDesc is like ExpectDesc, but gets the next token first.

func (*Parser) ExpectValue

func (this *Parser) ExpectValue(kind lexer.TokenKind, allowed ...string) error

ExpectValue returns an error if the current token's value does not match the allowed values.

func (*Parser) ExpectValueDesc

func (this *Parser) ExpectValueDesc(description string, kind lexer.TokenKind, allowed ...string) error

ExpectValueDesc is like ExpectValue, but the expected value(s) are described manually.

func (*Parser) Is

func (this *Parser) Is(allowed ...lexer.TokenKind) bool

Is returns whether or not the current token matches any of the given kinds.

func (*Parser) Kind

func (this *Parser) Kind() lexer.TokenKind

Kind returns the token kind of the current token.

func (*Parser) Next

func (this *Parser) Next() error

Next consumes a token from the lexer, and sets it as the current token.

func (*Parser) Pos

func (this *Parser) Pos() errors.Position

Pos returns the position of the current token.

func (*Parser) Value

func (this *Parser) Value() string

Value returns the value of the current token.

func (*Parser) ValueIs

func (this *Parser) ValueIs(allowed ...string) bool

ValueIs returns whether or not the current token matches any of the given values.

Directories

Path Synopsis
Package fsplParser implements the parsing stage of the FSPL compiler.
Package fsplParser implements the parsing stage of the FSPL compiler.
Package metaParser provides parsing for FSPL module metadata files.
Package metaParser provides parsing for FSPL module metadata files.

Jump to

Keyboard shortcuts

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