-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkg_doc.go
101 lines (101 loc) · 1.71 KB
/
pkg_doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Package conf can parse configuration text and populate structs with the results.
//
// Basic Syntax
//
// Example:
//
// # Lines beginning with punctuation are comments.
// ; Also a comment!
//
// # key=value pairs are assigned to the current section or the global section
// # if no section has been defined yet.
//
// key1 = value1
// key with spaces = value with spaces!
//
// quote1 = 'This value is "quoted"'
// quote2 = " whitespace
// is preserved in
// quoted values! "
// quote3 = `backticks quote too!`
//
// # Create a section with [ section-name ]
// [ section ]
// # This key value pair goes into a section named: section
// key = value
//
// [ sections can also have spaces ]
// keys.can.have.punctuation.too = neat!
//
// Repetition
//
// Both keys and sections can be turned into lists by repeating them:
// fruits = apples
// fruits = oranges
// fruits = bananas
//
// [ color ]
// name = red
// rgb = ff0000
//
// [ color ]
// name = blue
// rgb = 0000ff
//
// [ color ]
// name = green
// rgb = 00ff00
//
// Fill
//
// Use Conf.Fill() and Conf.FillByTag() to populate parsed configuration into your structures. Examples are provided below.
//
// Configuration EBNF
//
// Here lies the EBNF for configuration syntax:
// conf
// : line*
// ;
//
// line
// : comment
// | section
// | key_value
// ;
//
// section
// : '[' key ']'
// ;
//
// key_value
// : key '=' value
// ;
//
// key
// : [a-z0-9]+ key_extend*
// ;
//
// key_extend
// : punct [a-z0-9]+
// : ws+ [a-z0-9]+
// ;
//
// value
// : ['] ~[']* [']
// : ["] ~["]* ["]
// : [`] ~[`]* [`]
// : ~[rn]*
// ;
//
// comment
// : punct ~[rn]*
// ;
//
// punct
// : [!@#$%&*()_+=\|;:'"``,.<>/?~-^]
// ;
//
// ws
// : [ t]
// ;
package conf