mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 10:13:03 +00:00
bistromathic: use symbol numbers instead of YYTRANSLATE
* examples/c/bistromathic/parse.y: here.
This commit is contained in:
@@ -386,23 +386,25 @@ completion (const char *text, int start, int end)
|
|||||||
char **matches = calloc (ntokens + symbol_count () + 2, sizeof *matches);
|
char **matches = calloc (ntokens + symbol_count () + 2, sizeof *matches);
|
||||||
int match = 1;
|
int match = 1;
|
||||||
for (int i = 0; i < ntokens; ++i)
|
for (int i = 0; i < ntokens; ++i)
|
||||||
if (tokens[i] == YYTRANSLATE (TOK_VAR))
|
switch (tokens[i])
|
||||||
{
|
|
||||||
for (symrec *s = sym_table; s; s = s->next)
|
|
||||||
if (s->type == TOK_VAR && strncmp (text, s->name, len) == 0)
|
|
||||||
matches[match++] = strdup (s->name);
|
|
||||||
}
|
|
||||||
else if (tokens[i] == YYTRANSLATE (TOK_FUN))
|
|
||||||
{
|
{
|
||||||
|
case YYSYMBOL_FUN:
|
||||||
for (symrec *s = sym_table; s; s = s->next)
|
for (symrec *s = sym_table; s; s = s->next)
|
||||||
if (s->type == TOK_FUN && strncmp (text, s->name, len) == 0)
|
if (s->type == TOK_FUN && strncmp (text, s->name, len) == 0)
|
||||||
matches[match++] = strdup (s->name);
|
matches[match++] = strdup (s->name);
|
||||||
}
|
break;
|
||||||
else
|
case YYSYMBOL_VAR:
|
||||||
{
|
for (symrec *s = sym_table; s; s = s->next)
|
||||||
const char* token = yysymbol_name (tokens[i]);
|
if (s->type == TOK_VAR && strncmp (text, s->name, len) == 0)
|
||||||
if (strncmp (token, text, strlen (text)) == 0)
|
matches[match++] = strdup (s->name);
|
||||||
matches[match++] = strdup (token);
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
const char* token = yysymbol_name (tokens[i]);
|
||||||
|
if (strncmp (text, token, len) == 0)
|
||||||
|
matches[match++] = strdup (token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the longest common prefix, and install it in matches[0], as
|
// Find the longest common prefix, and install it in matches[0], as
|
||||||
|
|||||||
Reference in New Issue
Block a user