#* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *# #* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *# #* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *# #* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *# #* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *# #* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *# #* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *# #* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *# #* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# #*****************************************************************************# #* "$Revision:: 129 $" *# #* "$HeadURL:: https://svn.ai.sri.com/projects/spark/trunk/spark/src/spar#$" *# #*****************************************************************************# import sys from com.sri.ai.spark.util import Bean from spark.internal.parse.basicvalues import set_methods def get_java_bean(): """for test bootstrapping""" return Bean() def inverse_eval_bean(x): return "RANDOM BEAN" def value_str_bean(x): return "RANDOM BEAN" set_methods(Bean, value_str=value_str_bean, inverse_eval=inverse_eval_bean)
SYM_generateIclTerm = Symbol("spark.io.oaa.generateIclTerm") SYM_applyfun = Symbol("applyfun") QUOTED_GENERATEICLTERM = BACKQUOTE_SYMBOL.structure(SYM_generateIclTerm) SYM_oaavar = Symbol("spark.io.oaa.oaavar") QUOTED_OAAVAR = BACKQUOTE_SYMBOL.structure(SYM_oaavar) def icl_inverse_eval(icl): string = icl_string(icl, None)[1] return SYM_applyfun.structure(QUOTED_GENERATEICLTERM, string) def icl_append_value_str(icl, buf): buf.append(",") return append_value_str(icl_inverse_eval(icl), buf) if imported: set_methods(IclTerm, append_value_str=icl_append_value_str, inverse_eval=icl_inverse_eval) ATOM_FUNCTOR = "@" NULLARY_FUNCTOR = "@@" REF_FUNCTOR = "#" SPECIAL_FUNCTORS = (ATOM_FUNCTOR, NULLARY_FUNCTOR, REF_FUNCTOR) # currentid = 0 # objectIdMap = WeakKeyDictionary() # idObjectMap = WeakValueDictionary() # def getId(object): # "Returns an id that can be used to retrieve the object" # id = objectIdMap.get(object, None) # if id is None: # id = currentid # currentid = currentid + 1
QUOTED_OAAVAR = BACKQUOTE_SYMBOL.structure(SYM_oaavar) def icl_inverse_eval(icl): string = icl_string(icl, None)[1] return SYM_applyfun.structure(QUOTED_GENERATEICLTERM, string) def icl_append_value_str(icl, buf): buf.append(",") return append_value_str(icl_inverse_eval(icl), buf) if imported: set_methods(IclTerm, append_value_str=icl_append_value_str, inverse_eval=icl_inverse_eval) ATOM_FUNCTOR = "@" NULLARY_FUNCTOR = "@@" REF_FUNCTOR = "#" SPECIAL_FUNCTORS = (ATOM_FUNCTOR, NULLARY_FUNCTOR, REF_FUNCTOR) # currentid = 0 # objectIdMap = WeakKeyDictionary() # idObjectMap = WeakValueDictionary() # def getId(object): # "Returns an id that can be used to retrieve the object" # id = objectIdMap.get(object, None) # if id is None: # id = currentid