- Restricted the syntax somewhat, to avoid people typing crap.

(Cf. Golsteijn)
This commit is contained in:
ccremers 2006-05-16 15:00:21 +00:00
parent 6dff931dbc
commit 6a74883adf
3 changed files with 23 additions and 10 deletions

View File

@ -49,7 +49,9 @@ int yylex(void);
%type <tac> typeinfo1 %type <tac> typeinfo1
%type <tac> typeinfoN %type <tac> typeinfoN
%type <tac> term %type <tac> term
%type <tac> basicterm
%type <tac> termlist %type <tac> termlist
%type <tac> basictermlist
%type <tac> key %type <tac> key
%type <tac> roleref %type <tac> roleref
@ -176,21 +178,21 @@ roleref : ID '.' ID
} }
; ;
declaration : secretpref CONST termlist typeinfo1 ';' declaration : secretpref CONST basictermlist typeinfo1 ';'
{ Tac t = tacCreate(TAC_CONST); { Tac t = tacCreate(TAC_CONST);
t->t1.tac = $3; t->t1.tac = $3;
t->t2.tac = $4; t->t2.tac = $4;
t->t3.tac = $1; t->t3.tac = $1;
$$ = t; $$ = t;
} }
| secretpref VAR termlist typeinfoN ';' | secretpref VAR basictermlist typeinfoN ';'
{ Tac t = tacCreate(TAC_VAR); { Tac t = tacCreate(TAC_VAR);
t->t1.tac = $3; t->t1.tac = $3;
t->t2.tac = $4; t->t2.tac = $4;
t->t3.tac = $1; t->t3.tac = $1;
$$ = t; $$ = t;
} }
| SECRET termlist typeinfo1 ';' | SECRET basictermlist typeinfo1 ';'
{ Tac t = tacCreate(TAC_SECRET); { Tac t = tacCreate(TAC_SECRET);
t->t1.tac = $2; t->t1.tac = $2;
t->t2.tac = $3; t->t2.tac = $3;
@ -237,7 +239,7 @@ typeinfoN : /* empty */
Tac t = tacCreate(TAC_UNDEF); Tac t = tacCreate(TAC_UNDEF);
$$ = t; $$ = t;
} }
| ':' termlist | ':' basictermlist
{ {
$$ = $2; $$ = $2;
} }
@ -254,12 +256,16 @@ optlabel : /* empty */
; ;
term : ID basicterm : ID
{ {
Tac t = tacCreate(TAC_STRING); Tac t = tacCreate(TAC_STRING);
t->t1.sym = $1; t->t1.sym = $1;
$$ = t; $$ = t;
} }
;
term : basicterm
{ }
| ID '(' termlist ')' | ID '(' termlist ')'
{ {
Tac t = tacCreate(TAC_STRING); Tac t = tacCreate(TAC_STRING);
@ -282,6 +288,12 @@ termlist : term
{ $$ = tacCat($1,$3); } { $$ = tacCat($1,$3); }
; ;
basictermlist : basicterm
{ }
| basicterm ',' basictermlist
{ $$ = tacCat($1,$3); }
;
key : term key : term
{ } { }
; ;

View File

@ -241,6 +241,7 @@ symbolNextFree (Symbol prefixsymbol)
int slen; int slen;
slen = sprintf (buffer, "%s%i", prefixstr, n); slen = sprintf (buffer, "%s%i", prefixstr, n);
buffer[slen] = EOS;
symb = lookup (buffer); symb = lookup (buffer);
if (symb == NULL) if (symb == NULL)
{ {

View File

@ -317,11 +317,6 @@ termPrintCustom (Term term, char *leftvar, char *rightvar, char *lefttup,
char *righttup, char *leftenc, char *rightenc, char *righttup, char *leftenc, char *rightenc,
void (*callback) (int rid)) void (*callback) (int rid))
{ {
if (term == NULL)
{
eprintf ("*");
return;
}
#ifdef DEBUG #ifdef DEBUG
if (!DEBUGL (4)) if (!DEBUGL (4))
{ {
@ -330,6 +325,11 @@ termPrintCustom (Term term, char *leftvar, char *rightvar, char *lefttup,
#else #else
term = deVar (term); term = deVar (term);
#endif #endif
if (term == NULL)
{
eprintf ("*");
return;
}
if (realTermLeaf (term)) if (realTermLeaf (term))
{ {
if (term->type == VARIABLE && TermRunid (term) >= 0) if (term->type == VARIABLE && TermRunid (term) >= 0)