stone

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

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

Go to latest
Published: Jan 6, 2020 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

stone-go

Stone configuration language Golang implement.

Example

An example: config.stone

cd example
go run main.go
# modify config.stone or add env, then retry it

Grammar

Reserved words

DELETE
TRUE
FALSE

Basic Types

String
Int
Float
Bool  (TRUE FALSE)
Array (of any type)
Map   (key: String, value: any)

Section

declare section:

[Identifier]

declare a section inherit another section:

[Identifier] < [Identifier]

Stmt

Stmt include Deletion and Assignment.

Deletion

DELETE LeftValue

Assignment

LeftValue = RightValue

LeftValue

LeftValue can be:

Identifier
Identifier[String] (item of Map)
Identifier[Int]    (item of Array)

RightValue

RightValue can be:

Literal Basic Types
LeftValue
EnvValue

EnvValue

${Identifier}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayValue

type ArrayValue struct {
	Array []*RightValue `("[" "]") | ("[" @@ ("," @@)* ","? "]")`
}

type Assignment

type Assignment struct {
	Left  LeftValue  `@@ "="`
	Right RightValue `@@`
}

type Boolean

type Boolean bool

func (*Boolean) Capture

func (b *Boolean) Capture(values []string) error

type EnvValue

type EnvValue struct {
	Env string `"$" "{" @Ident "}"`
}

type KV

type KV struct {
	K string     `@String ":"`
	V RightValue `@@`
}

type LeftValue

type LeftValue struct {
	Identifier string  `@Ident`
	KeyString  *string `("[" (@String `
	KeyInt     *int    `| @Int) "]")?`
}

type MapValue

type MapValue struct {
	KVs []*KV `("{" "}") | ("{" @@ ("," @@)* ","? "}")`
}

type RightValue

type RightValue struct {
	String     *string     `@String`
	Int        *int        `| @Int `
	Float      *float64    `| @Float`
	Bool       *Boolean    `| @("TRUE"|"FALSE")`
	LeftValue  *LeftValue  `| @@`
	ArrayValue *ArrayValue `| @@`
	MapValue   *MapValue   `| @@`
	EnvValue   *EnvValue   `| @@`
}

type Section

type Section struct {
	Name       string  `"[" @Ident "]"`
	ParentName *string `("<" "[" @Ident "]")?`
	Stmts      []*Stmt `@@*`
}

type SectionMap

type SectionMap map[string]*VarMap

func Parse

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

func ParseFile

func ParseFile(f string) (*SectionMap, error)

type Stmt

type Stmt struct {
	Assignment *Assignment `@@`
	Deletion   *LeftValue  `| "DELETE" @@`
}

type Stone

type Stone struct {
	Sections []*Section `( @@ )*`
}

type VarMap

type VarMap map[string]interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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