...
 
Commits (3)
......@@ -70,76 +70,76 @@ GList *include_dirs = NULL;
%%
decls : /* empty */
| START IDENT { start_nonterm ($2); } decls
| TERM tlist decls
| TERMPREFIX plist decls
| NAMESPACE IDENT {
warn_cxx ("`%namespace' directive");
namespaces = g_list_append (namespaces, $2);
} decls
| NO_LINES { lines_p = FALSE; } decls
| NO_GLIB { glib_p = FALSE; } decls
| NO_EXPORTED_SYMBOLS { exported_symbols_p = FALSE; } decls
| CXX_REF {
warn_cxx ("`%cxx-ref' directive");
cxx_ref_p = TRUE;
g_hash_table_insert (definedvars,
decls : /* empty */
| START IDENT { start_nonterm ($2); } decls
| TERM tlist decls
| TERMPREFIX plist decls
| NAMESPACE IDENT {
warn_cxx ("`%namespace' directive");
namespaces = g_list_append (namespaces, $2);
} decls
| NO_LINES { lines_p = FALSE; } decls
| NO_GLIB { glib_p = FALSE; } decls
| NO_EXPORTED_SYMBOLS { exported_symbols_p = FALSE; } decls
| CXX_REF {
warn_cxx ("`%cxx-ref' directive");
cxx_ref_p = TRUE;
g_hash_table_insert (definedvars,
g_strdup ("__CXX_REF"),
GUINT_TO_POINTER (1));
} decls
| rule_list optcost optcode optcfunc {
GList *tmp;
for (tmp = $1; tmp; tmp = tmp->next) {
rule_add (tmp->data, &($3), $2, $4);
} decls
| rule_list optcost optcode optcfunc {
GList *tmp;
for (tmp = $1; tmp; tmp = tmp->next) {
rule_add (tmp->data, &($3), $2, $4);
}
g_list_free ($1);
} decls
;
g_list_free ($1);
} decls
;
rule : IDENT ':' tree { $$ = make_rule ($1, $3); }
;
rule : IDENT ':' tree { $$ = make_rule ($1, $3); }
;
rule_list : rule { $$ = rule_list_prepend (NULL, $1); }
| rule ',' rule_list { $$ = rule_list_prepend ($3, $1); }
;
| rule ',' rule_list { $$ = rule_list_prepend ($3, $1); }
;
optcode : /* empty */ { $$ = NULL; }
| ';' { $$ = NULL; }
| CODE
;
plist : /* empty */
| plist IDENT { create_term_prefix ($2);}
;
tlist : /* empty */
| tlist IDENT { create_term ($2, -1);}
| tlist IDENT '=' INTEGER { create_term ($2, $4); }
;
tree : IDENT optvarname {
$$ = create_tree ($2 ? $2 : $1, $2 ? $1 : NULL, NULL, NULL);
}
| IDENT optvarname '(' tree ')' {
$$ = create_tree ($2 ? $2 : $1, $2 ? $1 : NULL, $4, NULL);
}
| IDENT optvarname '(' tree ',' tree ')' {
$$ = create_tree ($2 ? $2 : $1, $2 ? $1 : NULL, $4, $6);
}
;
| ';' { $$ = NULL; }
| CODE
;
plist : /* empty */
| plist IDENT { create_term_prefix ($2);}
;
tlist : /* empty */
| tlist IDENT { create_term ($2, -1);}
| tlist IDENT '=' INTEGER { create_term ($2, $4); }
;
tree : IDENT optvarname {
$$ = create_tree ($2 ? $2 : $1, $2 ? $1 : NULL, NULL, NULL);
}
| IDENT optvarname '(' tree ')' {
$$ = create_tree ($2 ? $2 : $1, $2 ? $1 : NULL, $4, NULL);
}
| IDENT optvarname '(' tree ',' tree ')' {
$$ = create_tree ($2 ? $2 : $1, $2 ? $1 : NULL, $4, $6);
}
;
optcost : /* empty */ {$$ = NULL; }
| STRING { $$ = g_strdup ($1); }
| INTEGER { $$ = g_strdup_printf ("%d", $1); }
;
| STRING { $$ = g_strdup ($1); }
| INTEGER { $$ = g_strdup_printf ("%d", $1); }
;
optcfunc : /*empty */ { $$ = NULL; }
| COST CODE { $$ = $2; }
;
| COST CODE { $$ = $2; }
;
optvarname: /* empty */ { $$ = NULL; }
| ':' IDENT { $$ = $2; }
| ':' IDENT { $$ = $2; }
%%
......@@ -211,13 +211,13 @@ fgets_inc(char *s, int size)
else
while ((b_found == FALSE) && include_dir)
{
if (strcmp ((char *) include_dir->data, "") == 0)
sprintf (path, "%s", filename);
else
sprintf (path, "%s/%s", (char *) include_dir->data, filename);
if ((new_include->fd = fopen (path, "r")))
b_found = TRUE;
include_dir = include_dir->next;
if (strcmp ((char *) include_dir->data, "") == 0)
sprintf (path, "%s", filename);
else
sprintf (path, "%s/%s", (char *) include_dir->data, filename);
if ((new_include->fd = fopen (path, "r")))
b_found = TRUE;
include_dir = include_dir->next;
}
if (b_found == FALSE)
{
......@@ -326,11 +326,11 @@ nextchar (void)
next = input;
*next = 0;
do {
if (!fgets_inc (input, sizeof (input)))
return 0;
if (!fgets_inc (input, sizeof (input)))
return 0;
ll = (input[0] == '%' && input[1] == '%');
next_state = state;
ll = (input[0] == '%' && input[1] == '%');
next_state = state;
if (state == 1) {
if (!ll && input[0] == '%') {
......@@ -339,7 +339,7 @@ nextchar (void)
ll = TRUE;
continue;
}
else if (!BOUND_STRCMP(&input[1], "ifndef")) {
else if (!BOUND_STRCMP(&input[1], "ifndef")) {
push_if (&input[STATIC_STRLEN ("ifndef") + 1], TRUE);
ll = TRUE;
continue;
......@@ -361,37 +361,37 @@ nextchar (void)
}
}
switch (state) {
case 0:
if (ll) {
next_state = 1;
} else
output ("%s", input);
break;
case 1:
if (ll) {
next_state = 2;
*next = 0;
return 0;
}
break;
default:
return 0;
}
ll = state != 1 || input[0] == '#';
state = next_state;
switch (state) {
case 0:
if (ll)
next_state = 1;
else
output ("%s", input);
break;
case 1:
if (ll) {
next_state = 2;
*next = 0;
return 0;
}
break;
default:
return 0;
}
ll = state != 1 || input[0] == '#';
state = next_state;
} while (ll);
}
return *next++;
return *next++;
}
void
yyparsetail (void)
{
if (lines_p)
output ("#line %d \"%s\"\n", LASTINPUT->yylineno,
LASTINPUT->filename);
output ("#line %d \"%s\"\n", LASTINPUT->yylineno, LASTINPUT->filename);
while (fgets_inc (input, sizeof (input)))
output ("%s", input);
}
......@@ -413,57 +413,57 @@ yylex (void)
if (c == '%') {
if (IS_TOKEN ("start", next)) {
EAT ("start", next);
return START;
EAT ("start", next);
return START;
}
if (IS_TOKEN ("termprefix", next)) {
EAT ("termprefix", next);
return TERMPREFIX;
EAT ("termprefix", next);
return TERMPREFIX;
}
if (IS_TOKEN ("term", next)) {
EAT ("term", next);
return TERM;
EAT ("term", next);
return TERM;
}
if (IS_TOKEN ("namespace", next)) {
EAT ("namespace", next);
return NAMESPACE;
EAT ("namespace", next);
return NAMESPACE;
}
if (IS_TOKEN ("no-lines", next)) {
EAT ("no-lines", next);
return NO_LINES;
EAT ("no-lines", next);
return NO_LINES;
}
if (IS_TOKEN ("no-glib", next)) {
EAT ("no-glib", next);
return NO_GLIB;
EAT ("no-glib", next);
return NO_GLIB;
}
if (IS_TOKEN ("no-exported-symbols", next)) {
EAT ("no-exported-symbols", next);
return NO_EXPORTED_SYMBOLS;
EAT ("no-exported-symbols", next);
return NO_EXPORTED_SYMBOLS;
}
if (IS_TOKEN ("cxx-ref", next)) {
EAT ("cxx-ref", next);
return CXX_REF;
EAT ("cxx-ref", next);
return CXX_REF;
}
return c;
}
if (isdigit (c)) {
int num = 0;
int num = 0;
do {
num = 10*num + (c - '0');
do {
num = 10*num + (c - '0');
} while (isdigit (c = (*next++)));
yylval.ivalue = num;
return INTEGER;
yylval.ivalue = num;
return INTEGER;
}
if (isalpha (c)) {
......@@ -471,12 +471,12 @@ yylex (void)
int l;
if (IS_TOKEN ("cost", next - 1)) {
EAT ("cost", next);
return COST;
EAT ("cost", next);
return COST;
}
while (isalpha (*n) || isdigit (*n) || *n == '_')
n++;
n++;
l = n - next + 1;
yylval.text = g_strndup (next - 1, l);
......@@ -489,7 +489,7 @@ yylex (void)
static char buf [100000];
while ((c = *next++) != '"' && c)
buf [i++] = c;
buf [i++] = c;
buf [i] = '\0';
yylval.text = g_strdup (buf);
......@@ -501,22 +501,22 @@ yylex (void)
unsigned i = 3, d = 1;
static char buf [100000];
g_memmove (buf, "\t{\n", 4);
memmove (buf, "\t{\n", 4);
if (lines_p)
i += sprintf (buf + 3, "#line %d \"%s\"\n", LASTINPUT->yylineno,
LASTINPUT->filename);
i += sprintf (buf + 3, "#line %d \"%s\"\n", LASTINPUT->yylineno,
LASTINPUT->filename);
while (d && (c = nextchar ())) {
buf [i++] = c;
assert (i < sizeof (buf));
switch (c) {
case '{': d++; break;
case '}': d--; break;
default:
break;
}
buf [i++] = c;
assert (i < sizeof (buf));
switch (c) {
case '{': d++; break;
case '}': d--; break;
default:
break;
}
}
g_memmove (buf + --i, "\n\t}", 4);
memmove (buf + --i, "\n\t}", 4);
yylval.text = g_strdup (buf);
return CODE;
......