diff --git a/src/parser.y b/src/parser.y index 63e4029..2d1c28b 100644 --- a/src/parser.y +++ b/src/parser.y @@ -49,7 +49,9 @@ int yylex(void); %type typeinfo1 %type typeinfoN %type term +%type basicterm %type termlist +%type basictermlist %type key %type roleref @@ -176,21 +178,21 @@ roleref : ID '.' ID } ; -declaration : secretpref CONST termlist typeinfo1 ';' +declaration : secretpref CONST basictermlist typeinfo1 ';' { Tac t = tacCreate(TAC_CONST); t->t1.tac = $3; t->t2.tac = $4; t->t3.tac = $1; $$ = t; } - | secretpref VAR termlist typeinfoN ';' + | secretpref VAR basictermlist typeinfoN ';' { Tac t = tacCreate(TAC_VAR); t->t1.tac = $3; t->t2.tac = $4; t->t3.tac = $1; $$ = t; } - | SECRET termlist typeinfo1 ';' + | SECRET basictermlist typeinfo1 ';' { Tac t = tacCreate(TAC_SECRET); t->t1.tac = $2; t->t2.tac = $3; @@ -237,7 +239,7 @@ typeinfoN : /* empty */ Tac t = tacCreate(TAC_UNDEF); $$ = t; } - | ':' termlist + | ':' basictermlist { $$ = $2; } @@ -254,12 +256,16 @@ optlabel : /* empty */ ; -term : ID +basicterm : ID { Tac t = tacCreate(TAC_STRING); t->t1.sym = $1; $$ = t; } + ; + +term : basicterm + { } | ID '(' termlist ')' { Tac t = tacCreate(TAC_STRING); @@ -282,6 +288,12 @@ termlist : term { $$ = tacCat($1,$3); } ; +basictermlist : basicterm + { } + | basicterm ',' basictermlist + { $$ = tacCat($1,$3); } + ; + key : term { } ; diff --git a/src/symbol.c b/src/symbol.c index b4c6b1d..4c9af85 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -241,6 +241,7 @@ symbolNextFree (Symbol prefixsymbol) int slen; slen = sprintf (buffer, "%s%i", prefixstr, n); + buffer[slen] = EOS; symb = lookup (buffer); if (symb == NULL) { diff --git a/src/term.c b/src/term.c index 4c953fc..998f072 100644 --- a/src/term.c +++ b/src/term.c @@ -317,11 +317,6 @@ termPrintCustom (Term term, char *leftvar, char *rightvar, char *lefttup, char *righttup, char *leftenc, char *rightenc, void (*callback) (int rid)) { - if (term == NULL) - { - eprintf ("*"); - return; - } #ifdef DEBUG if (!DEBUGL (4)) { @@ -330,6 +325,11 @@ termPrintCustom (Term term, char *leftvar, char *rightvar, char *lefttup, #else term = deVar (term); #endif + if (term == NULL) + { + eprintf ("*"); + return; + } if (realTermLeaf (term)) { if (term->type == VARIABLE && TermRunid (term) >= 0)