parser

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 9 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

CommandTypes is a list of the available commands that can be executed.

Functions

This section is empty.

Types

type Command

type Command struct {
	Type    CommandType
	Options string
	Args    string
}

Command represents a command with options and arguments.

func (Command) String

func (c Command) String() string

String returns the string representation of the command. This includes the options and arguments of the command.

type CommandType

type CommandType token.Type

CommandType is a type that represents a command.

func (CommandType) String

func (c CommandType) String() string

String returns the string representation of the command.

type Error

type Error struct {
	Token token.Token
	Msg   string
}

Error represents an error with parsing a tape file. It tracks the token causing the error and a human readable error message.

func NewError

func NewError(token token.Token, msg string) Error

NewError returns a new parser.Error with the given token and message.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

func (Error) String

func (e Error) String() string

String returns a human readable error message printing the token line number and message.

type Parser

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

Parser is the structure that manages the parsing of tokens.

func New

func New(l *lexer.Lexer) *Parser

New returns a new Parser.

func (*Parser) Errors

func (p *Parser) Errors() []Error

Errors returns any errors that occurred during parsing.

func (*Parser) Parse

func (p *Parser) Parse() []Command

Parse takes an input string provided by the lexer and parses it into a list of commands.

Jump to

Keyboard shortcuts

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