[Flora-commits] flora2 flrcoder.P,1.40,1.41 flrcompiler.P,1.67,1.68 flrcomposer.P,1.5,1.6 flrdepende
Brought to you by:
kifer
|
From: Chang Z. <ch...@us...> - 2005-03-21 06:55:10
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4343 Modified Files: flrcoder.P flrcompiler.P flrcomposer.P flrdependency.P flrlexer.P flrparser.P Log Message: introduce variables prefixed with ! for tabled predicates Index: flrcoder.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcoder.P,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- flrcoder.P 2 Feb 2005 12:11:09 -0000 1.40 +++ flrcoder.P 21 Mar 2005 06:55:00 -0000 1.41 @@ -86,6 +86,7 @@ is_prhashednumber(PRHASHEDNUMBER(Number,I),Number,I). is_prvariable(PRVARIABLE(Name,I),Name,I). is_prhashedvariable(PRHASHEDVARIABLE(Name,I),Name,I). +is_prexclvariable(PREXCLVARIABLE(Name,I),Name,I). is_prstring(PRSTRING(String,I),String,I). is_prlist(PRLIST(L,T,I),L,T,I). is_prfdbstorage(PRFDBSTORAGE(PRATOM(WS,I)),USERMODULE,WS,I). @@ -448,6 +449,14 @@ put(0')). flora_write_struct(Term,_Prefix) :- + is_prexclvariable(Term,Name,_Index), + !, + flora_write_quoted_atom(FL_EXCL), + put(0'(), + flora_write_variable(Name), + put(0')). + +flora_write_struct(Term,_Prefix) :- is_prcallervar(Term), !, flora_write_atom(FLORA_HEADLIT_CALLER_VAR_NAME). @@ -969,7 +978,6 @@ PF=WRAP_HILOG, is_prlist(PArgs,[FObj|ObjList],[],_I) - %% Case of X@Y, where X is a variable ; is_prvariable(P,_VarName,_Index) -> PArgs = P, PF=FL_LIBMOD % this wrapper is ignored -- just a placeholder @@ -978,6 +986,10 @@ PArgs = P, PF=FL_LIBMOD % this wrapper is ignored -- just a placeholder + ; is_prexclvariable(P,_VarName,_Index) -> + PArgs = P, + PF=FL_LIBMOD % this wrapper is ignored -- just a placeholder + ; is_flogic(P,Wrap,Arity,ObjList), flora_concat_atoms([Prefix,Wrap],PF), @@ -1203,6 +1215,12 @@ flora_build_variable(Name,VarList,Var), Code=FL_HASHED(Var). +flora_build_struct(Term,_DWS,_Prefix,VarList,Code,(Code,Index)) :- + is_prexclvariable(Term,Name,Index), + !, + flora_build_variable(Name,VarList,Var), + Code=FL_EXCL(Var). + %% We don't display the value of the special caller variable in the shell. %% Instead, we bind all occurrences of this variable in a rule to the same var flora_build_struct(Term,_DWS,_Prefix,VarList,Code,(_V,NO_INDEX)) :- @@ -1647,7 +1665,6 @@ PF=WRAP_HILOG, is_prlist(PArgs,[FObj|ObjList],[],NO_INDEX) - %% Case of X@Y, where X is a variable ; is_prvariable(P,_VarName,_Index) -> PArgs = P, %% this particular wrapper is ignored in fllibmodlit/4 @@ -1658,6 +1675,11 @@ %% this particular wrapper is ignored in fllibmodlit/4 PF=FL_LIBMOD + ; is_prexclvariable(P,_VarName,_Index) -> + PArgs = P, + %% this particular wrapper is ignored in fllibmodlit/4 + PF=FL_LIBMOD + ; is_flogic(P,Wrap,Arity,ObjList), flora_concat_atoms([Prefix,Wrap],PF), Index: flrcompiler.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcompiler.P,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- flrcompiler.P 2 Feb 2005 12:11:09 -0000 1.67 +++ flrcompiler.P 21 Mar 2005 06:55:00 -0000 1.68 @@ -187,6 +187,7 @@ is_flvar(FLVAR(Name,Index),Name,Index). is_flhashedvar(FLHASHEDVAR(Name,Index),Name,Index). +is_flexclvar(FLEXCLVAR(Name,Index),Name,Index). is_fllist(FLLIST(L,T,I),L,T,I). is_isaspecop(FL_ISA). @@ -349,6 +350,9 @@ hashedvarobj_struct(Name,Index,PRVARIABLE(Name,Index)). hashedvar_struct(Name,Index,PRHASHEDVARIABLE(Name,Index)). +exclvarobj_struct(Name,Index,PRVARIABLE(Name,Index)). +exclvar_struct(Name,Index,PREXCLVARIABLE(Name,Index)). + strobj_struct(FLSTRING(String,I),PRSTRING(String,I)). hashedstrobj_struct(FLHASHEDSTRING(String,I),PRSTRING(String,I)). newoid_struct(Oid,Index,PRNEWOID(Oid,Index)). @@ -507,7 +511,8 @@ %% X@module or X@flora(module) %% or #X@module or #X@flora(module) - ; (is_varobj_struct(P,Index); is_hashedvar_struct(P,Index)) -> + %% or !X@module or !X@flora(module) + ; (is_varobj_struct(P,Index); is_hashedvar_struct(P,Index); is_exclvar_struct(P,Index)) -> compile_workspace_term(WS,WSCode), set_context(literal_workspace(WS)), callerargsterm_struct(ThisModuleName,CallerInfo), @@ -976,6 +981,20 @@ flora_concat_atoms([NEWVAR,OldValAtm],Name), hashedvar_struct(Name,Index,VarObj). +new_exclvarobj(Index,VarObj) :- + flora_increment_counter(NEWVAR,1,OldVal,_NewVal), + number_codes(OldVal,OldValLst), + atom_codes(OldValAtm,OldValLst), + flora_concat_atoms([NEWVAR,OldValAtm],Name), + exclvarobj_struct(Name,Index,VarObj). + +new_exclvar(Index,VarObj) :- + flora_increment_counter(NEWVAR,1,OldVal,_NewVal), + number_codes(OldVal,OldValLst), + atom_codes(OldValAtm,OldValLst), + flora_concat_atoms([NEWVAR,OldValAtm],Name), + exclvar_struct(Name,Index,VarObj). + new_varobjlist(0,[]) :- !. @@ -1034,6 +1053,7 @@ is_varobj_struct(PRVARIABLE(_Name,Index),Index). is_strobj_struct(PRSTRING(_String,_I)). is_hashedvar_struct(PRHASHEDVARIABLE(_Name,Index),Index). +is_exclvar_struct(PREXCLVARIABLE(_Name,Index),Index). allvars(Term,Vars) :- allvars(Term,Vs,[]), @@ -1105,6 +1125,11 @@ !, is_flvar(NewParserTerm,Name,Index). +collect_vars(ParserTerm,[NewParserTerm|Vars],Vars) :- + is_flexclvar(ParserTerm,Name,Index), + !, + is_flvar(NewParserTerm,Name,Index). + collect_vars(ParserTerm,Vars,Vars) :- ( is_flatom(ParserTerm,_Atom); is_flhashedatom(ParserTerm,_Atom); @@ -1130,13 +1155,13 @@ subtract_vars([],_,[]) :- !. subtract_vars([H|T1],L,[H|T2]) :- - (is_flvar(H,FL_UNDERSCORE,_I);is_flhashedvar(H,FL_UNDERSCORE,_I)), + (is_flvar(H,FL_UNDERSCORE,_I);is_flhashedvar(H,FL_UNDERSCORE,_I);is_flexclvar(H,FL_UNDERSCORE,_I)), !, subtract_vars(T1,L,T2). subtract_vars([H|T],L,V) :- - (is_flvar(H,N,_I);is_flhashedvar(H,N,_I)), - (is_flvar(X,N,_J);is_flhashedvar(X,N,_J)), + (is_flvar(H,N,_I);is_flhashedvar(H,N,_I);is_flexclvar(H,N,_I)), + (is_flvar(X,N,_J);is_flhashedvar(X,N,_J);is_flexclvar(H,N,_I)), member(X,L), !, subtract_vars(T,L,V). @@ -1165,8 +1190,10 @@ indexvars([],[]) :- !. indexvars([T|L],Vars) :- - (is_flvar(T,Name,I);is_flhashedvar(T,Name,I)), - ( (is_flvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0);is_flhashedvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0)) -> + (is_flvar(T,Name,I);is_flhashedvar(T,Name,I);is_flexclvar(T,Name,I)), + ( (is_flvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flhashedvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flexclvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0))-> indexvars(L,Vars) ; Vars=[I-Name|Vs], @@ -1196,14 +1223,14 @@ singleton_vars([],[]) :- !. singleton_vars([V|L],[V|Vs]) :- - (is_flvar(V,FL_UNDERSCORE,_I);is_flhashedvar(V,FL_UNDERSCORE,_I)), + (is_flvar(V,FL_UNDERSCORE,_I);is_flhashedvar(V,FL_UNDERSCORE,_I);is_flexclvar(V,FL_UNDERSCORE,_I)), !, singleton_vars(L,Vs). singleton_vars([V],[V]) :- !. singleton_vars([V1,V2|L],Vars) :- - ( (is_flvar(V1,Name,_I);is_flhashedvar(V1,Name,_I)), (is_flvar(V2,Name,_J);is_flhashedvar(V2,Name,_I)) -> + ( (is_flvar(V1,Name,_I);is_flhashedvar(V1,Name,_I);is_flexclvar(V1,Name,_I)), (is_flvar(V2,Name,_J);is_flhashedvar(V2,Name,_J);is_flexclvar(V2,Name,_J)) -> remove_dupvars(L,Name,Vs), singleton_vars(Vs,Vars) ; @@ -1213,7 +1240,7 @@ remove_dupvars([V|L],Name,Vars) :- - (is_flvar(V,Name,_I);is_flhashedvar(V,Name,_I)), + (is_flvar(V,Name,_I);is_flhashedvar(V,Name,_I);is_flexclvar(V,Name,_I)), !, remove_dupvars(L,Name,Vars). @@ -1227,8 +1254,10 @@ singleton_warning([],WarnList,WarnList). singleton_warning([V|L],WarnList,WarnTail) :- - (is_flvar(V,Name,I);is_flhashedvar(V,Name,I)), - ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0);is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0)) -> + (is_flvar(V,Name,I);is_flhashedvar(V,Name,I);is_flexclvar(V,Name,I)), + ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flexclvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0))-> singleton_warning(L,WarnList,WarnTail) ; compiling_warning(I,SINGLETON_VAR,W), @@ -1244,8 +1273,10 @@ unbound_warning([],WarnList,WarnList). unbound_warning([V|L],WarnList,WarnTail) :- - (is_flvar(V,Name,I);is_flhashedvar(V,Name,I)), - ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0);is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0)) -> + (is_flvar(V,Name,I);is_flhashedvar(V,Name,I);is_flexclvar(V,Name,I)), + ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flexclvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0))-> unbound_warning(L,WarnList,WarnTail) ; compiling_warning(I,UNBOUND_VAR,W), @@ -1826,7 +1857,11 @@ compile_head_literal(ParserTerm,Code,Status) :- set_context(compiling_headliteral), ( is_flvar(ParserTerm,VName,VIndex) -> - compile_flvar(VName,VIndex,V), + compile_flvar(VName,VIndex,Code), + Status=[] + + ; is_flhashedvar(ParserTerm,VName,VIndex) -> + compile_flhashedvar(VName,VIndex,V), ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> Code = V ; @@ -1837,8 +1872,8 @@ ), Status=[] - ; is_flhashedvar(ParserTerm,VName,VIndex) -> - compile_flhashedvar(VName,VIndex,V), + ; is_flexclvar(ParserTerm,VName,VIndex) -> + compile_flexclvar(VName,VIndex,V), ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> Code = V ; @@ -1940,7 +1975,7 @@ ), ( is_flvar(ParserTerm,VName,VIndex) -> compile_flvar(VName,VIndex,V), - ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> + ( (COMPILATION_CONTEXT(compile_with_var_module); COMPILATION_CONTEXT(goal_reification); COMPILATION_CONTEXT(compile_meta);COMPILATION_CONTEXT(compile_delete)) -> SpecCode = V ; thismodule_struct(ThisModule), @@ -1964,6 +1999,19 @@ OidCode=NULL, Status=[] + ; is_flexclvar(ParserTerm,VName,VIndex) -> + compile_flexclvar(VName,VIndex,V), + ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> + SpecCode = V + ; + thismodule_struct(ThisModule), + callerargsterm_struct(ThisModule,CallerInfo), %% does not matter + atomobj_struct(FL_INVALIDMODULE,Module), + florasyslib_struct(VIndex,FLLIBMODLIT,3,[V,Module,CallerInfo],SpecCode) + ), + OidCode=NULL, + Status=[] + ; is_flterm(ParserTerm,Funct,N,Args) -> compile_fltermlit(Funct,N,Args,OidCode,SpecCode,Status) @@ -2130,7 +2178,8 @@ conjunct_code([SpecCode,OidCode],Code), clear_context(varpred_reify) ; - conjunct_code([OidCode,SpecCode],Code) + conjunct_code([OidCode,SpecCode],Code), + clear_context(compiling_prolog) ), (nonvar(PrevContext) -> set_context(PrevContext); true), (nonvar(PrologContext) -> set_context(PrologContext); true). @@ -2282,6 +2331,9 @@ ; is_flhashedvar(ParserTerm,Name,Index) -> compile_flhashedvar_without_hash(Name,Index,Object) + ; is_flexclvar(ParserTerm,Name,Index) -> + compile_flexclvar_without_excl(Name,Index,Object) + ; is_flstring(ParserTerm,_S) -> strobj_struct(ParserTerm,Object) @@ -2389,7 +2441,9 @@ %% Don't set compilation context to be 'goal_reification': %% These are special predicates such as findall, call, etc., %% for which we want to set the caller argument = current module + set_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), ( S == [] -> compile_argpathexplist(L,ArgTypeList,LObj,OidCode,Code,Status) @@ -2445,6 +2499,20 @@ hashedvarobj_struct(Name,Index,VarObject) ). +compile_flexclvar(Name,Index,VarObject) :- + ( Name == FL_UNDERSCORE -> + new_exclvar(Index,VarObject) + ; + exclvar_struct(Name,Index,VarObject) + ). + +compile_flexclvar_without_excl(Name,Index,VarObject) :- + ( Name == FL_UNDERSCORE -> + new_exclvarobj(Index,VarObject) + ; + exclvarobj_struct(Name,Index,VarObject) + ). + compile_flhashedvar(Name,Index,VarObject) :- ( Name == FL_UNDERSCORE -> new_hashedvar(Index,VarObject) @@ -2676,31 +2744,58 @@ %% the attribute (M) and the value (V). We conjunct this code in front of the %% code for the molecule %% NULL means that we don't pass OID code out, because we use it right here. -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flfdattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexplist([AttTerm,ValTerm],[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> fdattspec_struct(BODYLITERAL,Object,AttObj,RefType,ValObj,SCode), %% SCode: code to produce object reference, attribute, and value %% OCode: code for the pure attribute spec of the object %% OidCode: code to produce the attribute and the value - conjunct_code([SCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([SCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,SCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% Same for ->> %% No OidCode is passed outside: we consume it here -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flmvdattspec(SpecTerm,AttTerm,RefType,ValTermList), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(AttTerm,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), ( S == [] -> ( ValTermList == [] -> mvdattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), - conjunct_code([ACode,SCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,SCode],Code) + ), Status=[] ; %% An mvd spec can have several terms in the value set @@ -2711,26 +2806,54 @@ %% SCode: code to produce pure attr specs and %% the objects that represents the values (Status == [] -> - conjunct_code([AOidCode,VOidCode],OidCode), - conjunct_code([ACode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,SCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,SCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,SCode],Code) + ) + ) ; true ) ) ; Status=S - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% signatures: =>, *=>, etc. -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flsigattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(AttTerm,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), (S == [] -> (is_flemptyterm(ValTerm) -> sigattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), - conjunct_code([ACode,SCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,SCode],Code) + ), Status=[] ; compile_pathexp(ValTerm,ValObj,VOidCode,VCode,Status), @@ -2742,40 +2865,77 @@ %% ACode: code for the attribute %% VOidCode: code to produce value of the attribute %% VCode: code for value of the attribute - conjunct_code([ACode,VCode,SCode],Code), - conjunct_code([AOidCode,VOidCode],OidCode) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,VCode,SCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,VCode,SCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,VCode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,VCode,SCode],Code) + ) + ) ; true ) ) ; Status = S - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% +>>, *+>> -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flincattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexplist([AttTerm,ValTerm],[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> incattspec_struct(Object,AttObj,RefType,ValObj,SCode), - conjunct_code([SCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([SCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,SCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% same for ->-> -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_fltolistattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexplist([AttTerm,ValTerm],[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> tolistattspec_struct(Object,AttObj,RefType,ValObj,SCode), %% Fold OidCode in front of the molecule - conjunct_code([SCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([SCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,SCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% Obj[true], Obj[fail], Obj[!] translate as true, fail, and ! compile_flspecbody(_Object,SpecTerm,NULL,Code,Status) :- @@ -2789,50 +2949,86 @@ Status=[]. %% Obj[X>Y], Obj[X=Y], etc. -compile_flspecbody(_Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(_Object,SpecTerm,NULL,Code,Status) :- is_flpassthru(SpecTerm,P), is_flterm(P, Funct, N, Args), !, - compile_prlgterm(Funct,N,Args,TCode,OidCode,ACode,Status), + compile_prlgterm(Funct,N,Args,TCode,_OidCode,ACode,Status), (Status == [] -> conjunct_code([ACode,TCode],Code); true). %% for O[BoolMeth] -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flmethspec(SpecTerm,MethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(MethTerm,MethObj,OidCode,MCode,Status), ( Status == [] -> methspec_struct(BODYLITERAL,Object,MethObj,SCode), %% Fold OidCode in front of the molecule - conjunct_code([MCode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([MCode,SCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,MCode,SCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% for O[*BoolMeth] -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flimethspec(SpecTerm,IMethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(IMethTerm,IMethObj,OidCode,IMCode,Status), ( Status == [] -> imethspec_struct(BODYLITERAL,Object,IMethObj,SCode), %% Fold OidCode in front of the molecule - conjunct_code([IMCode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([IMCode,SCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,IMCode,SCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% O[#M] -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_fltranspec(SpecTerm,TranTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(TranTerm,TranObj,OidCode,TCode,Status), ( Status == [] -> transpec_struct(BODYLITERAL,Object,TranObj,SCode), - conjunct_code([TCode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([TCode,SCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,TCode,SCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). /**************************************************************************** @@ -3093,7 +3289,9 @@ compile_head_argpathexplist([T|L],[FL_BODYFORMULA|ArgTypeList],[TCode|LObj],Code,Status) :- !, set_context(goal_reification), + set_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), clear_context(goal_reification), ( S == [] -> @@ -3139,6 +3337,9 @@ ; is_flhashedvar(ParserTerm,Name,Index) -> compile_flhashedvar_without_hash(Name,Index,Object) + ; is_flexclvar(ParserTerm,Name,Index) -> + compile_flexclvar_without_excl(Name,Index,Object) + ; is_flstring(ParserTerm,_S) -> strobj_struct(ParserTerm,Object) @@ -3442,6 +3643,14 @@ OidCode = NULL, Status = [] + ; is_flexclvar(ParserTerm,VarName,Index) -> + %% Is this possible? Should be taken care by the libmodlit code + attach_workspace(WS, + compile_flexclvar(VarName,Index,VarCode), + VarCode,WSCode), + OidCode = NULL, + Status = [] + ; is_flbirelate(ParserTerm,ObjTerm1,RelType,ObjTerm2) -> compile_wsflbirelate(ObjTerm1,RelType,ObjTerm2,WS,_Obj,OidCode,WSCode,Status) @@ -3573,7 +3782,9 @@ %% workspace not distributive over nested "meta" %%compile_body(T,TCode,S), set_context(goal_reification), + set_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), clear_context(goal_reification), ( S == [] -> @@ -3871,9 +4082,15 @@ %% the attribute (M) and the value (V). We conjunct this code in front of the %% code for the molecule %% NULL means tht we don't pass OID code out, because we use it right here. -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flfdattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexplist([AttTerm,ValTerm],WS,[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> attach_workspace(WS, @@ -3882,24 +4099,45 @@ %% WSCode: code to produce object reference, attribute, and value %% OCode: code for the pure attribute spec of the object %% OidCode: code to produce the attribute and the value - conjunct_code([WSCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([WSCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,WSCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% No OidCode is passed outside: we consume it here -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flmvdattspec(SpecTerm,AttTerm,RefType,ValTermList), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(AttTerm,WS,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), ( S == [] -> ( ValTermList == [] -> attach_workspace(WS, mvdattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), SCode,WSCode), %% Fold OidCode in front of molecule - conjunct_code([ACode,WSCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,WSCode],Code) + ), Status=[] ; compile_wsmvdattspec(Object,AttObj,RefType,ValTermList,WS,VOidCode,WSCode,Status), @@ -3907,27 +4145,55 @@ %% ACode: Code to produce attribute %% WSCode: code to produce pure attr specs and %% the objects that represents the values - conjunct_code([ACode,WSCode],Code), - conjunct_code([AOidCode,VOidCode],OidCode) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,WSCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,WSCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,WSCode],Code) + ) + ) ; true ) ) ; Status=S - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% signatures: =>, *=>, etc. -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flsigattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(AttTerm,WS,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), (S == [] -> (is_flemptyterm(ValTerm) -> attach_workspace(WS, sigattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), SCode,WSCode), - conjunct_code([ACode,WSCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,WSCode],Code) + ), Status=[] ; compile_wsflpathexp(ValTerm,WS,ValObj,VOidCode,VCode,Status), @@ -3935,47 +4201,83 @@ attach_workspace(WS, sigattspec_struct(BODYLITERAL,Object,AttObj,RefType,ValObj,SCode), SCode,WSCode), - conjunct_code([ACode,VCode,WSCode],Code), - conjunct_code([AOidCode,VOidCode],OidCode) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,VCode,WSCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,VCode,WSCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,VCode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,VCode,WSCode],Code) + ) + ) ; true ) ) ; Status = S - ). - + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% +>>, *+>>@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flincattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexplist([AttTerm,ValTerm],WS,[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> attach_workspace(WS, incattspec_struct(Object,AttObj,RefType,ValObj,SCode), SCode,WSCode), %% Fold OidCode in front of molecule - conjunct_code([WSCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([WSCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,WSCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% same for ->->@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_fltolistattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexplist([AttTerm,ValTerm],WS,[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> attach_workspace(WS, tolistattspec_struct(Object,AttObj,RefType,ValObj,SCode), SCode,WSCode), - conjunct_code([WSCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([WSCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,WSCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% Obj[true], Obj[fail], Obj[!] translate as true, fail, and ! compile_wsflspecbody(_Object,SpecTerm,_WS,NULL,Code,Status) :- @@ -3989,57 +4291,93 @@ Status=[]. %% Obj[X>Y], Obj[X=Y], etc. -compile_wsflspecbody(_Object,SpecTerm,_WS,OidCode,Code,Status) :- +compile_wsflspecbody(_Object,SpecTerm,_WS,NULL,Code,Status) :- is_flpassthru(SpecTerm,P), is_flterm(P, Funct, N, Args), !, - compile_prlgterm(Funct,N,Args,TCode,OidCode,ACode,Status), + compile_prlgterm(Funct,N,Args,TCode,_OidCode,ACode,Status), (Status == [] -> conjunct_code([ACode,TCode],Code); true). %% for O[BoolMeth]@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flmethspec(SpecTerm,MethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(MethTerm,WS,MethObj,OidCode,MCode,Status), ( Status == [] -> attach_workspace(WS, methspec_struct(BODYLITERAL,Object,MethObj,SCode), SCode,WSCode), - conjunct_code([MCode,WSCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([MCode,WSCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,MCode,WSCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% for O[*BoolMeth]@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flimethspec(SpecTerm,IMethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(IMethTerm,WS,IMethObj,OidCode,IMCode,Status), ( Status == [] -> attach_workspace(WS, imethspec_struct(BODYLITERAL,Object,IMethObj,SCode), SCode,WSCode), %% Fold OidCode in front of molecule - conjunct_code([IMCode,WSCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([IMCode,WSCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,IMCode,WSCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% O[#M]@module -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_fltranspec(SpecTerm,TranTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(TranTerm,WS,TranObj,OidCode,TCode,Status), ( Status == [] -> attach_workspace(WS, transpec_struct(BODYLITERAL,Object,TranObj,SCode), SCode,WSCode), - conjunct_code([TCode,WSCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([TCode,WSCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,TCode,WSCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). /**************************************************************************** @@ -4426,6 +4764,12 @@ compile_flhashedvar(VarName,Index,VarCode), VarCode,Code), Status=[] + ; is_flexclvar(ParserTerm,VarName,Index) -> + %% Is this possible? Should be taken care by the libmodlit code + attach_workspace(WS, + compile_flexclvar(VarName,Index,VarCode), + VarCode,Code), + Status=[] ; attach_workspace(WS, atomlit_struct(HEADLITERAL,ParserTerm,ACode), @@ -4464,7 +4808,9 @@ %% workspace not distributive over nested `meta' argument spec %%compile_body(T,TCode,S), set_context(goal_reification), + clear_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), clear_context(goal_reification), ( S == [] -> @@ -4986,7 +5332,9 @@ compile_fldelete_list([H|T],CodeList,Status) :- %% Call compile_body_literal because path expressions should be %% compiled into queries. + set_context(compile_delete), compile_body_literal(H,HCode,S), + clear_context(compile_delete), ( S == [] -> compile_conjunct2list(HCode,HCodeList), compile_fldelete_list(T,TCodeList,Status), Index: flrparser.P =================================================================== RCS file: /cvsroot/flora/flora2/flrparser.P,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- flrparser.P 2 Feb 2005 12:11:09 -0000 1.72 +++ flrparser.P 21 Mar 2005 06:55:01 -0000 1.73 @@ -48,8 +48,9 @@ #define ALLOW_VARIABLES allow_variables #define DISALLOW_VARIABLES disallow_variables -#define ALLOW_HASH allow_hash -#define DISALLOW_HASH disallow_hash +#define DISALLOW_HASH disallow_hash %% neither # nor ! is allowed +#define ALLOW_HASH_NOPREFIX allow_hash_noprefix %% for method +#define ALLOW_HASH_EXCL allow_hash_excl %% predicate name %% If the module specification is for a dynamic rule (eg. foo in %% insertrule{(...)@foo}), the module information is just discarded when @@ -631,6 +632,8 @@ flhashedobject_struct(OBJECT(HASHED_VARIABLE(Name),I),FLHASHEDVAR(Name,I)) :- !. flhashedobject_struct(OBJECT(HASHED_ASCII_STRING(Str),I),FLHASHEDSTRING(Str,I)) :- !. +flexclobject_struct(OBJECT(EXCL_VARIABLE(Name),I),FLEXCLVAR(Name,I)) :- !. + flhashednumber_struct(OBJECT(HASHED_NUMBER(Num),I),FLHASHEDNUMBER(Num,I)) :- !. is_flhashedobject_struct(FLHASHEDATOM(_Atom,_I)) :- !. @@ -645,10 +648,13 @@ get_flvar_struct(OBJECT(VARIABLE(Name),I),FLVAR(Name,I)). get_flhashedvar_struct(OBJECT(HASHED_VARIABLE(Name),I),FLHASHEDVAR(Name,I)). +get_flexclvar_struct(OBJECT(EXCL_VARIABLE(Name),I),FLEXCLVAR(Name,I)). is_flvar_struct(FLVAR(_Name,_I)). is_flhashedvar_struct(FLHASHEDVAR(_Name,_I)). +is_flexclvar_struct(FLEXCLVAR(_Name,_I)). is_anonymous_flvar_struct(FLVAR(FL_UNDERSCORE,_I)). is_anonymous_flhashedvar_struct(FLHASHEDVAR(FL_UNDERSCORE,_I)). +is_anonymous_flexclvar_struct(FLEXCLVAR(FL_UNDERSCORE,_I)). fllist_struct(L,T,Index,FLLIST(L,T,Index)). is_fllist_struct(FLLIST(_L,_T,_I)). @@ -1222,6 +1228,9 @@ flexport_wrap_term(WS,WSFrom,OBJECT(HASHED_VARIABLE(Term),N),[],IsUpdatable,Code), !. +flora_export_compose_term([OBJECT(EXCL_VARIABLE(Term),N)],WS,WSFrom,IsUpdatable,Code) :- + flexport_wrap_term(WS,WSFrom,OBJECT(EXCL_VARIABLE(Term),N),[],IsUpdatable,Code), + !. /**************************************************************************** flora_export_wrap_multiple_terms(+WorkSpace,+WSFrom,+Args,+InitTermCode,+Modules,+IsUpdatable,-Code) Transfroms (t1,t2) >> (m1,m2,m3) --> [(t1,(m1,m2,m3)) , (t2,(m1,m2,m3))] @@ -1398,6 +1407,7 @@ %% Term >> m1, m2 flora_export_check_error(OBJECT(VARIABLE(_Term),_),_Status). flora_export_check_error(OBJECT(HASHED_VARIABLE(_Term),_),_Status). +flora_export_check_error(OBJECT(EXCL_VARIABLE(_Term),_),_Status). /**************************************************************************** @@ -1958,7 +1968,7 @@ flora_head_literal(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),Code,Status) :- !, - flora_head_term(Funct,N,Args,ALLOW_HASH,Code,Status). + flora_head_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status). flora_head_literal(CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- !, @@ -2746,7 +2756,7 @@ flora_body_literal(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),Code,Status) :- !, - flora_term(Funct,N,Args,ALLOW_HASH,Code,Status). + flora_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status). %% ...[...] flora_body_literal(CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- @@ -2793,17 +2803,8 @@ flhashedobject_struct(CanoniTerm,Code). flora_body_literal(CanoniTerm,Code,Status) :- - get_flvar_struct(CanoniTerm,C), - !, - ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> - parsing_error(CanoniTerm,NO_PRED_VAR,Status) - ; - Status=[], - C=Code - ). - -flora_body_literal(CanoniTerm,Code,Status) :- - get_flhashedvar_struct(CanoniTerm,C), + (get_flvar_struct(CanoniTerm,C); get_flhashedvar_struct(CanoniTerm,C); + get_flexclvar_struct(CanoniTerm,C)), !, ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> parsing_error(CanoniTerm,NO_PRED_VAR,Status) @@ -2857,12 +2858,12 @@ ; WSFlag = WITH_MODULE, - flora_term(Funct,N,Args,ALLOW_HASH,Code,Status) + flora_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status) ). flora_body_wsliteral(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- !, - flora_term(Funct,N,Args,ALLOW_HASH,Code,Status). + flora_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status). flora_body_wsliteral(CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- !, @@ -2908,7 +2909,7 @@ ). flora_body_wsliteral(CanoniTerm,_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- - get_flvar_struct(CanoniTerm,C), + (get_flvar_struct(CanoniTerm,C); get_flhashedvar_struct(CanoniTerm,C); get_flexclvar_struct(CanoniTerm,C)), !, ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> parsing_error(CanoniTerm,NO_PRED_VAR,Status) @@ -2917,15 +2918,10 @@ C=Code ). -flora_body_wsliteral(CanoniTerm,_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- - get_flhashedvar_struct(CanoniTerm,C), +flora_body_wsliteral(CanoniTerm,_FloraModSpec,_WSFrom,WITH_MODULE,_Code,Status) :- + get_flvar_struct(CanoniTerm,_C), !, - ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> - parsing_error(CanoniTerm,NO_PRED_VAR,Status) - ; - Status=[], - C=Code - ). + parsing_error(CanoniTerm,ERROR_VARPREFIX,Status). flora_body_wsliteral(CanoniTerm,_FloraModSpec,WS_FROM_DYNRULE,WITHOUT_MODULE,Code,Status) :- !, @@ -3096,7 +3092,7 @@ %% term flora_parse_body_literal_template(CanoniTerm,Code,Status) :- - flora_term_template(CanoniTerm,ALLOW_HASH,Code,Status), + flora_term_template(CanoniTerm,ALLOW_HASH_EXCL,Code,Status), !. flora_parse_body_literal_template(CanoniTerm,_Code,Status) :- @@ -3204,7 +3200,7 @@ ). flora_attmeth_template(CanoniTerm,Code,Status) :- - flora_term_template(CanoniTerm,ALLOW_HASH,C,Status), + flora_term_template(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> ((is_flhashedterm_struct(C);is_flhashedobject_struct(C)) -> fltranspec_struct(C,Code) @@ -3261,17 +3257,19 @@ Status=S ). -flora_term_template(ObjectTerm,_HashFlag,Code,Status) :- +flora_term_template(ObjectTerm,HashFlag,Code,Status) :- %% primitive structures except named variables flobject_struct(ObjectTerm,Code), !, - (is_flvar_struct(Code), not is_anonymous_flvar_struct(Code) -> + ( is_flvar_struct(Code), not is_anonymous_flvar_struct(Code) -> parsing_error(ObjectTerm,ERROR_NAMEDVAR,Status) - ; - Status = [] + ; is_flvar_struct(Code), HashFlag==ALLOW_HASH_EXCL -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; Status = [] ). -flora_term_template(ObjectTerm,ALLOW_HASH,Code,Status) :- +flora_term_template(ObjectTerm,HashFlag,Code,Status) :- + (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL), flhashedobject_struct(ObjectTerm,Code), !, (is_flhashedvar_struct(Code), not is_anonymous_flhashedvar_struct(Code) -> @@ -3280,6 +3278,15 @@ Status = [] ). +flora_term_template(ObjectTerm,ALLOW_HASH_EXCL,Code,Status) :- + flexclobject_struct(ObjectTerm,Code), + !, + (is_flexclvar_struct(Code), not is_anonymous_flexclvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_NAMEDVAR,Status) + ; + Status = [] + ). + flora_term_template(CanoniTerm,_HashFlag,_Code,Status) :- parsing_error(CanoniTerm,ERROR_TEMPLATE,Status). @@ -3457,7 +3464,7 @@ flora_term(Funct,N,Args,HashFlag,Code,Status) :- flhashedobject_struct(Funct,F), !, - ( HashFlag == ALLOW_HASH -> + ( (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL) -> flora_pathexplist(Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -3465,6 +3472,16 @@ ). flora_term(Funct,N,Args,HashFlag,Code,Status) :- + flexclobject_struct(Funct,F), + !, + ( HashFlag==ALLOW_HASH_EXCL -> + flora_pathexplist(Args,AList,Status), + (Status == [] -> flterm_struct(F,N,AList,Code); true) + ; + parsing_error(Funct,ERROR_EXCL_SYMBOL,Status) + ). + +flora_term(Funct,N,Args,HashFlag,Code,Status) :- change_atom_name_if_needed(Funct,Funct1), flora_pathexp(Funct1,HashFlag,F,S), ( S == [] -> @@ -3736,9 +3753,14 @@ !, parsing_error(ObjectTerm,ERROR_NEWOID,Status). -flora_pathexp(ObjectTerm,_HF,Code,[]) :- +flora_pathexp(ObjectTerm,HashFlag,Code,Status) :- flobject_struct(ObjectTerm,Code), - !. + !, + ( HashFlag==ALLOW_HASH_EXCL, is_flvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; + Status=[] + ). flora_pathexp(CANOBRACE(_L,_N,I),_HF,_Code,Status) :- !, @@ -3907,7 +3929,7 @@ fltranspec_struct(C,Code). flora_attmethspec(CanoniTerm,Code,Status) :- - flora_pathexp(CanoniTerm,ALLOW_HASH,C,Status), + flora_pathexp(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -4046,7 +4068,7 @@ flora_head_term(Funct,N,Args,HashFlag,Code,Status) :- flhashedobject_struct(Funct,F), !, - (HashFlag == ALLOW_HASH -> + ( (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL) -> flora_head_pathexplist(Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -4054,6 +4076,16 @@ ). flora_head_term(Funct,N,Args,HashFlag,Code,Status) :- + flexclobject_struct(Funct,F), + !, + ( HashFlag==ALLOW_HASH_EXCL -> + flora_head_pathexplist(Args,AList,Status), + (Status == [] -> flterm_struct(F,N,AList,Code); true) + ; + parsing_error(Funct,ERROR_EXCL_SYMBOL,Status) + ). + +flora_head_term(Funct,N,Args,HashFlag,Code,Status) :- flora_head_pathexp(Funct,HashFlag,F,S), ( S == [] -> flora_head_pathexplist(Args,AList,Status), @@ -4169,9 +4201,14 @@ !, flora_head_list(L,T,I,Code,Status). -flora_head_pathexp(ObjectTerm,_HF,Code,[]) :- +flora_head_pathexp(ObjectTerm,HashFlag,Code,Status) :- flobject_struct(ObjectTerm,Code), - !. + !, + ( HashFlag==ALLOW_HASH_EXCL, is_flvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; + Status=[] + ). %% ${...} - reification flora_head_pathexp(CANOTERM(Funct,N,FL_BRACE,Args,If,Ip),_HF,Code,Status) :- @@ -4293,7 +4330,7 @@ fltranspec_struct(C,Code). flora_head_attmethspec(CanoniTerm,Code,Status) :- - flora_head_pathexp(CanoniTerm,ALLOW_HASH,C,Status), + flora_head_pathexp(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -4630,7 +4667,7 @@ ( get_atom(Funct,F), flora_prlgdef(F,N) -> parsing_error(If,NO_PROLOG,Status) ; - flora_db_term(Mode,Funct,N,Args,ALLOW_HASH,Code,Status) + flora_db_term(Mode,Funct,N,Args,ALLOW_HASH_EXCL,Code,Status) ). flora_dblit(Mode,CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- @@ -4672,6 +4709,11 @@ not is_anonymous_flhashedvar_struct(Code), !. +flora_dblit(_Mode,CanoniTerm,Code,[]) :- + get_flexclvar_struct(CanoniTerm,Code), + not is_anonymous_flexclvar_struct(Code), + !. + flora_dblit(Mode,CanoniTerm,_Code,Status) :- !, ( Mode == FLINS -> @@ -4735,7 +4777,7 @@ ( get_atom(Funct,F), flora_nowsp(F,N) -> parsing_error(If,NO_WORKSPACE,Status) ; - flora_db_term(Mode,Funct,N,Args,ALLOW_HASH,Code,Status) + flora_db_term(Mode,Funct,N,Args,ALLOW_HASH_EXCL,Code,Status) ). flora_dbwslit(Mode,CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- @@ -4776,6 +4818,11 @@ not is_anonymous_flhashedvar_struct(Code), !. +flora_dbwslit(_Mode,CanoniTerm,Code,[]) :- + get_flexclvar_struct(CanoniTerm,Code), + not is_anonymous_flexclvar_struct(Code), + !. + /**** allow insert{Var@Mod} flora_dbwslit(_Mode,CanoniTerm,_Code,Status) :- get_flvar_struct(CanoniTerm,_V), @@ -4805,7 +4852,7 @@ flora_db_term(Mode,Funct,N,Args,HF,Code,Status) :- flhashedobject_struct(Funct,F), !, - (HF == ALLOW_HASH -> + ( (HF==ALLOW_HASH_NOPREFIX;HF==ALLOW_HASH_EXCL) -> flora_db_pathexplist(Mode,Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -4813,6 +4860,16 @@ ). flora_db_term(Mode,Funct,N,Args,HF,Code,Status) :- + flexclobject_struct(Funct,F), + !, + ( HF==ALLOW_HASH_EXCL -> + flora_db_pathexplist(Mode,Args,AList,Status), + (Status == [] -> flterm_struct(F,N,AList,Code); true) + ; + parsing_error(Funct,ERROR_EXCL_SYMBOL,Status) + ). + +flora_db_term(Mode,Funct,N,Args,HF,Code,Status) :- flora_db_pathexp(Mode,Funct,HF,F,S), ( S == [] -> flora_db_pathexplist(Mode,Args,AList,Status), @@ -4946,9 +5003,14 @@ %% Anonymous oid IS allowed in insert/delete -flora_db_pathexp(_Mode,ObjectTerm,_HF,Code,[]) :- +flora_db_pathexp(_Mode,ObjectTerm,HashFlag,Code,Status) :- flobject_struct(ObjectTerm,Code), - !. + !, + ( HashFlag==ALLOW_HASH_EXCL, is_flvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; + Status=[] + ). flora_db_pathexp(Mode,CanoniTerm,_HF,_Code,Status) :- ( Mode == FLINS -> @@ -5087,7 +5149,7 @@ fltranspec_struct(C,Code). flora_db_attmethspec(Mode,CanoniTerm,Code,Status) :- - flora_db_pathexp(Mode,CanoniTerm,ALLOW_HASH,C,Status), + flora_db_pathexp(Mode,CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -5272,6 +5334,12 @@ ; Status=[] ) + ; get_flexclvar_struct(CanoniTerm,Code) -> + ( is_anonymous_flexclvar_struct(Code) -> + parsing_error(I,ERROR_HDLITERAL,Status) + ; + Status=[] + ) ; flora_head_literal(CanoniTerm,Code,Status) ). Index: flrcomposer.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcomposer.P,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- flrcomposer.P 2 Feb 2005 12:11:09 -0000 1.5 +++ flrcomposer.P 21 Mar 2005 06:55:00 -0000 1.6 @@ -142,6 +142,8 @@ is_sole_operand(HASHED_NUMBER(_,_)) :- !. is_sole_operand(HASHED_SYMBOL_TOKEN(_,_)) :- !. +is_sole_operand(EXCL_VARIABLE(_,_)) :- !. + is_sole_operand(IDENTIFIER(I,_)) :- \+ flora_opdef(_,_,I), !. is_sole_operand(QUOTED_ATOM(QA,_)) :- \+ flora_opdef(_,_,QA), !. is_sole_operand(SYMBOL_TOKEN(ST,_)) :- \+ flora_opdef(_,_,ST), !. Index: flrdependency.P =================================================================== RCS file: /cvsroot/flora/flora2/flrdependency.P,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- flrdependency.P 2 Feb 2005 12:11:09 -0000 1.20 +++ flrdependency.P 21 Mar 2005 06:55:00 -0000 1.21 @@ -486,6 +486,8 @@ true ; HC=FL_HASHED(Var), var(Var) -> Wrap=WRAP_HILOG + ; HC=FL_EXCL(Var), var(Var) -> + Wrap=WRAP_TABLED_HILOG ; ( functor(HC,DB,3), dboperation(DB,3) -> HC =.. [DB,WS,DBList,Cond], Index: flrlexer.P =================================================================== RCS file: /cvsroot/flora/flora2/flrlexer.P,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- flrlexer.P 2 Feb 2005 12:11:09 -0000 1.9 +++ flrlexer.P 21 Mar 2005 06:55:01 -0000 1.10 @@ -171,6 +171,7 @@ flora_hashed_identifier_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_variable_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_hashed_variable_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) + flora_excl_variable_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_number_struct(+Num,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_hashed_number_struct(+Num,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_quoted_atom_struct(+AtomStr,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) @@ -199,6 +200,10 @@ text_info(LN1,CN1,LN2,CN2,TextStr,Text), atom_codes(A,TextStr). +flora_excl_variable_struct(TextStr,LN1,CN1,LN2,CN2,EXCL_VARIABLE(A,Text)) :- + text_info(LN1,CN1,LN2,CN2,TextStr,Text), + atom_codes(A,TextStr). + flora_hashed_variable_struct(TextStr,LN1,CN1,LN2,CN2,HASHED_VARIABLE(A,Text)) :- text_info(LN1,CN1,LN2,CN2,TextStr,Text), atom_codes(A,TextStr). @@ -271,6 +276,9 @@ flora_token_text(VARIABLE(_A,Text),TextStr,BLN,BCN,ELN,ECN) :- text_info(BLN,BCN,ELN,ECN,TextStr,Text). +flora_token_text(EXCL_VARIABLE(_A,Text),[CH_EXCLAMATION|TextStr],BLN,BCN,ELN,ECN) :- + text_info(BLN,BCN,ELN,ECN,TextStr,Text). + flora_token_text(HASHED_VARIABLE(_A,Text),[CH_HASH|TextStr],BLN,BCN,ELN,ECN) :- text_info(BLN,BCN,ELN,ECN,TextStr,Text). @@ -430,6 +438,9 @@ ; Char == CH_HASH -> read_hashed_token(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + ; Char == CH_EXCLAMATION -> + read_excl_token(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + ; Char >= CH_a, Char =< CH_z -> read_identifier(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) @@ -464,6 +475,27 @@ ). /**************************************************************************** + read_excl_token(+Char,+LineNo,+CharNo,+NextLN,+NextCN,-TokenList,-Status) + parses variables starting from Char which is !. +****************************************************************************/ +read_excl_token(C1,LN1,CN1,LN,CN,TokenList,Status) :- + get_char(LN,CN,Ch,NextLN,NextCN), + ( Ch >= CH_A, Ch =< CH_Z -> + read_excl_named_variable(Ch,LN1,CN1,LN,CN,NextLN,NextCN,TokenList,Status) + ; Ch == CH_UNDERSCORE -> + read_excl_underscore_variable(Ch,LN1,CN1,LN,CN,NextLN,NextCN,TokenList,Status) + ; Ch == CH_EXCLAMATION -> + flora_symbol_token_struct([Ch,Ch],LN1,CN1,LN,CN,Tk), + get_char(NextLN,NextCN,C2,NLN,NCN), + read_tokens(C2,NextLN,NextCN,NLN,NCN,Tokens,Status), + TokenList=[Tk|Tokens] + ; + flora_symbol_token_struct([C1],LN1,CN1,LN1,CN1,Tk), + read_tokens(Ch,LN,CN,NextLN,NextCN,Tokens,Status), + TokenList=[Tk|Tokens] + ). + +/**************************************************************************** read_hashed_tokens(+Char,+LineNo,+CharNo,+NextLN,+NextCN,-TokenList,-Status) parses tokens starting from Char which is #. ****************************************************************************/ @@ -622,6 +654,17 @@ read_tokens(NextCh,NLN,NCN,NNLN,NNCN,Tokens,Status). /**************************************************************************** + read_excl_named_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) + reads a variable name following a ! +****************************************************************************/ +read_excl_named_variable(C2,LN1,CN1,LN2,CN2,LN,CN,TokenList,Status) :- + read_name(C2,LN2,CN2,LN,CN,Chars,LN3,CN3,NextCh,NLN,NCN,NNLN,NNCN), + flora_excl_variable_struct(Chars,LN1,CN1,LN3,CN3,Tk), + TokenList=[Tk|Tokens], + !, + read_tokens(NextCh,NLN,NCN,NNLN,NNCN,Tokens,Status). + +/**************************************************************************** read_hashed_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) reads a variable name following a # ****************************************************************************/ @@ -721,6 +764,38 @@ /**************************************************************************** + read_excl_underscore_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) + reads an underscore variable name following a ! +****************************************************************************/ +read_excl_underscore_variable(C2,LN1,CN1,LN2,CN2,LN,CN,TokenList,Status) :- + get_char(LN,CN,Ch,NextLN,NextCN), + ( Ch >= CH_a, Ch =< CH_z -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + + ; Ch >= CH_A, Ch =< CH_Z -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + + ; Ch >= CH_0, Ch =< CH_9 -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + + ; Ch == CH_UNDERSCORE -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + ; + Chars=[], + LN3=LN2, + CN3=CN2, + NCh=Ch, + NLN=LN, + NCN=CN, + NNLN=NextLN, + NNCN=NextCN + ), + flora_excl_variable_struct([C2|Chars],LN1,CN1,LN3,CN3,Tk), + TokenList=[Tk|Tokens], + !, + read_tokens(NCh,NLN,NCN,NNLN,NNCN,Tokens,Status). + +/**************************************************************************** read_hashed_underscore_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) reads an underscore variable name following a # ****************************************************************************/ @@ -752,6 +827,7 @@ !, read_tokens(NCh,NLN,NCN,NNLN,NNCN,Tokens,Status). + /**************************************************************************** read_special(+Ch,+LineNo,+CharNo,+NextLN,+NextCN,-Tokens,-Status) handles tokens made of special symbols. @@ -789,18 +865,6 @@ read_comment_line(Ch,LN,CN,NLN,NCN,LN1,CN1,TxChs,LN2,CN2,Tokens,Status). */ -read_special(CH_EXCLAMATION,LN1,CN1,LN,CN,[Tk|Tokens],Status) :- - !, - get_char(LN,CN,C1,NextLN,NextCN), - ( C1 == CH_EXCLAMATION -> - flora_symbol_token_struct([C1,C1],LN1,CN1,LN,CN,Tk), - get_char(NextLN,NextCN,C2,NLN,NCN), - read_tokens(C2,NextLN,NextCN,NLN,NCN,Tokens,Status) - ; - flora_symbol_token_struct([CH_EXCLAMATION],LN1,CN1,LN1,CN1,Tk), - read_tokens(C1,LN,CN,NextLN,NextCN,Tokens,Status) - ). - read_special(CH_DOT,LN1,CN1,LN,CN,Tokens,Status) :- !, get_char(LN,CN,C1,NextLN,NextCN), |