preprocessor

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package preprocessor provides means for preprocessing abudsl programs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbuType

type AbuType struct {
	// TypeName contains the type of the expression.
	TypeName string
	// Readable specifies if all the expression's terms are accessible.
	Readable bool
	// Writable specifies whether the expression is an l-value of a modifiable resource.
	Writable bool
}

AbuType represents the type of an abudsl expression.

type DeviceSymbolTable

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

DeviceSymbolTable is a SymbolTable that can be used to obtain information on the local and remote resources of a selected device.

func (DeviceSymbolTable) ExtSymbols

func (d DeviceSymbolTable) ExtSymbols(args ...string) []Symbol

ExtSymbols takes as arguments the IDs of a remote resource and returns a []Symbol containing all the entries apart from the one related to the selected device.

func (DeviceSymbolTable) Symbol

func (d DeviceSymbolTable) Symbol(args ...string) Symbol

Symbol takes as arguments the IDs of a local resource of the selected device and returns an entry that implements the Symbol interface. It returns nil if no entry is found.

func (DeviceSymbolTable) TypeInfo

func (d DeviceSymbolTable) TypeInfo(customType string) map[string]Symbol

TypeInfo takes the name of a defined custom type and returns a map where the keys are the names of its fields and the values are the related symbol table entries. It returns nil if no entry is found.

type Symbol

type Symbol interface {
	// Type returns the AbuType of the resource.
	Type() AbuType
	// contains filtered or unexported methods
}

Symbol is the inferface implemented by the entries of a SymbolTable.

type SymbolTable

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

SymbolTable contains the information, usable by the compiler, regarding the resources of all the devices of an abudsl program.

func DecodeSymbolTable

func DecodeSymbolTable(r io.Reader) (SymbolTable, error)

DecodeSymbolTable deserializes a SymbolTable from an io.Reader.

func PreprocessedStreams

func PreprocessedStreams(input string) (map[string]TrivialStream, SymbolTable, []error)

PreprocessedStreams takes a string containing an abudsl program and performs desugaring and splitting. It returns a map where the the keys are the device ids while the values are the corresponding desugared text streams and the program's symbol table. If an error is encountered during the preprocessing, a not empty []error is returned.

NOTE: In the future it may return a map[string]antlr.CharStream

func PreprocessedStreamsFromFile

func PreprocessedStreamsFromFile(fileName string) (map[string]TrivialStream, SymbolTable, []error)

PreprocessedStreamsFromFile takes a file name of an abudsl program and performs desugaring and splitting. It returns a map where the the keys are the device ids while the values are the corresponding desugared text streams and the program's symbol table. If an error is encountered during the preprocessing, a not empty []error is returned.

NOTE: In the future it may return a map[string]antlr.CharStream

func (SymbolTable) DeviceSymbolTable

func (t SymbolTable) DeviceSymbolTable(device string) (DeviceSymbolTable, error)

DeviceSymbolTable returns the DeviceSymbolTable corresponding to the device ID argument.

func (SymbolTable) Encode

func (t SymbolTable) Encode(w io.Writer) error

Encode serializes the SymbolTable to an io.Writer.

func (SymbolTable) TypeInfo

func (t SymbolTable) TypeInfo(customType string) map[string]Symbol

TypeInfo takes the name of a defined custom type and returns a map where the keys are the names of its fields and the values are the related symbol table entries. It returns nil if no entry is found.

type TrivialStream

type TrivialStream interface {
	// Size returns the number of the chunks that compose the stream.
	Size() int
	// GetText returns the section of the content delimited by the
	// specified chunk indexes (e.g. 0,Size()-1).
	GetText(int, int) string
}

TrivialStream is a minimal interface for chunk-based text streams.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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