MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / main

Function main

smallthinker/tests/test-grammar-parser.cpp:142–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142int main()
143{
144 verify_failure(R"""(
145 root ::= "a"{,}"
146 )""");
147
148 verify_failure(R"""(
149 root ::= "a"{,10}"
150 )""");
151
152 verify_parsing(R"""(
153 root ::= "a"
154 )""", {
155 {"root", 0},
156 }, {
157 // root (index 0)
158 {LLAMA_GRETYPE_CHAR, 'a'},
159 {LLAMA_GRETYPE_END, 0},
160 });
161
162 verify_parsing(R"""(
163 root ::= "a" | [bdx-z] | [^1-3]
164 )""", {
165 {"root", 0},
166 }, {
167 // root (index 0)
168 {LLAMA_GRETYPE_CHAR, 'a'},
169 {LLAMA_GRETYPE_ALT, 0},
170 {LLAMA_GRETYPE_CHAR, 'b'},
171 {LLAMA_GRETYPE_CHAR_ALT, 'd'},
172 {LLAMA_GRETYPE_CHAR_ALT, 'x'},
173 {LLAMA_GRETYPE_CHAR_RNG_UPPER, 'z'},
174 {LLAMA_GRETYPE_ALT, 0},
175 {LLAMA_GRETYPE_CHAR_NOT, '1'},
176 {LLAMA_GRETYPE_CHAR_RNG_UPPER, '3'},
177 {LLAMA_GRETYPE_END, 0},
178 });
179
180 verify_parsing(R"""(
181 root ::= a+
182 a ::= "a"
183 )""", {
184 {"a", 1},
185 {"root", 0},
186 {"root_2", 2},
187 }, {
188 // root (index 0)
189 {LLAMA_GRETYPE_RULE_REF, /* a */ 1},
190 {LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
191 {LLAMA_GRETYPE_END, 0},
192 // a (index 1)
193 {LLAMA_GRETYPE_CHAR, 'a'},
194 {LLAMA_GRETYPE_END, 0},
195 // root_2 (index 2)
196 {LLAMA_GRETYPE_RULE_REF, /* a */ 1},
197 {LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
198 {LLAMA_GRETYPE_ALT, 0},
199 {LLAMA_GRETYPE_END, 0},

Callers

nothing calls this directly

Calls 2

verify_failureFunction · 0.85
verify_parsingFunction · 0.85

Tested by

no test coverage detected