Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var TokeniseJsonString = grammar.SimpleTokeniser([]grammar.TokenDef{
{
Ptn: `\s+`,
},
{
Name: "null",
Ptn: `null`,
},
{
Name: "bool",
Ptn: `true|false`,
},
{
Name: "op",
Ptn: `[{},:[\]]`,
},
{
Name: "string",
Ptn: `"[^"]*"`,
},
{
Name: "number",
Ptn: `-?[0-9]+(?:\.[0-9]+)?`,
},
})
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
grammar.Seq
Open grammar.Match `tok:"op,["` // This tells the parser a token of type "op" with value "[" should be used
Items []Json `sep:"op,,"` // This tells the parse items should be separater by a token of type "op" with value ","
Close grammar.Match `tok:"op,]"`
}
Array ::= "[" [ArrayBody] "]"
type Dict ¶
type Dict struct {
grammar.Seq
Open grammar.Match `tok:"op,{"`
Items []DictItem `sep:"op,,"`
Close grammar.Match `tok:"op,}"`
}
Dict ::= "{" [DictBody] "}"
type Json ¶
type Json struct {
grammar.OneOf // This tells the parser exactly one of the fields below should be populated
*Number
*String
*Null
*Bool
*Array
*Dict
}
Json ::= Number | String | Null | Bool | Array | Dict
type Number ¶
type Number struct {
grammar.Seq
Value Token `tok:"number"` // This tells the parser that a token of type "number" should be used
}
Number ::= <number token>
type Token ¶
type Token = grammar.SimpleToken
Click to show internal directories.
Click to hide internal directories.