parse

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Parser = participle.MustBuild(
	&Template{},
	participle.Lexer(lex),
	participle.Unquote("String"),
	participle.Elide("Whitespace", "Comment"),
)

Functions

This section is empty.

Types

type AnnotatedField

type AnnotatedField struct {
	Annotation string `("@" @Ident)?`
	Key        string `@String ":"`
	Value      Value  `@@`
}

type Function

type Function struct {
	Name string  `@Ident`
	Args []Value `"(" (@@ ("," @@)*)? ")"`
}

type Generator

type Generator struct {
	Range       string `"range" @JSONPath`
	SubTemplate Value  `"[" @@ "]"`
}

type Object

type Object struct {
	Fields []AnnotatedField `"{" (@@ ("," @@)* ","?)? "}"`
}

type Template

type Template struct {
	Root Value `@@`
}

type Value

type Value struct {
	// These are standard JSON fields.
	String *string  `  @String`
	Number *float64 `| @Number`
	Object *Object  `| @@`
	Array  []Value  `| "[" (@@ ("," @@)* ","?)? "]"`
	Bool   *bool    `| (@"true" | "false")`
	Null   bool     `| @"null"`

	// These are template elements generating JSON fields.
	Generator *Generator `| @@`
	Extractor *string    `| @JSONPath`
	Function  *Function  `| @@`
}

Jump to

Keyboard shortcuts

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