parser

package
v2.2.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseToAST

func ParseToAST(code string, ast interface{}) error

ParseToAST ...

func SetInnerField

func SetInnerField(rootValue interface{}, fieldName string, fieldValue interface{}) interface{}

SetInnerField ...

It creates a hierarchy of structures and sets the specified field.

First, it searches the specified field in the passed root value. If the field was found, then the specified value is set to it.

Otherwise, the first field is selected and filled with a zero value of the corresponding type. After that, the search recursively continues in it with the same logic.

The passed root value and the first field on each step of the search should be a pointer to a structure.

Types

type Accessor

type Accessor struct {
	Atom *Atom          `parser:"@@"`
	Keys []*AccessorKey `parser:"{ @@ }"`
}

Accessor ...

type AccessorKey

type AccessorKey struct {
	Name       *string     `parser:"\".\" @Ident"`
	Expression *Expression `parser:"| \"[\" @@ \"]\""`
}

AccessorKey ...

type Actor

type Actor struct {
	Name       string           `parser:"\"actor\" @Ident"`
	Parameters *IdentifierGroup `parser:"\"(\" @@ \")\""`
	States     []*State         `parser:"{ @@ } \";\""`
}

Actor ...

type ActorClass

type ActorClass struct {
	Name       string           `parser:"\"class\" @Ident"`
	Parameters *IdentifierGroup `parser:"\"(\" @@ \")\""`
	States     []*State         `parser:"{ @@ } \";\""`
}

ActorClass ...

type Addition

type Addition struct {
	Multiplication *Multiplication `parser:"@@"`
	Operation      string          `parser:"[ @( \"+\" | \"-\" )"`
	Addition       *Addition       `parser:"@@ ]"`
}

Addition ...

type Atom

type Atom struct {
	IntegerNumber         *int64                 `parser:"@Int"`
	FloatingPointNumber   *float64               `parser:"| @Float"`
	Symbol                *string                `parser:"| @Char"`
	String                *string                `parser:"| @String | @RawString"`
	ListDefinition        *ListDefinition        `parser:"| @@"`
	HashTableDefinition   *HashTableDefinition   `parser:"| @@"`
	FunctionCall          *FunctionCall          `parser:"| @@"`
	ConditionalExpression *ConditionalExpression `parser:"| @@"`
	Identifier            *string                `parser:"| @Ident"`
	Expression            *Expression            `parser:"| \"(\" @@ \")\""`
}

Atom ...

type BitwiseConjunction

type BitwiseConjunction struct {
	Shift              *Shift              `parser:"@@"`
	Operation          string              `parser:"[ @\"&\""`
	BitwiseConjunction *BitwiseConjunction `parser:"@@ ]"`
}

BitwiseConjunction ...

type BitwiseDisjunction

type BitwiseDisjunction struct {
	BitwiseExclusiveDisjunction *BitwiseExclusiveDisjunction `parser:"@@"`
	Operation                   string                       `parser:"[ @\"|\""`
	BitwiseDisjunction          *BitwiseDisjunction          `parser:"@@ ]"`
}

BitwiseDisjunction ...

type BitwiseExclusiveDisjunction

type BitwiseExclusiveDisjunction struct {
	BitwiseConjunction          *BitwiseConjunction          `parser:"@@"`
	Operation                   string                       `parser:"[ @\"^\""`
	BitwiseExclusiveDisjunction *BitwiseExclusiveDisjunction `parser:"@@ ]"`
}

BitwiseExclusiveDisjunction ...

type Command

type Command struct {
	Let        *LetCommand   `parser:"@@"`
	Start      *StartCommand `parser:"| @@"`
	Send       *SendCommand  `parser:"| @@"`
	Set        *SetCommand   `parser:"| @@"`
	Return     bool          `parser:"| @\"return\""`
	Expression *Expression   `parser:"| @@"`
}

Command ...

type Comparison

type Comparison struct {
	BitwiseDisjunction *BitwiseDisjunction `parser:"@@"`
	Operation          string              `parser:"[ @( \"<\" \"=\" | \"<\" | \">\" \"=\" | \">\" )"`
	Comparison         *Comparison         `parser:"@@ ]"`
}

Comparison ...

type ConditionalCase

type ConditionalCase struct {
	Condition *Expression `parser:"\"=\" \">\" @@"`
	Commands  []*Command  `parser:"{ @@ }"`
}

ConditionalCase ...

type ConditionalExpression

type ConditionalExpression struct {
	ConditionalCases []*ConditionalCase `parser:"\"when\" { @@ } \";\""`
}

ConditionalExpression ...

type Conjunction

type Conjunction struct {
	Equality    *Equality    `parser:"@@"`
	Operation   string       `parser:"[ @( \"&\" \"&\" )"`
	Conjunction *Conjunction `parser:"@@ ]"`
}

Conjunction ...

type Definition

type Definition struct {
	Actor      *Actor      `parser:"@@"`
	ActorClass *ActorClass `parser:"| @@"`
}

Definition ...

type Disjunction

type Disjunction struct {
	Conjunction *Conjunction `parser:"@@"`
	Operation   string       `parser:"[ @( \"|\" \"|\" )"`
	Disjunction *Disjunction `parser:"@@ ]"`
}

Disjunction ...

type Equality

type Equality struct {
	Comparison *Comparison `parser:"@@"`
	Operation  string      `parser:"[ @( \"=\" \"=\" | \"!\" \"=\" )"`
	Equality   *Equality   `parser:"@@ ]"`
}

Equality ...

type Expression

type Expression struct {
	ListConstruction *ListConstruction `parser:"@@"`
}

Expression ...

type ExpressionGroup

type ExpressionGroup struct {
	Expressions []*Expression `parser:"[ @@ { \",\" @@ } [ \",\" ] ]"`
}

ExpressionGroup ...

type FunctionCall

type FunctionCall struct {
	Name      string           `parser:"@Ident"`
	Arguments *ExpressionGroup `parser:"\"(\" @@ \")\""`
}

FunctionCall ...

type HashTableDefinition

type HashTableDefinition struct {
	Entries []*HashTableEntry `parser:"\"{\" [ @@ { \",\" @@ } [ \",\" ] ] \"}\""`
}

HashTableDefinition ...

type HashTableEntry

type HashTableEntry struct {
	Name       *string     `parser:"( @Ident"`
	Expression *Expression `parser:"| \"[\" @@ \"]\" )"`
	Value      *Expression `parser:"\":\" @@"`
}

HashTableEntry ...

type IdentifierGroup

type IdentifierGroup struct {
	Identifiers []string `parser:"[ @Ident { \",\" @Ident } [ \",\" ] ]"`
}

IdentifierGroup ...

type LetCommand

type LetCommand struct {
	Identifier string      `parser:"\"let\" @Ident \"=\""`
	Expression *Expression `parser:"@@"`
}

LetCommand ...

type ListConstruction

type ListConstruction struct {
	NilCoalescing    *NilCoalescing    `parser:"@@"`
	Operation        string            `parser:"[ @\":\""`
	ListConstruction *ListConstruction `parser:"@@ ]"`
}

ListConstruction ...

type ListDefinition

type ListDefinition struct {
	Items *ExpressionGroup `parser:"\"[\" @@ \"]\""`
}

ListDefinition ...

type Message

type Message struct {
	Name       string           `parser:"\"message\" @Ident"`
	Parameters *IdentifierGroup `parser:"\"(\" @@ \")\""`
	Commands   []*Command       `parser:"{ @@ } \";\""`
}

Message ...

type Multiplication

type Multiplication struct {
	Unary          *Unary          `parser:"@@"`
	Operation      string          `parser:"[ @( \"*\" | \"/\" | \"%\" )"`
	Multiplication *Multiplication `parser:"@@ ]"`
}

Multiplication ...

type NilCoalescing

type NilCoalescing struct {
	Disjunction   *Disjunction   `parser:"@@"`
	Operation     string         `parser:"[ @( \"?\" \"?\" )"`
	NilCoalescing *NilCoalescing `parser:"@@ ]"`
}

NilCoalescing ...

type Program

type Program struct {
	Definitions []*Definition `parser:"{ @@ }"`
}

Program ...

type SendCommand

type SendCommand struct {
	Name      string           `parser:"\"send\" @Ident"`
	Arguments *ExpressionGroup `parser:"\"(\" @@ \")\""`
}

SendCommand ...

type SetCommand

type SetCommand struct {
	Name      string           `parser:"\"set\" @Ident"`
	Arguments *ExpressionGroup `parser:"\"(\" @@ \")\""`
}

SetCommand ...

type Shift

type Shift struct {
	Addition  *Addition `parser:"@@"`
	Operation string    `parser:"[ @( \"<\" \"<\" | \">\" \">\" [ \">\" ] )"`
	Shift     *Shift    `parser:"@@ ]"`
}

Shift ...

type StartCommand

type StartCommand struct {
	Name       *string          `parser:"\"start\" ( @Ident"`
	Expression *Expression      `parser:"| \"[\" @@ \"]\" )"`
	Arguments  *ExpressionGroup `parser:"\"(\" @@ \")\""`
}

StartCommand ...

type State

type State struct {
	Name       string           `parser:"\"state\" @Ident"`
	Parameters *IdentifierGroup `parser:"\"(\" @@ \")\""`
	Messages   []*Message       `parser:"{ @@ } \";\""`
}

State ...

type Unary

type Unary struct {
	Operation string    `parser:"( @( \"-\" | \"~\" | \"!\" )"`
	Unary     *Unary    `parser:"@@ )"`
	Accessor  *Accessor `parser:"| @@"`
}

Unary ...

Jump to

Keyboard shortcuts

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