ast

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AST

type AST struct {
	Types []*ASTElement `parser:"{ @@ }"`
}

AST represents the structure of a parsed firemodel schema file.

Read about the magical annotations here: https://github.com/alecthomas/participle/.

func ParseSchema

func ParseSchema(r io.Reader) (*AST, error)

type ASTElement

type ASTElement struct {
	Comment string     `parser:"{ @Comment }"`
	Model   *ASTModel  `parser:"(  'model' @@"`
	Enum    *ASTEnum   `parser:"| 'enum' @@"`
	Option  *ASTOption `parser:"| 'option' @@"`
	Struct  *ASTStruct `parser:"| 'struct' @@ )"`
}

type ASTEnum

type ASTEnum struct {
	Identifier ASTIdentifier   `parser:"@Ident '{'"`
	Values     []*ASTEnumValue `parser:"{ @@ } '}'"`
}

type ASTEnumValue

type ASTEnumValue struct {
	Comment string `parser:"{ @Comment }"`
	Name    string `parser:"@Ident ','"`
}

type ASTField

type ASTField struct {
	Comment string        `parser:"{ @Comment }"`
	Type    *ASTFieldType `parser:"@@"`
	Name    string        `parser:"@Ident ';'"`
}

type ASTFieldType

type ASTFieldType struct {
	Base    ASTType       `parser:"@Ident"`
	Generic *ASTFieldType `parser:"[ '<' @@ '>' ]"`
}

func (*ASTFieldType) IsPrimitive

func (ft *ASTFieldType) IsPrimitive() bool

func (*ASTFieldType) String

func (ft *ASTFieldType) String() string

type ASTIdentifier

type ASTIdentifier string

func (ASTIdentifier) IsReserved

func (id ASTIdentifier) IsReserved() bool

type ASTModel

type ASTModel struct {
	Identifier ASTIdentifier      `parser:"@Ident"`
	Elements   []*ASTModelElement `parser:"'{' { @@ } '}'"`
}

type ASTModelElement

type ASTModelElement struct {
	Option *ASTOption `parser:"  'option' @@"`
	Field  *ASTField  `parser:"| @@"`
}

type ASTOption

type ASTOption struct {
	Language string        `parser:"@Ident '.'"`
	Key      ASTIdentifier `parser:"@Ident '='"`
	Value    string        `parser:"@('true' | 'false' | 'null' | String | Int) ';'"`
}

type ASTStruct added in v0.0.5

type ASTStruct struct {
	Identifier ASTIdentifier       `parser:"@Ident"`
	Elements   []*ASTStructElement `parser:"'{' { @@ } '}'"`
}

type ASTStructElement added in v0.0.5

type ASTStructElement struct {
	Field *ASTField `parser:"@@"`
}

type ASTType

type ASTType string
const (
	Boolean   ASTType = "boolean"
	Integer   ASTType = "integer"
	Double    ASTType = "double"
	Timestamp ASTType = "timestamp"
	String    ASTType = "string"
	Bytes     ASTType = "bytes"
	Reference ASTType = "reference"
	GeoPoint  ASTType = "geopoint"
	Array     ASTType = "array"
	Map       ASTType = "map"
	// Fake types.
	URL  ASTType = "URL"
	File ASTType = "File"
)

func (ASTType) IsCollection

func (s ASTType) IsCollection() bool

Jump to

Keyboard shortcuts

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