ast

package
v0.0.0-...-1f1b166 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atom

type Atom struct {
	Pos lexer.Position

	Negated bool       `parser:"@'not'?"`
	Name    string     `parser:"@Ident"`
	Terms   []AtomTerm `parser:"'(' @@ (',' @@)* ')'"`
}

type AtomTerm

type AtomTerm struct {
	Pos lexer.Position

	Var *Variable `parser:"@@ |"`
	Num *int      `parser:"@Int"`
}

type BodyTerm

type BodyTerm struct {
	Pos lexer.Position

	Atom      *Atom      `parser:"@@ |"`
	Condition *Condition `parser:"@@"`
}

type Condition

type Condition struct {
	Pos lexer.Position

	Expr1   Expression `parser:"@@"`
	Operand string     `parser:"@('<='|'>='|'='|'!='|'<'|'>')"`
	Expr2   Expression `parser:"@@"`
}

type Expression

type Expression struct {
	Pos lexer.Position

	Var *Variable `parser:"(@@|"`
	Num *int      `parser:"@Int)"`

	Op   *string     `parser:"(@('+'|'-'|'*'|'/')"`
	Expr *Expression `parser:"@@)?"`
}

type HeadAtom

type HeadAtom struct {
	Pos lexer.Position

	Name  string     `parser:"@Ident"`
	Terms []HeadTerm `parser:"'(' @@ (',' @@)* ')'"`
}

type HeadTerm

type HeadTerm struct {
	Pos lexer.Position

	Aggregator *string  `parser:"@Ident?"`
	Variable   Variable `parser:"('<' @@ '>')|@@"` // This is a temporary workaround
}

type Preload

type Preload struct {
	Pos lexer.Position

	Name   string         `parser:"@Ident '('"`
	Fields []PreloadField `parser:"(@@ ',')* ((@@ ')') |"`
	Loc    *string        `parser:"(@Ident ','"`
	Time   *int           `parser:"@Int ')'))"`
}

type PreloadField

type PreloadField struct {
	Pos lexer.Position

	Data string `parser:"@String"`
}

type Program

type Program struct {
	Pos lexer.Position

	Statements []Statement `parser:"@@*"`
}

func Parse

func Parse(r io.Reader) (*Program, error)

type Rule

type Rule struct {
	Pos lexer.Position

	Head HeadAtom   `parser:"@@ ':-'"`
	Body []BodyTerm `parser:"@@ (',' @@)*"`
}

type Statement

type Statement struct {
	Pos lexer.Position

	Rule    *Rule    `parser:"@@ |"`
	Preload *Preload `parser:"(@@ '.') |"`
	Comment *string  `parser:"@Comment"`
}

type Variable

type Variable struct {
	Pos lexer.Position

	NameTuple []*Variable `parser:"('(' @@ (',' @@)* ')') |"`
	Name      string      `parser:"@Ident"`
}

Jump to

Keyboard shortcuts

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