parser

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCOPE_PROGRAM  scope = "program"
	SCOPE_FUNCTION scope = "function"
	SCOPE_IF       scope = "if"
	SCOPE_FOR      scope = "for"
	SCOPE_SWITCH   scope = "switch"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppCall

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

func (AppCall) Args

func (a AppCall) Args() []Expression

func (AppCall) Name

func (a AppCall) Name() string

func (AppCall) Next

func (a AppCall) Next() *AppCall

func (AppCall) ReturnTypes

func (a AppCall) ReturnTypes() []ValueType

func (AppCall) StatementType

func (a AppCall) StatementType() StatementType

func (AppCall) ValueType

func (a AppCall) ValueType() ValueType

type BinaryOperation

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

func (BinaryOperation) Left

func (b BinaryOperation) Left() Expression

func (BinaryOperation) Operator

func (b BinaryOperation) Operator() BinaryOperator

func (BinaryOperation) Right

func (b BinaryOperation) Right() Expression

func (BinaryOperation) StatementType

func (b BinaryOperation) StatementType() StatementType

func (BinaryOperation) ValueType

func (b BinaryOperation) ValueType() ValueType

type BinaryOperator

type BinaryOperator = string
const (
	BINARY_OPERATOR_MULTIPLICATION BinaryOperator = "*"
	BINARY_OPERATOR_DIVISION       BinaryOperator = "/"
	BINARY_OPERATOR_MODULO         BinaryOperator = "%"
	BINARY_OPERATOR_ADDITION       BinaryOperator = "+"
	BINARY_OPERATOR_SUBTRACTION    BinaryOperator = "-"
)

type Block

type Block interface {
	Body() []Statement
}

type BooleanLiteral

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

func (BooleanLiteral) StatementType

func (l BooleanLiteral) StatementType() StatementType

func (BooleanLiteral) Value

func (l BooleanLiteral) Value() bool

func (BooleanLiteral) ValueType

func (l BooleanLiteral) ValueType() ValueType

type Break

type Break struct {
}

func (Break) StatementType

func (b Break) StatementType() StatementType

type Call

type Call interface {
	Expression
	Name() string
	Args() []Expression
	ReturnTypes() []ValueType
}

type CompareOperator

type CompareOperator = string
const (
	COMPARE_OPERATOR_EQUAL            CompareOperator = "=="
	COMPARE_OPERATOR_NOT_EQUAL        CompareOperator = "!="
	COMPARE_OPERATOR_LESS             CompareOperator = "<"
	COMPARE_OPERATOR_LESS_OR_EQUAL    CompareOperator = "<="
	COMPARE_OPERATOR_GREATER          CompareOperator = ">"
	COMPARE_OPERATOR_GREATER_OR_EQUAL CompareOperator = ">="
)

type Comparison

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

func NewComparison

func NewComparison(left Expression, operator CompareOperator, right Expression) Comparison

func (Comparison) Left

func (c Comparison) Left() Expression

func (Comparison) Operator

func (c Comparison) Operator() CompareOperator

func (Comparison) Right

func (c Comparison) Right() Expression

func (Comparison) StatementType

func (c Comparison) StatementType() StatementType

func (Comparison) ValueType

func (c Comparison) ValueType() ValueType

type Continue

type Continue struct {
}

func (Continue) StatementType

func (c Continue) StatementType() StatementType

type Copy

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

func (Copy) Destination

func (c Copy) Destination() Variable

func (Copy) Source

func (c Copy) Source() Expression

func (Copy) StatementType

func (c Copy) StatementType() StatementType

func (Copy) ValueType

func (c Copy) ValueType() ValueType

type DataType

type DataType string
const (
	DATA_TYPE_UNKNOWN  DataType = "unknown"
	DATA_TYPE_MULTIPLE DataType = "multiple"
	DATA_TYPE_BOOLEAN  DataType = "bool"
	DATA_TYPE_INTEGER  DataType = "int"
	DATA_TYPE_STRING   DataType = "string"
	DATA_TYPE_ERROR    DataType = DATA_TYPE_STRING
)

type Else

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

func (Else) Body

func (e Else) Body() []Statement

type Exists

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

func (Exists) Path

func (e Exists) Path() Expression

func (Exists) StatementType

func (e Exists) StatementType() StatementType

func (Exists) ValueType

func (e Exists) ValueType() ValueType

type Expression

type Expression interface {
	// An expression is a super-type of statement which results in a value.
	Statement
	ValueType() ValueType
}

type For

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

func (For) Body

func (f For) Body() []Statement

func (For) Condition

func (f For) Condition() Expression

func (For) Increment

func (f For) Increment() Statement

func (For) Init

func (f For) Init() Statement

func (For) StatementType

func (f For) StatementType() StatementType

type FunctionCall

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

func (FunctionCall) Args

func (e FunctionCall) Args() []Expression

func (FunctionCall) Name

func (e FunctionCall) Name() string

func (FunctionCall) ReturnTypes

func (e FunctionCall) ReturnTypes() []ValueType

func (FunctionCall) StatementType

func (e FunctionCall) StatementType() StatementType

func (FunctionCall) ValueType

func (e FunctionCall) ValueType() ValueType

type FunctionDefinition

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

func (FunctionDefinition) Body

func (e FunctionDefinition) Body() []Statement

func (FunctionDefinition) Name

func (e FunctionDefinition) Name() string

func (FunctionDefinition) Params

func (e FunctionDefinition) Params() []Variable

func (FunctionDefinition) Public

func (e FunctionDefinition) Public() bool

func (FunctionDefinition) ReturnTypes

func (e FunctionDefinition) ReturnTypes() []ValueType

func (FunctionDefinition) StatementType

func (e FunctionDefinition) StatementType() StatementType

func (FunctionDefinition) ValueType

func (e FunctionDefinition) ValueType() ValueType

type Global

type Global interface {
	Global() bool
}

type Group

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

func (Group) Child

func (e Group) Child() Expression

func (Group) StatementType

func (e Group) StatementType() StatementType

func (Group) ValueType

func (e Group) ValueType() ValueType

type If

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

func (If) Else

func (i If) Else() Else

func (If) ElseIfBranches

func (i If) ElseIfBranches() []IfBranch

func (If) HasElse

func (i If) HasElse() bool

func (If) IfBranch

func (i If) IfBranch() IfBranch

func (If) StatementType

func (i If) StatementType() StatementType

type IfBranch

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

func (IfBranch) Body

func (b IfBranch) Body() []Statement

func (IfBranch) Condition

func (b IfBranch) Condition() Expression

type Input

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

func (Input) Prompt

func (i Input) Prompt() Expression

func (Input) StatementType

func (i Input) StatementType() StatementType

func (Input) ValueType

func (i Input) ValueType() ValueType

type IntegerLiteral

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

func (IntegerLiteral) StatementType

func (l IntegerLiteral) StatementType() StatementType

func (IntegerLiteral) Value

func (l IntegerLiteral) Value() int

func (IntegerLiteral) ValueType

func (l IntegerLiteral) ValueType() ValueType

type Itoa

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

func (Itoa) StatementType

func (e Itoa) StatementType() StatementType

func (Itoa) Value

func (e Itoa) Value() Expression

func (Itoa) ValueType

func (e Itoa) ValueType() ValueType

type Len

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

func (Len) Expression

func (l Len) Expression() Expression

func (Len) StatementType

func (l Len) StatementType() StatementType

func (Len) ValueType

func (l Len) ValueType() ValueType

type LogicalOperation

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

func (LogicalOperation) Left

func (l LogicalOperation) Left() Expression

func (LogicalOperation) Operator

func (l LogicalOperation) Operator() LogicalOperator

func (LogicalOperation) Right

func (l LogicalOperation) Right() Expression

func (LogicalOperation) StatementType

func (l LogicalOperation) StatementType() StatementType

func (LogicalOperation) ValueType

func (l LogicalOperation) ValueType() ValueType

type LogicalOperator

type LogicalOperator = string
const (
	LOGICAL_OPERATOR_AND LogicalOperator = "&&"
	LOGICAL_OPERATOR_OR  LogicalOperator = "||"
)

type Operation

type Operation interface {
	Left() Expression
	Operator() string
	Right() Expression
}

type Panic

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

func (Panic) Expression

func (p Panic) Expression() Expression

func (Panic) StatementType

func (p Panic) StatementType() StatementType

type Parser

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

func New

func New() Parser

func (*Parser) Parse

func (p *Parser) Parse(path string) (Program, error)

type Print

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

func (Print) Expressions

func (p Print) Expressions() []Expression

func (Print) StatementType

func (p Print) StatementType() StatementType

type Program

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

func (Program) Body

func (p Program) Body() []Statement

func (Program) StatementType

func (p Program) StatementType() StatementType

type Read

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

func (Read) Path

func (r Read) Path() Expression

func (Read) StatementType

func (r Read) StatementType() StatementType

func (Read) ValueType

func (r Read) ValueType() ValueType

type Return

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

func (Return) StatementType

func (r Return) StatementType() StatementType

func (Return) Values

func (r Return) Values() []Expression

type SliceAssignment

type SliceAssignment struct {
	Variable
	// contains filtered or unexported fields
}

func (SliceAssignment) Index

func (s SliceAssignment) Index() Expression

func (SliceAssignment) Name

func (s SliceAssignment) Name() string

func (SliceAssignment) StatementType

func (s SliceAssignment) StatementType() StatementType

func (SliceAssignment) Value

func (s SliceAssignment) Value() Expression

type SliceEvaluation

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

func (SliceEvaluation) Index

func (s SliceEvaluation) Index() Expression

func (SliceEvaluation) StatementType

func (s SliceEvaluation) StatementType() StatementType

func (SliceEvaluation) Value

func (s SliceEvaluation) Value() Expression

func (SliceEvaluation) ValueType

func (s SliceEvaluation) ValueType() ValueType

type SliceInstantiation

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

func (SliceInstantiation) StatementType

func (s SliceInstantiation) StatementType() StatementType

func (SliceInstantiation) ValueType

func (s SliceInstantiation) ValueType() ValueType

func (SliceInstantiation) Values

func (s SliceInstantiation) Values() []Expression

type Statement

type Statement interface {
	StatementType() StatementType
}

type StatementType

type StatementType string
const (
	STATEMENT_TYPE_PROGRAM                        StatementType = "program"
	STATEMENT_TYPE_BOOL_LITERAL                   StatementType = "boolean"
	STATEMENT_TYPE_INT_LITERAL                    StatementType = "integer"
	STATEMENT_TYPE_STRING_LITERAL                 StatementType = "string"
	STATEMENT_TYPE_STRING_SUBSCRIPT               StatementType = "string subscript"
	STATEMENT_TYPE_NIL_LITERAL                    StatementType = "nil"
	STATEMENT_TYPE_UNARY_OPERATION                StatementType = "unary operation"
	STATEMENT_TYPE_BINARY_OPERATION               StatementType = "binary operation"
	STATEMENT_TYPE_LOGICAL_OPERATION              StatementType = "logical operation"
	STATEMENT_TYPE_COMPARISON                     StatementType = "comparison"
	STATEMENT_TYPE_VAR_DEFINITION                 StatementType = "variable definition"
	STATEMENT_TYPE_VAR_DEFINITION_CALL_ASSIGNMENT StatementType = "variable definition func assignment"
	STATEMENT_TYPE_VAR_ASSIGNMENT                 StatementType = "variable assignment"
	STATEMENT_TYPE_VAR_ASSIGNMENT_CALL_ASSIGNMENT StatementType = "variable assignment func assignment"
	STATEMENT_TYPE_VAR_EVALUATION                 StatementType = "variable evaluation"
	STATEMENT_TYPE_GROUP                          StatementType = "group"
	STATEMENT_TYPE_FUNCTION_DEFINITION            StatementType = "function definition"
	STATEMENT_TYPE_FUNCTION_CALL                  StatementType = "function call"
	STATEMENT_TYPE_APP_CALL                       StatementType = "app call"
	STATEMENT_TYPE_RETURN                         StatementType = "return"
	STATEMENT_TYPE_IF                             StatementType = "if"
	STATEMENT_TYPE_FOR                            StatementType = "for"
	STATEMENT_TYPE_FOR_RANGE                      StatementType = "for range"
	STATEMENT_TYPE_BREAK                          StatementType = "break"
	STATEMENT_TYPE_CONTINUE                       StatementType = "continue"
	STATEMENT_TYPE_INSTANTIATION                  StatementType = "instantiation"
	STATEMENT_TYPE_PRINT                          StatementType = "print"
	STATEMENT_TYPE_ITOA                           StatementType = "itoa"
	STATEMENT_TYPE_EXISTS                         StatementType = "exists"
	STATEMENT_TYPE_PANIC                          StatementType = "panic"
	STATEMENT_TYPE_LEN                            StatementType = "len"
	STATEMENT_TYPE_INPUT                          StatementType = "input"
	STATEMENT_TYPE_COPY                           StatementType = "copy"
	STATEMENT_TYPE_READ                           StatementType = "read"
	STATEMENT_TYPE_WRITE                          StatementType = "write"
	STATEMENT_TYPE_SLICE_INSTANTIATION            StatementType = "slice instantiation"
	STATEMENT_TYPE_SLICE_ASSIGNMENT               StatementType = "slice assignment"
	STATEMENT_TYPE_SLICE_EVALUATION               StatementType = "slice evaluation"
)

type StringLiteral

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

func (StringLiteral) StatementType

func (l StringLiteral) StatementType() StatementType

func (StringLiteral) Value

func (l StringLiteral) Value() string

func (StringLiteral) ValueType

func (l StringLiteral) ValueType() ValueType

type StringSubscript

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

func (StringSubscript) EndIndex

func (s StringSubscript) EndIndex() Expression

func (StringSubscript) StartIndex

func (s StringSubscript) StartIndex() Expression

func (StringSubscript) StatementType

func (s StringSubscript) StatementType() StatementType

func (StringSubscript) Value

func (s StringSubscript) Value() Expression

func (StringSubscript) ValueType

func (s StringSubscript) ValueType() ValueType

type UnaryOperation

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

func (UnaryOperation) Expression

func (b UnaryOperation) Expression() Expression

func (UnaryOperation) Operator

func (b UnaryOperation) Operator() UnaryOperator

func (UnaryOperation) StatementType

func (b UnaryOperation) StatementType() StatementType

func (UnaryOperation) ValueType

func (b UnaryOperation) ValueType() ValueType

type UnaryOperator

type UnaryOperator = string
const (
	UNARY_OPERATOR_NEGATE UnaryOperator = "!"
)

type ValueType

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

func NewValueType

func NewValueType(dataType DataType, isSlice bool) ValueType

func (ValueType) DataType

func (vt ValueType) DataType() DataType

func (ValueType) Equals

func (vt ValueType) Equals(valueType ValueType) bool

func (ValueType) IsBool

func (vt ValueType) IsBool() bool

func (ValueType) IsInt

func (vt ValueType) IsInt() bool

func (ValueType) IsSlice

func (vt ValueType) IsSlice() bool

func (ValueType) IsString

func (vt ValueType) IsString() bool

func (ValueType) String

func (vt ValueType) String() string

type Variable

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

func NewVariable

func NewVariable(name string, valueType ValueType, global bool, public bool) Variable

func (Variable) Global

func (v Variable) Global() bool

func (Variable) Name

func (v Variable) Name() string

func (Variable) Public

func (v Variable) Public() bool

func (Variable) ValueType

func (v Variable) ValueType() ValueType

type VariableAssignment

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

func (VariableAssignment) StatementType

func (v VariableAssignment) StatementType() StatementType

func (VariableAssignment) Values

func (v VariableAssignment) Values() []Expression

func (VariableAssignment) Variables

func (v VariableAssignment) Variables() []Variable

type VariableAssignmentCallAssignment

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

func (VariableAssignmentCallAssignment) Call

func (VariableAssignmentCallAssignment) StatementType

func (VariableAssignmentCallAssignment) Variables

type VariableDefinition

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

func (VariableDefinition) StatementType

func (v VariableDefinition) StatementType() StatementType

func (VariableDefinition) Values

func (v VariableDefinition) Values() []Expression

func (VariableDefinition) Variables

func (v VariableDefinition) Variables() []Variable

type VariableDefinitionCallAssignment

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

func (VariableDefinitionCallAssignment) Call

func (VariableDefinitionCallAssignment) StatementType

func (VariableDefinitionCallAssignment) Variables

type VariableEvaluation

type VariableEvaluation struct {
	Variable
}

func (VariableEvaluation) StatementType

func (e VariableEvaluation) StatementType() StatementType

type Write

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

func (Write) Append

func (w Write) Append() Expression

func (Write) Data

func (w Write) Data() Expression

func (Write) Path

func (w Write) Path() Expression

func (Write) StatementType

func (w Write) StatementType() StatementType

func (Write) ValueType

func (w Write) ValueType() ValueType

Jump to

Keyboard shortcuts

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