ast

package
v0.0.0-...-438179e Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: GPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package ast provides the functionality and data structures around the Serene's AST.

Index

Constants

This section is empty.

Variables

View Source
var OutOfRangeLine string = "----"

Functions

This section is empty.

Types

type ILocatable

type ILocatable interface {
	GetLocation() *Location
}

ILocatable describes something that can be located in a source

type ITypable

type ITypable interface {
	GetType() NodeType
}

type Location

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

Location is used to point to a specific location in the source code (before parse). It can point to a single point or a range.

var UnknownLocation *Location = &Location{knownLocation: false}

func MakeLocation

func MakeLocation(input *Source, start, end int) *Location

MakeLocation return a pointer to a `Location` in the given source `input` specified by the `start` and `end` boundaries

func MakeUnknownLocation

func MakeUnknownLocation() *Location

func (*Location) DecEnd

func (l *Location) DecEnd(x int)

DecEnd decreases the end pointer of the location by `x` with respect to the boundaries of the source

func (*Location) DecStart

func (l *Location) DecStart(x int)

DecStart decreases the start pointer of the location by `x` with respect to the boundaries of the source

func (*Location) GetEnd

func (l *Location) GetEnd() int

func (*Location) GetSource

func (l *Location) GetSource() *Source

GetSource returns the source of the current location or the "builtin" source to indicate that the source of this location is not known in the context of source code

func (*Location) GetStart

func (l *Location) GetStart() int

func (*Location) IncEnd

func (l *Location) IncEnd(x int)

IncEnd increases the end pointer of the location by `x` with respect to the boundaries of the source

func (*Location) IncStart

func (l *Location) IncStart(x int)

IncStart increases the start pointer of the location by `x` with respect to the boundaries of the source

func (*Location) IsKnownLocaiton

func (l *Location) IsKnownLocaiton() bool

type NodeType

type NodeType int
const (
	Nil NodeType = iota
	Nothing
	Bool
	Instruction
	Symbol
	Keyword
	Number
	List
	Fn
	NativeFn
	Namespace
	String
	Block // Dont' mistake it with block from other programming languages

)

type Source

type Source struct {
	// A Pointer to the buffer where the parser used for parsing the source
	Buffer *[]string

	// The namespace name which this source is describing
	NS string

	// This array contains the boundaries of each line in the buffer. For example
	// [24 50 106] means that the buffer contains 3 lines and the first line can
	// be found from the index 0 to index 24 of the buffer and the second line is
	// from index 25 till 50 and so on
	LineIndex *[]int
}

func GetBuiltinSource

func GetBuiltinSource() *Source

GetBuiltinSource returns a pointer to a source that represents builtin expressions

func (*Source) GetLine

func (s *Source) GetLine(linenum int) string

GetLine returns the line specified by the `linenum` from the buffer. It will return "----" if the given line number exceeds the boundaries of the buffer

func (*Source) GetSubstr

func (s *Source) GetSubstr(start, end int) *string

GetSubstr returns the a pointer to the string from the buffer specified by the `start` and `end`

func (*Source) LineNumberFor

func (s *Source) LineNumberFor(pos int) int

LineNumberFor returns the line number associated with the given position `pos` in the buffer

Jump to

Keyboard shortcuts

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