polylang

package module
v0.0.0-...-ddda045 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PolylangLexer = lexer.MustSimple([]lexer.SimpleRule{
	{Name: "Ident", Pattern: `[a-zA-Z_.][a-zA-Z0-9_.]*`},
	{Name: "String", Pattern: `'[^']*'`},
	{Name: "Punct", Pattern: `\[|]|[,:;={}()?!@]`},
	{Name: "whitespace", Pattern: `\s+`},
})

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Pos lexer.Position

	Name  string  `parser:"'collection' @Ident"`
	Items []*Item `parser:"'{' @@* '}'"`
}

type CompoundStatement

type CompoundStatement struct {
	If *If `parser:"@@"`
}

type Expression

type Expression struct {
	Pos lexer.Position

	Left       string      `parser:"@( Ident | String )"`
	Operator   Operator    `parser:"( @@ )?"`
	Expression *Expression `parser:"( '(' @@ ')' )?"`
	Right      string      `parser:"( @( Ident | String ) )?"`
}

type Field

type Field struct {
	Pos lexer.Position

	Name     string `parser:"@Ident"`
	Optional bool   `parser:"@'?'?"`
	Type     string `parser:"':' @Ident ';'"`
}

type Function

type Function struct {
	Pos lexer.Position

	Name       string       `parser:"@Ident '('"`
	Parameters []*Parameter `parser:"( @@ ( ',' @@ )* )? ')'"`
	ReturnType string       `parser:"( ':' @Ident )?"`
	Statements []*Statement `parser:"'{' ( @@* )? '}'"`
}

type If

type If struct {
	Pos lexer.Position

	Condition  *Expression  `parser:"'if' '(' @@ ')'"`
	Statements []*Statement `parser:"'{' @@* '}'"`
	Else       []*Statement `parser:"( 'else' '{' @@* '}' )?"`
}

type Index

type Index struct {
	Pos lexer.Position

	Unique bool          `parser:"'@' ( @'unique' | 'index' )"`
	Fields []*IndexField `parser:"'(' @@ ( ',' @@ )* ')' ';'"`
}

type IndexField

type IndexField struct {
	Pos lexer.Position

	Name  string `parser:"( '[' )? ( @Ident )"`
	Order Order  `parser:"( ',' @@ ']' )?"`
}

type Item

type Item struct {
	Pos lexer.Position

	Field    *Field    `parser:"@@"`
	Function *Function `parser:"| @@"`
	Index    *Index    `parser:"| @@"`
}

type Operator

type Operator int
const (
	Not Operator = iota
	BitNot
	Exponent
	Multiply
	Divide
	Modulo
	Add
	Subtract
	ShiftLeft
	ShiftRight
	BitAnd
	BitXor
	BitOr
	LessThan
	GreaterThan
	LessThanOrEqual
	GreaterThanOrEqual
	Equal
	NotEqual
	And
	Or
	AssignSub
	AssignAdd
	Assign
)

func (Operator) GoString

func (o Operator) GoString() string

func (*Operator) Parse

func (o *Operator) Parse(lex *lexer.PeekingLexer) error

type Order

type Order int
const (
	Asc Order = iota
	Desc
)

func (Order) GoString

func (o Order) GoString() string

func (*Order) Parse

func (o *Order) Parse(lex *lexer.PeekingLexer) error

type Parameter

type Parameter struct {
	Pos lexer.Position

	Name     string `parser:"@Ident"`
	Optional bool   `parser:"@'?'?"`
	Type     string `parser:"':' @Ident"`
}

type Polylang

type Polylang struct {
	Pos lexer.Position

	Collection *Collection
}

type SimpleStatement

type SimpleStatement struct {
	Small *SmallStatement `parser:"| @@ ';'"`
}

type SmallStatement

type SmallStatement struct {
	Throw      *Expression `parser:"'throw' @@"`
	Expression *Expression `parser:"| @@"`
}

type Statement

type Statement struct {
	CompoundStatement
	SimpleStatement
}

Jump to

Keyboard shortcuts

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