Download whisper.cpp/examples/grammar-parser.h from Dyen/Rovin: direct link, hf CLI and curl.
- Browser
- Download file 895 Bytes
-
https://huggingface.co/spaces/Dyen/Rovin/resolve/main/whisper.cpp/examples/grammar-parser.h
- Command line
-
hf download hf://spaces/Dyen/Rovin/whisper.cpp/examples/grammar-parser.h
-
curl -L -o grammar-parser.h https://huggingface.co/spaces/Dyen/Rovin/resolve/main/whisper.cpp/examples/grammar-parser.h
895 Bytes
| // Implements a parser for an extended Backus-Naur form (BNF), producing the | |
| // binary context-free grammar format specified by whisper.h. Supports character | |
| // ranges, grouping, and repetition operators. As an example, a grammar for | |
| // arithmetic might look like: | |
| // | |
| // root ::= expr | |
| // expr ::= term ([-+*/] term)* | |
| // term ::= num | "(" space expr ")" space | |
| // num ::= [0-9]+ space | |
| // space ::= [ \t\n]* | |
| namespace grammar_parser { | |
| struct parse_state { | |
| std::map<std::string, uint32_t> symbol_ids; | |
| std::vector<std::vector<whisper_grammar_element>> rules; | |
| std::vector<const whisper_grammar_element *> c_rules() const; | |
| }; | |
| parse_state parse(const char * src); | |
| void print_grammar(FILE * file, const parse_state & state); | |
| } | |