-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.thsl
123 lines (103 loc) · 3.29 KB
/
sample.thsl
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
# comments use a # (pound sign, hash)
# all root values get serialized into single dictionary
debug :bool: true
num :int: -3
name :str: Frank Drebin # strings don't need quotes and will be left/right trimmed of whitespace
name_quotes :str: " My name" # but they can use quotes if you don't want to trim the whitespace
name_single_quotes :str: 'My name is {name}' # single quotes allow templating, not implimented yet
escaping :str: "My \"Name "
# currently the colon is not required but it helps with readability
less_readable :int 3
# curly braces need escaping to be included in single quotes
escaping_single_quotes :str: 'My name is \{{name}\}'
# types are preceded by a : (colon) to allow for seamlessly adding new/custom types
# collection types do not need to have a type declared unless they contain homogeneous data
# in which case you can provide the data type that they will contain
graphics:
target_framerate :int: 60
fullscreen :bool: false
resolution:
width :int: 1920
height :int: 1080
key :str # defaults to empty string
key_without_value :float # defaults to 0
# indentation has to be a tab
a_char :char: a # can only be a single character
multi_line_str :str: "This
string is
on multiple
lines.
"
"keys can be in quotes" :int: 1 # for a key to have spaces it must be in quotes
# no need to worry about using type identifiers as keys or values
int :int: 1
str :str: str
my_num :int: "-50" # even if the value is in quotes it will be cast to the correct type
1 :str: one # keys will always end up as strings
some_bytes :bytes: 1110101
a_complex :complex: 3-2i
a_decimal :dec: 4.2
infinity :float: inf
neg_infinity :float: -inf
not_a_number :dec: nan
sci_note :float: 1.3e-4
hexadecimal :hex: deadbeef
octal :oct: 7
base_64 :base64: VGhlIFNwYW5pc2ggSW5xdWlzaXRpb24h
base_64_encode :base64e: Encode this string to base64
birthday :date: 1986-02-10
new_year :datetime: 2020-01-01 12:00:00 -6
my_interval :interval: 1 hour
alarm :time: 08:00:00AM
ip_address :ip: 192.168.1.1
ip_network :network: 192.168.0.0/28
my_page :url: http://www.example.com/index.html
env_var :env: PATH
range_example :range: 1..5 # non-inclusive
inclusive_example :range: 1...5 # inclusive
number_sep :int: 100_000_000 # numbers support seperators
homogeneous_list :int: # list entries are delimeted by a return character and are prefixed by a dash
- 1
- 2
- 4
- 7
# If the list is homogeneous then the type of all the elements can be provided next to the list name for convenience
heterogeneous_list:
- :int: 1
- :float: 3.14159
- :dec: 2.11
- :str: hello
list_of_dicts:
- {one :int: 1, two :int: 2}
- {three :int: 3, four :int: 4}
dict_one_liner: {one :int: 1, two :int: 2}
uniform_list_one_liner :int: [1, 2, 3,] # trailing commas are valid and encouraged!
heterogeneous_list_one_liner: [:int: 1, :float: 3.14159, :dec: 2.11, :str: hello]
a_set :int:
> 1
> 2
> 3
set_one_liner :int: <1, 2, 3>
a_tuple :int:
) 1
) 2
) 3
tuple_one_liner :int: (1, 2, 3)
typed_tuple:
) :int: 1
) :float: 2
) :dec: 3
) :str: 4
my_list: # list of multi-line dicts
-
one :int: 1
two :int: 2
-
three :int: 3
four :int: 4
named_tuple:
) one :int
) two :int
) three :float: 3.0 # default value?
# spaces are not required between entries or key-values but they sure do help readability
tuple_one_liner: (:int:1,:float:2)