We now also allow macro definitions in roles, and allow for macro overwrite.

In some cases, macro definitions within roles are more readable, for example for
key exchange protocols where the computations are asymmetrical.
This commit is contained in:
Cas Cremers 2012-11-23 13:26:04 +01:00
parent a71fe51036
commit ae155f8169

View File

@ -44,7 +44,6 @@ List findMacroDefinition(Symbol s)
{
Tac tmacro;
Symbol sl;
Tac tl;
tmacro = (Tac) l->data;
sl = (tmacro->t1.tac)->t1.sym; // The symbol
@ -162,10 +161,6 @@ spdl : UNTRUSTED termlist ';'
{
$$ = $1;
}
| macrodecl
{
$$ = $1;
}
;
roles : /* empty */
@ -281,26 +276,32 @@ knowsdecl : KNOWS termlist ';'
macrodecl : MACRO basicterm '=' termlist ';'
{
List l;
Tac t;
l = findMacroDefinition($2->t1.sym);
if (l == NULL)
{
Tac t;
/* Add to macro declaration list.
* TAC_MACRO doesn't show up in the compiler though. */
t = tacCreate(TAC_MACRO);
t->t1.tac = $2;
t->t2.tac = tacTuple($4);
macrolist = list_append(macrolist, t);
}
else
if (l != NULL)
{
/* Already defined. We can consider this
* a bug or we can define it to
* overwrite.
*
* For now, we decide to overwrite. This
* will also aid in straightforward file
* composition, if both files contain
* macros.
*/
macrolist = list_delete(l);
// Alternative:
//yyerror("macro symbol already defined earlier.");
}
// Now we know that l does not occur in macrolist
/* Add to macro declaration list.
* TAC_MACRO doesn't show up in the compiler though. */
t = tacCreate(TAC_MACRO);
t->t1.tac = $2;
t->t2.tac = tacTuple($4);
macrolist = list_append(macrolist, t);
$$ = NULL;
}
;
@ -349,6 +350,10 @@ declaration : secretpref CONST basictermlist typeinfo1 ';'
t->t3.tac = NULL; // Not secret: public
$$ = t;
}
| macrodecl
{
$$ = $1;
}
;
secretpref : /* empty */