-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomprehensive-example.yini
More file actions
176 lines (145 loc) · 4.6 KB
/
Copy pathcomprehensive-example.yini
File metadata and controls
176 lines (145 loc) · 4.6 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/env yini
# Optional shebang, must appear on first line
/*
A comprehensive YINI example that exercises as
many syntax features, section header styles, data
types, and comment types/styles as possible.
Version: 1.0.1
*/
/*
* Optional directive variants (use only one "@yini" per file)
*/
@yini
@Yini
@YINI
/*
Example of a YINI document - all features showcased.
*/
/*
* All comment types/styles
*/
// Block comments (as above) and inline double-slash comments.
; Semicolon full-line comment (must be at start of line).
# Hash comment with space after hash (must have tab/space after hash).
# Hash comment with tabs and spaces after hash (must have tab/space after hash).
-- Disabled line, ignored by the parser.
--env = "dev" // Disabled assignment (should be ignored).
// Double-slash comment
/*
* All basic types
*/
^ TopSection // Basic section header (this is a double-slash inline-comment)
; Strings are raw by default, string must always be enclosed by quotes
rawStr = 'Hello world' // Member is key-value pair, (this is a hash inline-comment)
string1 = "My Service Name" // With double quotes
string2 = 'My Service Name' // With single quotes
string3 = "C:\Users\Name" // Strings are raw by default
string4 = './**' // Any \ are preserved as-is in raw strings
string5 = "\__/" # Hash inline comment
string6 = '**/*.js.map' # Hash inline comment
; Integer numbers
int1 = 42
int2 = -1
int3 = 0
; Floating point numbers
float1 = 0.42
float2 = -0.123
float3 = 0.0
float4 = 0.00
float5 = 321.0001
float6 = -99.0099
; Boolean literals are case-insensitive
bool1 = true
bool2 = false
bool3 = Yes # Alternative true
bool4 = No # Alternative false
bool5 = ON # Alternative true
bool6 = OFF # Alternative false
; Null literals are also case-insensitive
null1 = null
null2 = Null
null3 = NULL
/*
* More advanced numbers number notations
*/
^^ MoreAdvancedNumbers // Sub-section of "TopSection"
; Exponential numbers (scientific notation)
exp1 = 0.99e3
exp2 = -0.30e2
exp3 = 1.0e0 // Edge-case!
exp4 = .5e2 # Edge-case!
; Hexadecimal notation
hex2 = #FFEEAA // A hash without any tab/space after is interpreted as hex
hex1 = 0xDEADBEEF // The common "0x" works too
; Binary notation
//@todo
; Duodecimal notation
//@todo
; Oct notation
//@todo
; Raw strings can optionally be prefixed with R or r to be explicit
rawString1 = R'This is a "raw" string, it is as-is, no escapes are interpreted'
rawString2 = r"This is a\n**raw**\nstring, it's as-is, no escapes are interpreted"
; Classic strings are prefixed with C or c
; They support and interpret escape sequences like \n, \t
classicStr1 = C'Hello,\nWorld!\tWelcome to YINI.'
classicStr2 = c"Hello,\nWorld!\tWelcome to YINI."
// Triple quoted string, are multi-line.
// (!) NOTE: Only enclosed in double quotes supported!
tripleQStr = """Raw triple-quoted
string with \n not interpreted
and line breaks kept."""
tripleQClassicStr = C"""Classic triple-quoted (prefixed with C or c)
string: newlines and escapes like \n
are interpreted."""
; Section names in headers can be backticked if they include
; spacer or special characters.
^ `Backticked Section Name`
; Member keys can also be backticked.
`Project Name` = "My Project"
`Created By` = "Jane Developer"
`License Type` = "MIT"
`Is Active` = true
^^ Cache // Nested section with classic marker
type = "redis"
TTL = 3600
enabled = FALSE
list = [1, 2, 3, "str", true, null]
^^^ Options // Third-level section
host = '127.0.0.1'
port = 6379
_object = { id: 1, name: "Main", tags: {a: 3, b: 2, c: 1} }
_list = [ 'style', ['Volvo', 'Doc', 'Cat'] ]
_meta1 = [ 'font', 42, 'UI', [55, 44, 33], "default", 'description of' ]
_meta2 = [
{role: "admin", value: 1},
{role: "user", value: 2},
{role: "guest", value: 0}
]
^ Env // New top-level section
code = "dev"
mode = ON
pi = 3.14159
list_empty = []
object_empty = {}
; Shorthand numeric section marker headers.
^1 Database # Section header using numeric shorthand (^1)
enabled = true
user = "root"
password = '****'
roles = ["admin", "user", "guest"]
timeout = null
^2 Cache # Sub-section using numeric shorthand (^2)
type = "memcached"
TTL = 1800
^3 Options # Third-level sub-section with numeric marker
host = "192.168.1.1"
port = 11211
< AlternativeMarkerSection
val = 123
<< AltSubSection
val2 = "abc"
<<< AltThirdLevel
val3 = false
/END // (only optional)
// End of demo