Dict.borg
Dict.borg
`*-----------------------------------*`
`* >>>Pico v.1.1<<< *`
`* Theo D'Hondt *`
`* VUB Programming Technology Lab *`
`* (c)1999 *`
`*-----------------------------------*`
`* dictionaries *`
`* (METACIRCULAR VERSION) *`
`*-----------------------------------*`
{ Add_Var(Nam, Val, Dct):
Error('dictionary not initialized');
Add_Cst(Nam, Val, Dct):
Error('dictionary not initialized');
Get_Any(Nam, Dct):
Error('dictionary not initialized');
Get_Cst(Nam, Dct):
Error('dictionary not initialized');
Set_Var(Nam, Val, Dct):
Error('dictionary not initialized');
Init_Dict():
{ Add_Var(Nam, Val, Dct):=
Make_VAR(Nam, Val, Dct);
Add_Cst(Nam, Val, Dct):=
Make_CST(Nam, Val, Dct);
same_name(Na1, Na2)::
{ na1: Na1[TXT_VAL_idx];
na2: Na2[TXT_VAL_idx];
na1 = na2 };
any_case:: case(VAR_tag <> (any_var(Nam, Dct):
if(same_name(Dct[VAR_NAM_idx], Nam),
Dct[VAR_VAL_idx],
Get_Any(Nam, Dct[VAR_DCT_idx]))),
CST_tag <> (any_cst(Nam, Dct):
if(same_name(Dct[CST_NAM_idx], Nam),
Dct[CST_VAL_idx],
Get_Any(Nam, Dct[CST_DCT_idx]))),
VOI_tag <> (any_voi(Nam, Dct):
Error('undefined: ' + Nam[TXT_VAL_idx])),
void <> (any_err(Nam, Dct):
Error('abstract grammar violation')));
Get_Any(Nam, Dct):=
{ tag: Dct[TAG_idx];
cas: any_case(tag);
cas(Nam, Dct) };
cst_case:: case(VAR_tag <> (cst_var(Nam, Dct):
if(same_name(Dct[VAR_NAM_idx], Nam),
Error('is invisible: ' + Nam[TXT_VAL_idx]),
Get_Cst(Nam, Dct[VAR_DCT_idx]))),
CST_tag <> (cst_cst(Nam, Dct):
if(same_name(Dct[CST_NAM_idx], Nam),
Dct[CST_VAL_idx],
Get_Cst(Nam, Dct[CST_DCT_idx]))),
VOI_tag <> (cst_voi(Nam, Dct):
Error('undefined: ' + Nam[TXT_VAL_idx])),
void <> (cst_err(Nam, Dct):
Error('abstract grammar violation')));
Get_Cst(Nam, Dct):=
{ tag: Dct[TAG_idx];
cas: cst_case(tag);
cas(Nam, Dct) };
set_case:: case(VAR_tag <> (set_var(Nam, Val, Dct):
if(same_name(Dct[VAR_NAM_idx], Nam),
Dct[VAR_VAL_idx]:= Val,
Set_Var(Nam, Val, Dct[VAR_DCT_idx]))),
CST_tag <> (set_cst(Nam, Val, Dct):
if(same_name(Dct[CST_NAM_idx], Nam),
Error('cannot be changed: ' + Nam[TXT_VAL_idx]),
Set_Var(Nam, Val, Dct[CST_DCT_idx]))),
VOI_tag <> (set_voi(Nam, Val, Dct):
Error('undefined: ' + Nam[TXT_VAL_idx])),
void <> (set_err(Nam, Val, Dct):
Error('abstract grammar violation')));
Set_Var(Nam, Val, Dct):=
{ tag: Dct[TAG_idx];
cas: set_case(tag);
cas(Nam, Val, Dct);
void };
Init_Dict():=
_VOID_;
Init_Dict() };
display('dictionary ... installed', eoln) }