diff --git a/examples/grammar-parser.cpp b/examples/grammar-parser.cpp index 53f9b26d5..650c3cfc5 100644 --- a/examples/grammar-parser.cpp +++ b/examples/grammar-parser.cpp @@ -265,7 +265,7 @@ namespace grammar_parser { const uint16_t * print_rule( FILE * file, const uint16_t * base, - const uint16_t * src, + const uint16_t * src, const std::map & symbol_id_names) { uint16_t rule_id = *src; fprintf(file, "<%zu>%s ::= ", src - base, symbol_id_names.at(rule_id).c_str()); @@ -312,4 +312,3 @@ namespace grammar_parser { } } } - diff --git a/examples/main/main.cpp b/examples/main/main.cpp index f43eb4fe4..47b4728e9 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -293,7 +293,7 @@ int main(int argc, char ** argv) { fprintf(stderr, "\n\n"); grammar_parser::parse_state parsed_grammar; - llama_grammar * grammar = NULL; + llama_grammar * grammar = NULL; if (!params.grammar.empty()) { parsed_grammar = grammar_parser::parse(params.grammar.c_str()); fprintf(stderr, "%s: grammar:\n", __func__); diff --git a/llama.cpp b/llama.cpp index 877a6a2a1..cc66a601e 100644 --- a/llama.cpp +++ b/llama.cpp @@ -1843,7 +1843,7 @@ static void llama_grammar_advance_stack( } const uint16_t * pos = stack.back(); - + if (*pos == 1) { // rule reference, apply rule to stack const uint16_t * subpos = rules[pos[1]] + 1; @@ -1871,7 +1871,7 @@ static void llama_grammar_advance_stack( // takes a set of possible pushdown stacks on a grammar, which are required to // be positioned at a character range (see `llama_grammar_advance_stack`), and // produces the N possible stacks if the given char is accepted at those -// positions +// positions static std::vector> llama_grammar_accept( const std::vector & rules, const std::vector> & stacks, @@ -1913,7 +1913,7 @@ static std::vector> llama_grammar_accept( return new_stacks; } -// returns `true` if one of the pushdown stacks can accept the given char. +// returns `true` if one of the pushdown stacks can accept the given char. static bool llama_grammar_peek( const std::vector> & stacks, const uint16_t chr) { @@ -1942,7 +1942,7 @@ static bool llama_grammar_peek( // // grammar - external -// +// struct llama_grammar * llama_grammar_init(const uint16_t * src, uint16_t start_rule_id) { const uint16_t * pos = src;