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:
parent
a71fe51036
commit
ae155f8169
37
src/parser.y
37
src/parser.y
@ -44,7 +44,6 @@ List findMacroDefinition(Symbol s)
|
|||||||
{
|
{
|
||||||
Tac tmacro;
|
Tac tmacro;
|
||||||
Symbol sl;
|
Symbol sl;
|
||||||
Tac tl;
|
|
||||||
|
|
||||||
tmacro = (Tac) l->data;
|
tmacro = (Tac) l->data;
|
||||||
sl = (tmacro->t1.tac)->t1.sym; // The symbol
|
sl = (tmacro->t1.tac)->t1.sym; // The symbol
|
||||||
@ -162,10 +161,6 @@ spdl : UNTRUSTED termlist ';'
|
|||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| macrodecl
|
|
||||||
{
|
|
||||||
$$ = $1;
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
roles : /* empty */
|
roles : /* empty */
|
||||||
@ -281,26 +276,32 @@ knowsdecl : KNOWS termlist ';'
|
|||||||
macrodecl : MACRO basicterm '=' termlist ';'
|
macrodecl : MACRO basicterm '=' termlist ';'
|
||||||
{
|
{
|
||||||
List l;
|
List l;
|
||||||
|
Tac t;
|
||||||
|
|
||||||
l = findMacroDefinition($2->t1.sym);
|
l = findMacroDefinition($2->t1.sym);
|
||||||
if (l == NULL)
|
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
|
|
||||||
{
|
{
|
||||||
/* Already defined. We can consider this
|
/* Already defined. We can consider this
|
||||||
* a bug or we can define it to
|
* a bug or we can define it to
|
||||||
* overwrite.
|
* 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.");
|
//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;
|
$$ = NULL;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -349,6 +350,10 @@ declaration : secretpref CONST basictermlist typeinfo1 ';'
|
|||||||
t->t3.tac = NULL; // Not secret: public
|
t->t3.tac = NULL; // Not secret: public
|
||||||
$$ = t;
|
$$ = t;
|
||||||
}
|
}
|
||||||
|
| macrodecl
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
secretpref : /* empty */
|
secretpref : /* empty */
|
||||||
|
Loading…
Reference in New Issue
Block a user