[Flora-commits] flora2 flora2.P,1.15,1.16 flrcoder.H,1.14,1.15 flrcoder.P,1.43,1.44 flrcompiler.H,1.
Brought to you by:
kifer
|
From: Hui W. <hw...@us...> - 2005-10-17 05:25:46
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9411 Modified Files: flora2.P flrcoder.H flrcoder.P flrcompiler.H flrcompiler.P flrcomposer.P flrdependency.H flrdependency.P flrlexer.P flrlibman.P flroperator.P flrparser.H flrparser.P flrregistry.P flrundefined.H flrundefined.P flrutils.H flrutils.P Log Message: 1, Supports for URIs (http://www.daml.org/services/swsl-rules/1.0/#swsl-rules-basic-defs); 2, More specific error reporting in flrcoder; 3, Fix bugs in syntax error reporting about underscore. Index: flrparser.H =================================================================== RCS file: /cvsroot/flora/flora2/flrparser.H,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- flrparser.H 16 Apr 2005 07:38:45 -0000 1.6 +++ flrparser.H 17 Oct 2005 05:25:33 -0000 1.7 @@ -51,3 +51,5 @@ :- import flora_system_module/1 from flrlibman. :- export flora_parse/3. + +:- export fldirective_struct/3. Index: flrdependency.H =================================================================== RCS file: /cvsroot/flora/flora2/flrdependency.H,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- flrdependency.H 20 Aug 2004 16:44:28 -0000 1.10 +++ flrdependency.H 17 Oct 2005 05:25:33 -0000 1.11 @@ -9,7 +9,8 @@ :- import flora_set_counter/2, - flora_get_counter/2 + flora_get_counter/2, + flora_concat_atoms/2 from flrporting. :- import @@ -21,13 +22,18 @@ :- import is_prrule/3, + is_pratom/3, + is_prstring/3, is_prdirective/2, is_prignoredep/2, - flora_build_struct/6 + is_prprefixdef/3, + flora_build_struct/7 from flrcoder. :- import get_canonical_form/2 from flrcanon. +:- import flora_depchk_prefixdef/3 from flrregistry. + :- dynamic rule(_,_,_). :- dynamic target(_,_,_). :- dynamic tabled_head(_). Index: flrcoder.H =================================================================== RCS file: /cvsroot/flora/flora2/flrcoder.H,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- flrcoder.H 26 Jul 2005 00:33:32 -0000 1.14 +++ flrcoder.H 17 Oct 2005 05:25:33 -0000 1.15 @@ -51,6 +51,12 @@ %% Undefinedness support :- dynamic using_debug_prefix(_). +:- import + flora_coder_prefixdef/2, + flora_shell_prefixdef/3, + flora_depchk_prefixdef/3 + from flrregistry. + :- export flora_divide_program/3, flora_extern_code/2, @@ -70,6 +76,8 @@ is_prvariable/3, is_prtransactionalvariable/3, is_prstring/3, + is_pruri/3, + is_prurisq/3, is_prlist/4, is_prfdbstorage/3, is_skolem/5, @@ -80,6 +88,7 @@ is_prtransactionalatomlit/3, is_prtermlit/4, is_prtransactionaltermlit/4, + is_prprefixdef/3, is_prworkspace/3, is_florasyslib/5, is_prologterm/4, @@ -89,5 +98,5 @@ is_prreify/2, is_flogic/4, is_fllibdb/1, - flora_write_struct/2, - flora_build_struct/6. + flora_write_struct/3, + flora_build_struct/7. Index: flrcompiler.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcompiler.P,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- flrcompiler.P 16 Oct 2005 21:45:53 -0000 1.84 +++ flrcompiler.P 17 Oct 2005 05:25:33 -0000 1.85 @@ -78,6 +78,9 @@ is_flsemantics(FLSEMANTICS(A),A). is_flsetsemantics(FLSETSEMANTICS(A),A). is_flcmpopt(FLCMPOPT(OptList),OptList). + +is_flprefixdef(FLPREFIXDEF(PrefixName,PrefixStr),PrefixName,PrefixStr). + is_flignoredep(FLIGNOREDEP(PredList),PredList). %% These two are used for the build process only--want to get rid of them @@ -188,7 +191,9 @@ is_flstring(FLSTRING(String,_I),String). is_fltransactionalstring(FLTRANSACTIONALSTRING(String,_I),String). is_fltoken(FLTOKEN(Token,I),Token,I). -is_fltoken(FLTOKEN(Token,Num,I),Token,Num,I). +is_fltoken(FLTOKEN(Token,Num,I),Token,Num,I). +is_fluri(FLURI(Uri,_I),Uri). +is_flurisq(FLURISQ(Prefix,Localname),Prefix,Localname). is_flvar(FLVAR(Name,Index),Name,Index). is_fltransactionalvar(FLTRANSACTIONALVAR(Name,Index),Name,Index). @@ -268,6 +273,7 @@ import_struct(F,N,M,PRIMPORT(F,N,M)). cmpopt_struct(OptList,PRCMPOPT(OptList)). ignoredep_struct(SpecList,PRIGNOREDEP(SpecList)). +prefixdef_struct(PrefixName,PrefixStr,PRPREFIXDEF(PrefixName,PrefixStr)). is_prfact(PRFACT(Head),Head). @@ -357,6 +363,13 @@ strobj_struct(FLSTRING(String,I),PRSTRING(String,I)). transactionalstrobj_struct(FLTRANSACTIONALSTRING(String,I),PRSTRING(String,I)). + +uriobj_struct(FLURI(Uri,I),PRURI(Uri,I)). + +urisqobj_struct(FLURISQ(Prefix,Localname),PRURISQ(PrefixAtom,LocalnameStr)) :- + atomobj_struct(Prefix,PrefixAtom), + strobj_struct(Localname,LocalnameStr). + newoid_struct(Oid,Index,PRNEWOID(Oid,Index)). cut_struct(Index,PRCUT(Index)). @@ -1053,6 +1066,8 @@ is_varobj_struct(PRVARIABLE(_Name,_I)). is_varobj_struct(PRVARIABLE(_Name,Index),Index). is_strobj_struct(PRSTRING(_String,_I)). +is_uriobj_struct(PRURI(_Uri,_I)). +is_urisqobj_struct(PRURISQ(_Prefix,_Localname)). is_transactionalvar_struct(PRTRANSACTIONALVARIABLE(_Name,Index),Index). allvars(Term,Vars) :- @@ -1078,7 +1093,9 @@ allvars(Term,Vars,Vars) :- ( is_atomobj_struct(Term); is_numobj_struct(Term); - is_strobj_struct(Term) + is_strobj_struct(Term); + is_uriobj_struct(Term); + is_urisqobj_struct(Term) ), !. @@ -1131,6 +1148,8 @@ is_flnumber(ParserTerm,_Number); is_fltransactionalnumber(ParserTerm,_Number); is_flstring(ParserTerm,_String); + is_fluri(ParserTerm,_Uri); + is_flurisq(ParserTerm,_Prefix,_Localname); is_fltransactionalstring(ParserTerm,_String); is_fltoken(ParserTerm,_Token,_I); is_fltoken(ParserTerm,_Token,_Num,_I) @@ -1175,7 +1194,9 @@ ( is_pratom(CompilerTerm,_,_); is_prnumber(CompilerTerm,_,_); is_prtransactionalnumber(CompilerTerm,_,_); - is_prstring(CompilerTerm,_,_) + is_prstring(CompilerTerm,_,_); + is_pruri(CompilerTerm,_,_); + is_prurisq(CompilerTerm,_,_) ), !. @@ -1530,7 +1551,7 @@ /**************************************************************************** compile_directive(+DirectList,+DirctIdx,-CodeDiffList,-Status) - compile_direct(DirectTerm,+DirctIdx,-CodeList,Status) + compile_direct(+DirectTerm,+DirctIdx,-CodeList,-Status) ****************************************************************************/ compile_directive([],_,T-T,[]) :- !. @@ -1572,6 +1593,20 @@ CodeList = [], !. +compile_direct(DirectTerm,Idx,CodeList,Status) :- + is_flprefixdef(DirectTerm,PrefixName,PrefixStr), + compile_pathexplist([PrefixName,PrefixStr],[NameCode,StrCode],_,_,S), + ( S==[] -> + prefixdef_struct(NameCode,StrCode,Direct), + directive_struct(Direct,Code1), + fldirective_struct([DirectTerm],Idx,Term), + compile_query(Term,CodeList-[Code1],Status) + + ; Status=S, + CodeList=[] + ), + !. + %% :- compiler_options compile_direct(DirectTerm,Idx,[Code],[]) :- is_flcmpopt(DirectTerm,OptList), @@ -2304,6 +2339,12 @@ ; is_flstring(ParserTerm,_S) -> strobj_struct(ParserTerm,Object) + ; is_fluri(ParserTerm,_U) -> + uriobj_struct(ParserTerm,Object) + + ; is_flurisq(ParserTerm,_P,_L) -> + urisqobj_struct(ParserTerm,Object) + ; is_fltransactionalstring(ParserTerm,_S) -> transactionalstrobj_struct(ParserTerm,Object) ), @@ -3039,6 +3080,12 @@ ; is_fltransactionalvar(ParserTerm,Name,Index) -> compile_fltransactionalvar_without_trans(Name,Index,Object) + ; is_fluri(ParserTerm,_U) -> + uriobj_struct(ParserTerm,Object) + + ; is_flurisq(ParserTerm,_P,_L) -> + urisqobj_struct(ParserTerm,Object) + ; is_flstring(ParserTerm,_S) -> strobj_struct(ParserTerm,Object) @@ -3422,6 +3469,13 @@ ; is_flobjref(ParserTerm,ObjTerm,RefType,AttTerm), compile_wsflobjref(ObjTerm,RefType,AttTerm,WS,Object,OidCode,Code,Status) + + ; is_flurisq(ParserTerm,_P,_L) -> + urisqobj_struct(ParserTerm,UrisqCode), + workspaceobj_struct(UrisqCode,WS,Object,OidCode), + Code=NULL, + Status = [] + ). @@ -4211,6 +4265,12 @@ ; is_flobjref(ParserTerm,ObjTerm,RefType,AttTerm), compile_head_wsflobjref(ObjTerm,RefType,AttTerm,WS,Object,Code,Status) + + ; is_flurisq(ParserTerm,_P,_L) -> + urisqobj_struct(ParserTerm,UrisqCode), + workspaceobj_struct(UrisqCode,WS,Object,Code), + Status = [] + ). @@ -5056,5 +5116,10 @@ numobj_struct(A,ACode); is_flvar(A,AN,AI),varobj_struct(AN,AI,ACode)), (numobj_struct(P,PCode); is_flvar(P,PN,PI),varobj_struct(PN,PI,PCode)), florasyslib_struct(FLLIBSHDIRECT,4,[FL_INDEX,Mod,ACode,PCode],Code) + + ; is_flprefixdef(DirectTerm,PrefixName,PrefixStr) -> + compile_pathexplist([PrefixName,PrefixStr],[NamePR,StrPR],_,_,_Status), + florasyslib_struct(FLLIBPREFIXDEF,3,[Mod,NamePR,StrPR],Code) + ), !. Index: flrcoder.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcoder.P,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- flrcoder.P 26 Jul 2005 00:33:32 -0000 1.43 +++ flrcoder.P 17 Oct 2005 05:25:33 -0000 1.44 @@ -32,6 +32,7 @@ #include "flora_terms.flh" #include "flora_porting.flh" +#include "standard.h" #define THISMODULE thismodule #define USERMODULE usermodule @@ -61,6 +62,7 @@ is_primport(PRIMPORT(P,A,M),P,A,M). % prolog's :- import (for output only) is_prcmpopt(PRCMPOPT(OptList),OptList). % :- compiler_options/1 directive is_prignoredep(PRIGNOREDEP(PredList),PredList). [...1941 lines suppressed...] + ( HS == [] -> + flora_build_dynrulelist(T,DWS,Prefix,VarList,TCode,TCInd,Status), + append(HCode,TCode,Code), + append(HCInd,TCInd,CInd) + ; + Status = HS, + Code = [], + CInd = [] + ). /**************************************************************************** - flora_build_newpred(+F,+N,+Args,+DWS,+Prefix,?VarList,-Code,-IndexedCode) + flora_build_newpred(+F,+N,+Args,+DWS,+Prefix,?VarList,-Code,-IndexedCode,-Status) ****************************************************************************/ -flora_build_newpred(F,N,Args,DWS,Prefix,VarList,Code,CodeInd) :- - flora_build_wsliteral(USERMODULE,F,N,Args,DWS,DWS,Prefix,VarList,Code,CodeInd). +flora_build_newpred(F,N,Args,DWS,Prefix,VarList,Code,CodeInd,Status) :- + flora_build_wsliteral(USERMODULE,F,N,Args,DWS,DWS,Prefix,VarList,Code,CodeInd,Status). /**************************************************************************** flora_build_newoid(+Oid,+DWS,-Code) Index: flrundefined.P =================================================================== RCS file: /cvsroot/flora/flora2/flrundefined.P,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- flrundefined.P 20 Aug 2005 04:19:01 -0000 1.26 +++ flrundefined.P 17 Oct 2005 05:25:33 -0000 1.27 @@ -416,7 +416,8 @@ **********************************************************************/ generate_patches :- term_seen(Term), - flora_write_struct(Term,FLBODYPREFIX), + flora_write_struct(Term,FLBODYPREFIX,Status), + flora_coder_error(Status), put(0'.),nl, fail. Index: flrutils.P =================================================================== RCS file: /cvsroot/flora/flora2/flrutils.P,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- flrutils.P 15 Oct 2005 19:08:20 -0000 1.60 +++ flrutils.P 17 Oct 2005 05:25:33 -0000 1.61 @@ -2359,6 +2359,21 @@ ), flora_coder_error(L). +flora_coder_error([error(Indx,Msg)|L]) :- + !, + flora_nth_token(Indx,Tk), + flora_token_text(Tk,TextStr,BLN,BCN,_ELN,_ECN), + ( flora_current_compile_filename(FileName) -> + flora_error_line('[~w] [Coder] near line(~w)/char(~w) `~s''', + [FileName,BLN,BCN,TextStr]) + ; + flora_error_line('[Coder] near line(~w)/char(~w) `~s''', + [BLN,BCN,TextStr]) + ), + flora_error_indentline, + flora_stderr_string('~w~n',[Msg]), + flora_coder_error(L). + /***************************************************************************** flora_list2conjunct(+List,-Goal) @@ -2413,13 +2428,13 @@ String: A query string Vars: A list of the form [Name1=Var1, Name2=Var2,...]. Name is a name of a variable mentioned in String, for instance, - 'X' (note: must be quoted, since it is a name). + '?X' (note: must be quoted, since it is a name). Var is a variable where you want the bonding for the variable Name in String to be returned. For instance, - if String is 'p(X,Y).' - Vars can be ['X' = Xyz, 'Y' = Qpr] - Then Xyz will be bound to the value of X in p(X,Y) after - the execution and Qpr will be bound to the value of Y in p(X,Y). + if String is 'p(?X,?Y).' + Vars can be ['?X' = Xyz, '?Y' = Qpr] + Then Xyz will be bound to the value of ?X in p(?X,?Y) after + the execution and Qpr will be bound to the value of ?Y in p(?X,?Y). Status: indicates the status of compilation of the command in String. Exception: is a possible exception during the runtime execution of the command in String. Index: flrlibman.P =================================================================== RCS file: /cvsroot/flora/flora2/flrlibman.P,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- flrlibman.P 3 Apr 2005 06:38:09 -0000 1.15 +++ flrlibman.P 17 Oct 2005 05:25:33 -0000 1.16 @@ -176,6 +176,7 @@ flora_library_file(FLLIBMODOBJ,flrdynmod,syslib) :- !. flora_library_file(FLLIBSEMANTICS,flrsemantics,syslib) :- !. flora_library_file(FLLIBSETSEMANTICS,flrsemantics,syslib) :- !. +flora_library_file(FLLIBPREFIXDEF,flrprefixdef,syslib) :- !. flora_library_file(FLLIBDYNRULE,flrdynrule,syslib) :- !. flora_library_file(FLLIBNEWMODULE,flrdynrule,syslib) :- !. Index: flroperator.P =================================================================== RCS file: /cvsroot/flora/flora2/flroperator.P,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- flroperator.P 16 Oct 2005 21:45:53 -0000 1.24 +++ flroperator.P 17 Oct 2005 05:25:33 -0000 1.25 @@ -37,6 +37,7 @@ flora_op(1600,xfx,FL_BAR). flora_op(1600,fx,FL_INDEX). flora_op(1600,fx,FL_EXPORT). +flora_op(1600,fx,FL_PREFIXDEF). flora_op(1300,fx,FL_UPDATABLE). flora_op(1600,fx,FL_CMPOPT). flora_op(1600,fx,FL_IGNOREDEP). @@ -115,6 +116,7 @@ flora_op(800,yfx,FL_PLUS). flora_op(800,yfx,FL_MINUS). flora_op(800,yfx,FL_SYMOR). +flora_op(800,yfx,FL_URISQOP). flora_op(700,yfx,FL_STAR). flora_op(700,yfx,FL_SLASH). Index: flrundefined.H =================================================================== RCS file: /cvsroot/flora/flora2/flrundefined.H,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- flrundefined.H 26 Jul 2005 00:33:32 -0000 1.16 +++ flrundefined.H 17 Oct 2005 05:25:33 -0000 1.17 @@ -43,7 +43,10 @@ flora_concat_items/2 from flrporting. -:- import flora_abort/1 from flrutils. +:- import + flora_abort/1, + flora_coder_error/1 + from flrutils. :- import flora_disabled_undefinedness_check_registry/3 from flrregistry. @@ -61,7 +64,7 @@ is_prtransactionalatomlit/3, is_prtermlit/4, is_prtransactionaltermlit/4, - flora_write_struct/2 + flora_write_struct/3 from flrcoder. :- import Index: flrparser.P =================================================================== RCS file: /cvsroot/flora/flora2/flrparser.P,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- flrparser.P 16 Oct 2005 21:45:53 -0000 1.88 +++ flrparser.P 17 Oct 2005 05:25:33 -0000 1.89 @@ -135,7 +135,7 @@ '=>' | '=>>' | '*=>' | '*=>>' | '+>' | '*+>' | '->->' | '*->->' -PathExpression := atom | number | string | variable | specialOidToken +PathExpression := atom | number | string | uri | variable | specialOidToken PathExpression := Term | List | ReifiedFormula PathExpression := PathExpression PathExpressionConnective PathExpression PathExpression := BinaryRelationship @@ -501,7 +501,7 @@ get_index(OBJECT(_PrimitiveType,Index),Index) :- !. get_index(FLATOM(_Name,Index),Index) :- !. - +get_index(FLSTRING(_Str,Index),Index) :- !. get_index(FLVAR(_Name,Index),Index) :- !. @@ -526,6 +526,8 @@ is_birelop(FL_ISA) :- !. is_birelop(FL_SUB) :- !. +is_urisqop(FL_URISQOP) :- !. + is_objrefop(A) :- is_fdobjrefop(A), !. is_objrefop(A) :- is_mvdobjrefop(A), !. @@ -593,6 +595,8 @@ flexport_struct(DynamicModule,Term,Modules,Updtag,FLEXPORT(DynamicModule,Term,Modules,FLATOM(Updtag,_I))). flexport_struct_list(TermList,FLEXPORT_LIST(TermList)). +flprefixdef_struct(PrefixName,PrefixStr,FLPREFIXDEF(PrefixName,PrefixStr)). + fldynrule_struct(Head,Body,FLDYNRULE(Head,Body)). %%flargumentsdirect_struct(F,N,Args,FLARGUMENTS(F,N,Args)). @@ -620,6 +624,7 @@ flobject_struct(OBJECT(NUMBER(Num),I),FLNUMBER(Num,I)) :- !. flobject_struct(OBJECT(ASCII_STRING(Str),I),FLSTRING(Str,I)) :- !. flobject_struct(OBJECT(SPECIAL_TOKEN(Atom),I),FLTOKEN(Atom,I)) :- !. +flobject_struct(OBJECT(URI(Uri),I),FLURI(Uri,I)) :- !. fltransactionalobject_struct(OBJECT(TRANSACTIONAL_IDENTIFIER(Atom),I),FLTRANSACTIONALATOM(Atom,I)) :- !. fltransactionalobject_struct(OBJECT(TRANSACTIONAL_QUOTED_ATOM(Atom),I),FLTRANSACTIONALATOM(Atom,I)) :- !. @@ -638,6 +643,7 @@ is_flatom_struct(FLATOM(Atom,_I),Atom). is_flnumber_struct(FLNUMBER(_Num,_I)). is_flstring_struct(FLSTRING(_Str,_I)). +is_fluri_struct(FLURI(_Uri,_I)). flatom_struct(Atom,Index, FLATOM(Atom,Index)). @@ -682,6 +688,8 @@ flbirelate_struct(Subject,R,Object,FLBIRELATE(Subject,R,Object)). +flurisq_struct(PrefixName,LocalName,FLURISQ(PrefixName,LocalName)). + flobjref_struct(Object,M,Attribute,FLOBJREF(Object,M,Attribute)). %% Composes PARSED Funct with PARSED args to compose a parsed term @@ -937,6 +945,7 @@ ; flora_index_directive(CanoniTerm,CodeList,Status) ; flora_setsemantics_directive(CanoniTerm,CodeList,Status) ; flora_cmpopt_directive(CanoniTerm,CodeList,Status) + ; flora_prefixdef_directive(CanoniTerm,CodeList,Status) ; flora_ignoredep_directive(CanoniTerm,CodeList,Status) ), fldirective_struct(CodeList,If,Code), @@ -969,6 +978,7 @@ ; flora_exec_index_directive(CanoniTerm,CodeList,Status) ; flora_exec_setsemantics_directive(CanoniTerm,CodeList,Status) ; flora_exec_semantics_directive(CanoniTerm,CodeList,Status) + ; flora_prefixdef_directive(CanoniTerm,CodeList,Status) ), !. @@ -1791,13 +1801,69 @@ parsing_error(H,ERROR_CMPOPT,Status) ). +/**************************************************************************** + flora_prefixdef_directive(+CanoniTerm,-CodeList,-Status) + Compiling the prefix directive in the form of + :- prefix A="aaa",B="bbb",.... +****************************************************************************/ +flora_prefixdef_directive(CANOTERM(Funct,_N,FL_PARENTHESIS,[T],_If,_Ip),Code,Status) :- + get_name(Funct,FL_PREFIXDEF), + flora_comma_separated_list(T,TermList), + flora_prefixdef_parse_term_list(TermList,Code,Status), + !. + +%% error case. +flora_prefixdef_directive(CANOTERM(Funct,_N,FL_PARENTHESIS,_Args,If,_Ip),[],Status) :- + get_name(Funct,FL_PREFIXDEF), + !, + parsing_error(If,ERROR_PREFIX,Status). + +/**************************************************************************** + flora_prefixdef_parse_term_list(+TermList,-CodeList,-Status) +***************************************************************************/ +flora_prefixdef_parse_term_list([],[],[]) :- !. + +flora_prefixdef_parse_term_list([H|T],Code,Status) :- + flora_prefixdef_parse_term(H,HCode,HStatus), + ( HStatus == [] -> + flora_prefixdef_parse_term_list(T,TCode,Status), + append(HCode,TCode,Code) + ; + Status = HStatus + ). + +/**************************************************************************** + flora_prefixdef_parse_term(+CanoniTerm,-Code,-Status) + ****************************************************************************/ +flora_prefixdef_parse_term(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),[Code],Status) :- + get_name(Funct,FL_UNIVEQ), + N==2, + !, + Args=[PrefixHead,PrefixBody], + ( PrefixHead=OBJECT(IDENTIFIER(_Name),_Index_Head) -> % make sure that prefix name(the part before '=') is an atom + ( PrefixBody=OBJECT(ASCII_STRING(_Str),_Index_Body) -> % make sure that the part following '=' is a string + flora_pathexplist(Args,NULL,ArgsCode,Status), + ArgsCode=[NameCode,StrCode], + flprefixdef_struct(NameCode,StrCode,Code) + + ; get_index(PrefixBody,Index_Body), + parsing_error(Index_Body,ERROR_PREFIX_BODY,Status) + ) + + ; get_index(PrefixHead,Index_Head), + parsing_error(Index_Head,ERROR_PREFIX_HEAD,Status) + ). + +%% error case +flora_prefixdef_parse_term(CANOTERM(_Funct,_N,_FL_PARENTHESIS,_Args,If,_Ip),[],Status) :- + parsing_error(If,ERROR_PREFIX,Status). + /**************************************************************************** flora_ignoredep_directive(+CanoniTerm,-CodeList,-Status) Compiling the :- ignore_depchk directive ****************************************************************************/ -flora_ignoredep_directive(CANOTERM(Funct,1,FL_PARENTHESIS,[T],_If,_Ip), - [Code],Status) :- +flora_ignoredep_directive(CANOTERM(Funct,1,FL_PARENTHESIS,[T],_If,_Ip),[Code],Status) :- get_name(Funct,FL_IGNOREDEP), ( flora_comma_separated_list(T,PreList) -> flora_parse_body_template_list(PreList,LCode,Status), @@ -2253,7 +2319,7 @@ Note: Textual information is reserved for module names. ****************************************************************************/ -%% Handle Flora user module specification. (@ M) +%% Handle Flora user module specification. (@ ?M) flora_workspace(CanoniTerm,FLORAUSERMOD(NVCode),[]) :- flora_name_or_normvar(CanoniTerm,NVCode), !. @@ -3622,13 +3688,33 @@ ( Status == [] -> ( is_birelop(F) -> flbirelate_struct(LCode,F,RCode,Code) - ; + ; flobjref_struct(LCode,F,RCode,Code) ) ; true ). +% To handle URI SQname structure like W3C#"function" +flora_pathexp(CANOTERM(Funct,2,FL_PARENTHESIS,Args,_If,_Ip),_HF,DWS,Code,Status) :- + get_atom(Funct,F), + is_urisqop(F), + !, + Args=[Prefix,Localname], + ( Prefix=OBJECT(IDENTIFIER(_Prefix),_Index_Prefix) -> % prefix (the part before '#') should be an atom + ( Localname=OBJECT(ASCII_STRING(_Localname),_Index_Localname) -> % localname (the part following '#') should be a string + flora_pathexplist(Args,DWS,ArgsCode,Status), + ArgsCode=[PrefixCode,LocalnameCode], + flurisq_struct(PrefixCode,LocalnameCode,Code) + + ; get_index(Localname,Index_Localname), + parsing_error(Index_Localname,ERROR_SQNAME_LOCAL,Status) + ) + + ; get_index(Prefix,Index_Prefix), + parsing_error(Index_Prefix,ERROR_SQNAME_PREFIX,Status) + ). + %% This procedure is to handle module specification @prolog() and @prologall() %% in the argument position. %% Note that @module (for FLORA modules) is deprecated in the argument position. @@ -3730,6 +3816,7 @@ nowspathexp(S) :- is_flreify_struct(S), !. nowspathexp(S) :- is_flnumber_struct(S), !. nowspathexp(S) :- is_flstring_struct(S), !. +nowspathexp(S) :- is_fluri_struct(S), !. nowspathexp(S) :- is_flatom_struct(S,FAtom), @@ -4127,8 +4214,24 @@ ; F == FL_AT -> %% Module specs for F-logic molecules in the head are not allowed. parsing_error(If,NO_WSINRULEHEAD,Status) - ; - flora_head_term(Funct,2,Args,HF,DWS,Code,Status) + + ; is_urisqop(F) -> + Args=[Prefix,Localname], + ( Prefix=OBJECT(IDENTIFIER(_Prefix),_Index_Prefix) -> % make sure that prefix (the part before '#') is an atom + ( Localname=OBJECT(ASCII_STRING(_Localname),_Index_Localname) -> % make sure that localname (the part following '#') is a string + flora_head_pathexplist(Args,DWS,ArgsCode,Status), + ArgsCode=[PrefixCode,LocalnameCode], + flurisq_struct(PrefixCode,LocalnameCode,Code) + + ; get_index(Localname,Index_Localname), + parsing_error(Index_Localname,ERROR_SQNAME_LOCAL,Status) + ) + + ; get_index(Prefix,Index_Prefix), + parsing_error(Index_Prefix,ERROR_SQNAME_PREFIX,Status) + ) + + ; flora_head_term(Funct,2,Args,HF,DWS,Code,Status) ). flora_head_pathexp(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),HF,DWS,Code,Status) :- @@ -4733,6 +4836,26 @@ (Status == [] -> flobjref_struct(LCode,F,RCode,Code); true) ). +% To handle URI SQname structure like W3C#"function" +flora_db_pathexp(Mode,CANOTERM(Funct,2,FL_PARENTHESIS,Args,_If,_Ip),_HF,DWS,Code,Status) :- + get_atom(Funct,F), + is_urisqop(F), + !, + Args=[Prefix,Localname], + ( Prefix=OBJECT(IDENTIFIER(_Prefix),_Index_Prefix) -> % prefix (the part before '#') should be an identifier + ( Localname=OBJECT(ASCII_STRING(_Localname),_Index_Localname) -> % localname (the part following '#') should be a string + flora_db_pathexplist(Mode,Args,DWS,ArgsCode,Status), + ArgsCode=[PrefixCode,LocalnameCode], + flurisq_struct(PrefixCode,LocalnameCode,Code) + + ; get_index(Localname,Index_Localname), + parsing_error(Index_Localname,ERROR_SQNAME_LOCAL,Status) + ) + + ; get_index(Prefix,Index_Prefix), + parsing_error(Index_Prefix,ERROR_SQNAME_PREFIX,Status) + ). + flora_db_pathexp(Mode,CANOTERM(Funct,2,FL_PARENTHESIS,[L,R],If,_Ip),HF,_DWS,Code,Status) :- get_atom(Funct,FL_AT), !, Index: flora2.P =================================================================== RCS file: /cvsroot/flora/flora2/flora2.P,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- flora2.P 30 Aug 2005 04:58:46 -0000 1.15 +++ flora2.P 17 Oct 2005 05:25:32 -0000 1.16 @@ -306,13 +306,13 @@ String: A query string Vars: A list of the form [Name1=Var1, Name2=Var2,...]. Name is a name of a variable mentioned in String, for instance, - 'X' (note: must be quoted, since it is an atom). + '?X' (note: must be quoted, since it is an atom). Var is a variable where you want the binding for the variable Name in String to be returned. For instance, - if String is 'p(X,Y).' - Vars can be ['X' = Xyz, 'Y' = Qpr] - Then Xyz will be bound to the value of X in p(X,Y) after - the execution and Qpr will be bound to the value of Y in p(X,Y). + if String is 'p(?X,?Y).' + Vars can be ['?X' = Xyz, '?Y' = Qpr] + Then Xyz will be bound to the value of ?X in p(?X,?Y) after + the execution and Qpr will be bound to the value of ?Y in p(?X,?Y). Status: indicates the status of compilation of the command in String. Exception: is a possible exception during the runtime execution of the command in String. Index: flrutils.H =================================================================== RCS file: /cvsroot/flora/flora2/flrutils.H,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- flrutils.H 15 Oct 2005 19:08:20 -0000 1.32 +++ flrutils.H 17 Oct 2005 05:25:33 -0000 1.33 @@ -250,4 +250,6 @@ flora_compile_add/2, flora_compile_add/1, - flora_patch_full_filename/1. + flora_patch_full_filename/1, + + flora_coder_error/1. Index: flrlexer.P =================================================================== RCS file: /cvsroot/flora/flora2/flrlexer.P,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- flrlexer.P 13 Oct 2005 02:07:54 -0000 1.16 +++ flrlexer.P 17 Oct 2005 05:25:33 -0000 1.17 @@ -175,6 +175,7 @@ flora_transactional_number_struct(+Num,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_quoted_atom_struct(+AtomStr,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_transactional_quoted_atom_struct(+AtomStr,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) + flora_uri_struct(+UriStr,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_ascii_string_struct(+ASCII,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_transactional_ascii_string_struct(+ASCII,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_symbol_token_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) @@ -217,6 +218,9 @@ text_info(LN1,CN1,LN2,CN2,TextStr,Text), atom_codes(A,AtomStr). +flora_uri_struct(UriStr,TextStr,LN1,CN1,LN2,CN2,URI(UriStr,Text)) :- + text_info(LN1,CN1,LN2,CN2,TextStr,Text). + flora_ascii_string_struct(ASCII,TextStr,LN1,CN1,LN2,CN2,ASCII_STRING(ASCII,Text)) :- text_info(LN1,CN1,LN2,CN2,TextStr,Text). @@ -433,18 +437,15 @@ ; (Char >= CH_a, Char =< CH_z;Char >= CH_A, Char =< CH_Z) -> read_identifier(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) - ; Char == CH_UNDERSCORE -> - read_anonyoid(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) - ; Char == CH_QUESTION -> get_char(NextLN,NextCN,NChar,NNLN,NNCN),% get the next character to see if there is a '?-' ( NChar \== CH_MINUS -> ( (NChar >= CH_a, NChar =< CH_z;NChar >= CH_A, NChar =< CH_Z) -> - % the case '?alphabet' is a variable + % the case '?alphanum' is a variable read_variable(NChar,NextLN,NextCN,NNLN,NNCN,TokenList,Status) ; NChar == CH_UNDERSCORE -> - % the case '?_[alphabet]' is an anonymous variable + % the case '?_[alphanum]' is an anonymous variable read_underscore_variable(NChar,NextLN,NextCN,NNLN,NNCN,TokenList,Status) ; % the case '?' itself is an anonymous variable @@ -456,7 +457,7 @@ ) ; peek_char(NextNextChar), - ( NextNextChar == '>' -> + ( NextNextChar == FL_GT -> % the case 'x[?->y]'. ? is an anonymous variable % since the cursor cannot be set backward, we construct a token here to avoid losing it. flora_variable_struct([CH_UNDERSCORE],LineNo,CharNo,LineNo,CharNo,Tk), @@ -475,6 +476,9 @@ ) + ; Char == CH_UNDERSCORE -> + read_underscore(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + ; Char >= CH_0, Char =< CH_9 -> read_number(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) @@ -495,8 +499,7 @@ Status=[FLORA_NOT_EOF,error(UNEXP_DEL_ISO)], set_charpos(NextLN,NextCN) - ; - read_special(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + ; read_special(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) ). /**************************************************************************** @@ -705,6 +708,29 @@ NNCN = NextCN ). + +/**************************************************************************** +read_underscore(+Char,+LineNo,+CharNo,+NextLN,+NextCN,-TokenList,-Status) + This function handles full uris, e.g._"uri", and two special tokens: + _#, _#<number> -- which generates new oids in rule head. Its use + in places other than rule head generates an error. + _@ -- which is replaced by the preprocessor constant + FLORA_THIS_MODULE_NAME. +****************************************************************************/ +read_underscore(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) :- + peek_char(NextChar), + ( NextChar == FL_DOUBLEQUOTE -> + read_uri(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + + ; ( NextChar == FL_HASH; NextChar == FL_AT) -> + read_anonyoid(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + + ; Status = [FLORA_NOT_EOF,error(AFTER_UNDERSCORE)], + flora_special_token_struct([Char],LineNo,CharNo,LineNo,CharNo,Tk), + TokenList = [Tk] + ). + + /**************************************************************************** read_anonyoid(+Char,+LineNo,+CharNo,+NextLN,+NextCN,-TokenList,-Status) This function handles two special tokens: @@ -729,8 +755,9 @@ NNLN=LNN, NNCN=CNN, flora_special_token_struct([C1,Ch],LN1,CN1,LN,CN,Tk) - ) - ; Ch == CH_AT, % The special token _@ is read + ) + + ; Ch == CH_AT, % The special token _@ is read NLN=NextLN, NCN=NextCN, get_char(NLN,NCN,NCh,NNLN,NNCN), @@ -786,7 +813,7 @@ 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) + 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) @@ -808,6 +835,23 @@ !, read_tokens(NCh,NLN,NCN,NNLN,NNCN,Tokens,Status). + +/**************************************************************************** + read_uri(+C1,+LN1,+CN1,+LN,+CN,-TokenList,-Status) :- + handles a full uri such as _"http://www.w3c.org/examples". + C1 is _, and it is already known that the character next to C1 is ". +****************************************************************************/ +read_uri(C1,LN1,CN1,LN,CN,TokenList,Status) :- + get_char(LN,CN,Ch,NextLN,NextCN), + C1 == CH_UNDERSCORE, + Ch == CH_DOUBLEQUOTE, + get_char(NextLN,NextCN,NextCh,NNLN,NNCN), + read_string(NextCh,NextLN,NextCN,NNLN,NNCN,LN,CN,CH_DOUBLEQUOTE, + Chars,TxChs,LLN,LCN,Tokens,Status), + flora_uri_struct(Chars,[CH_DOUBLEQUOTE|TxChs],LN1,CN1,LLN,LCN,Tk), + TokenList = [Tk|Tokens]. + + /**************************************************************************** read_special(+Ch,+LineNo,+CharNo,+NextLN,+NextCN,-Tokens,-Status) handles tokens made of special symbols. Index: flrcomposer.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcomposer.P,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- flrcomposer.P 26 Jul 2005 00:33:32 -0000 1.8 +++ flrcomposer.P 17 Oct 2005 05:25:33 -0000 1.9 @@ -141,6 +141,7 @@ is_sole_operand(TRANSACTIONAL_VARIABLE(_,_)) :- !. is_sole_operand(TRANSACTIONAL_NUMBER(_,_)) :- !. is_sole_operand(TRANSACTIONAL_SYMBOL_TOKEN(_,_)) :- !. +is_sole_operand(URI(_,_)) :- !. is_sole_operand(IDENTIFIER(I,_)) :- \+ flora_opdef(_,_,I), !. is_sole_operand(QUOTED_ATOM(QA,_)) :- \+ flora_opdef(_,_,QA), !. @@ -154,6 +155,7 @@ is_sole_operator(SYMBOL_TOKEN(FL_SEMICOLON,_),FL_SEMICOLON) :- !. is_sole_operator(SYMBOL_TOKEN(FL_IMPLYOP,_),FL_IMPLYOP) :- !. is_sole_operator(SYMBOL_TOKEN(FL_QUERYOP,_),FL_QUERYOP) :- !. +is_sole_operator(SYMBOL_TOKEN(FL_URISQOP,_),FL_URISQOP) :- !. %%is_sole_operator(SYMBOL_TOKEN(FL_TRAN,_),FL_TRAN) :- !. Index: flrdependency.P =================================================================== RCS file: /cvsroot/flora/flora2/flrdependency.P,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- flrdependency.P 13 Apr 2005 17:09:49 -0000 1.22 +++ flrdependency.P 17 Oct 2005 05:25:33 -0000 1.23 @@ -454,7 +454,8 @@ generate_rules([]) :- !. generate_rules(CodeList) :- retractall(rule(_,_,_)), - parse_codelist(CodeList). + parse_codelist(CodeList), + retractall(flora_depchk_prefixdef(_,_,_)). /**************************************************************************** parse_codelist(+CodeList) @@ -473,46 +474,69 @@ ( is_prrule(Term,Head,Body) -> parse_rule(Head,Body) ; - is_prdirective(Term,Direct), is_prignoredep(Direct,PList) -> - assert_ignoredlist(PList) + is_prdirective(Term,Direct) -> + ( is_prignoredep(Direct,PList) -> + assert_ignoredlist(PList) + + ; is_prprefixdef(Direct,PrefixName,PrefixStr) -> + is_pratom(PrefixName,NameAtom,_Index), + is_prstring(PrefixStr,String,_Index2), + flora_concat_atoms(['flora_prefix_',NameAtom],NameCode), + (flora_depchk_prefixdef(DEFAULT_WORKSPACE,NameCode,_)->retract(flora_depchk_prefixdef(DEFAULT_WORKSPACE,NameCode,_));true), + assert(flora_depchk_prefixdef(DEFAULT_WORKSPACE,NameCode,String)) + + ; true + ) ; true ). assert_ignoredlist([]) :- !. assert_ignoredlist([H|L]) :- - flora_build_struct(H,DEFAULT_WORKSPACE,FLBODYPREFIX,_VarList,HC,_HCI), - ( var(HC) -> - true - ; - ( functor(HC,DB,3), dboperation(DB,3) -> - HC =.. [DB,WS,DBList,Cond], - canonical_list(DBList,CDBList), - get_canonical_form(Cond,FLCANON(_W,_A,_M,CallCond,_TF)), - NHC =.. [DB,WS,CDBList,CallCond] - ; - functor(HC,DB,2), dboperation(DB,2) -> - HC =.. [DB,WS,DBList], - canonical_list(DBList,CDBList), - NHC =.. [DB,WS,CDBList] - ; - functor(HC,DB,4), moduleloading(DB,4) -> - HC =.. [DB,LList|_Rest], - NHC =.. [DB,LList,_,_,_] - ; - NHC = HC - ), - get_canonical_form(NHC,FLCANON(Wrap,Args,Mod,_Callable,_TF)) - ), - assert(ignored(Wrap,Args,Mod)), - assert_ignoredlist(L). + flora_build_struct(H,DEFAULT_WORKSPACE,FLBODYPREFIX,_VarList,HC,_HCI,Status), + ( Status == [] -> + ( var(HC) -> + true + ; + ( functor(HC,DB,3), dboperation(DB,3) -> + HC =.. [DB,WS,DBList,Cond], + canonical_list(DBList,CDBList), + get_canonical_form(Cond,FLCANON(_W,_A,_M,CallCond,_TF)), + NHC =.. [DB,WS,CDBList,CallCond] + ; + functor(HC,DB,2), dboperation(DB,2) -> + HC =.. [DB,WS,DBList], + canonical_list(DBList,CDBList), + NHC =.. [DB,WS,CDBList] + ; + functor(HC,DB,4), moduleloading(DB,4) -> + HC =.. [DB,LList|_Rest], + NHC =.. [DB,LList,_,_,_] + ; + NHC = HC + ), + get_canonical_form(NHC,FLCANON(Wrap,Args,Mod,_Callable,_TF)) + ), + assert(ignored(Wrap,Args,Mod)), + assert_ignoredlist(L) + ; + true + ). parse_rule(Head,Body) :- - flora_build_struct(Head,DEFAULT_WORKSPACE,FLBODYPREFIX,VarList,HeadCode,HCI), - functor(HeadCode,F,N), - ( default_tabled(F,N) -> assert(tabled_head((HeadCode,HCI))); true), - flora_build_struct(Body,DEFAULT_WORKSPACE,FLBODYPREFIX,VarList,BodyCode,BCI), - assert_rule((HeadCode,HCI),BodyCode,BCI,anu(_,_,_)). + flora_build_struct(Head,DEFAULT_WORKSPACE,FLBODYPREFIX,VarList,HeadCode,HCI,Status_Head), + ( Status_Head == [] -> + functor(HeadCode,F,N), + ( default_tabled(F,N) -> assert(tabled_head((HeadCode,HCI))); true), + flora_build_struct(Body,DEFAULT_WORKSPACE,FLBODYPREFIX,VarList,BodyCode,BCI,Status_Body), + ( Status_Body == [] -> + assert_rule((HeadCode,HCI),BodyCode,BCI,anu(_,_,_)) + ; + true + ) + ; + true + ). assert_rule(_H,BodyCode,_BI,_) :- var(BodyCode), Index: flrcompiler.H =================================================================== RCS file: /cvsroot/flora/flora2/flrcompiler.H,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- flrcompiler.H 26 Jul 2005 00:33:32 -0000 1.16 +++ flrcompiler.H 17 Oct 2005 05:25:33 -0000 1.17 @@ -30,7 +30,7 @@ flora_set_counter/2, flora_get_counter/2, flora_concat_atoms/2, - flora_match_substring/3 + flora_match_substring/3 from flrporting. :- import @@ -70,13 +70,16 @@ is_prtransactionalvariable/3, is_pratom/3, is_prnumber/3, + is_pruri/3, + is_prurisq/3, is_prtransactionalnumber/3, is_prstring/3 from flrcoder. - :- import flora_error_line/2 from flrprint. +:- import fldirective_struct/3 from flrparser. + :- dynamic compile_with_var_module(_). :- dynamic dynrule_warnings(_). Index: flrregistry.P =================================================================== RCS file: /cvsroot/flora/flora2/flrregistry.P,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- flrregistry.P 15 Oct 2005 19:08:20 -0000 1.7 +++ flrregistry.P 17 Oct 2005 05:25:33 -0000 1.8 @@ -52,6 +52,12 @@ :- index(flora_storage_registry/1,trie). :- index(flora_module_registry/1,trie). +:- dynamic flora_coder_prefixdef/2. + +:- dynamic flora_shell_prefixdef/3. + +:- dynamic flora_depchk_prefixdef/3. + :- export flora_module_registry/1, flora_debug_module_registry/1, @@ -63,4 +69,7 @@ flora_configuration/2, flora_dbmodule_registry/5, flora_dbmodule_handle/4, - flora_dbmodule_inmemory/1. + flora_dbmodule_inmemory/1, + flora_coder_prefixdef/2, + flora_shell_prefixdef/3, + flora_depchk_prefixdef/3. |