parser

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 7 Imported by: 0

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