parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package parser implements a parser used by the Elk interpreter.

Parser expects a slice of bytes containing Elk source code parses it, registering any encountered errors, and returns an Abstract Syntax Tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(sourceName string, source string) (*ast.ProgramNode, diagnostic.DiagnosticList)

Parse the given source code and return an Abstract Syntax Tree. Main entry point to the parser.

Types

type Parser

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

Holds the current state of the parsing process.

func New

func New(sourceName string, source string) *Parser

Instantiate a new parser.

func (*Parser) Class

func (*Parser) Class() *value.Class

func (*Parser) Copy

func (p *Parser) Copy() value.Reference

func (*Parser) DirectClass

func (*Parser) DirectClass() *value.Class

func (*Parser) Error

func (p *Parser) Error() string

func (*Parser) Inspect

func (p *Parser) Inspect() string

func (*Parser) InstanceVariables

func (p *Parser) InstanceVariables() *value.InstanceVariables

func (*Parser) IsIncomplete

func (p *Parser) IsIncomplete() bool

Returns true when the parser had finished early because of an END_OF_FILE token.

func (*Parser) Parse

Start the parsing process from the top.

func (*Parser) ShouldIndent

func (p *Parser) ShouldIndent() bool

Returns true when the parser had finished early because of an END_OF_FILE token and the following code should be indented.

func (*Parser) SingletonClass

func (p *Parser) SingletonClass() *value.Class

type Result

type Result struct {
	AST         *ast.ProgramNode
	Diagnostics diagnostic.DiagnosticList
}

func (*Result) Class

func (*Result) Class() *value.Class

func (*Result) Copy

func (r *Result) Copy() value.Reference

func (*Result) DirectClass

func (*Result) DirectClass() *value.Class

func (*Result) Error

func (r *Result) Error() string

func (*Result) Inspect

func (r *Result) Inspect() string

func (*Result) InstanceVariables

func (r *Result) InstanceVariables() *value.InstanceVariables

func (*Result) SingletonClass

func (r *Result) SingletonClass() *value.Class

Directories

Path Synopsis
ast
Package ast defines types used by the Elk parser.
Package ast defines types used by the Elk parser.

Jump to

Keyboard shortcuts

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