Exemplo n.º 1
0
def _print_sym_list(agent, title, list):
    print title
    for sym in list:
        reqArgs = requiredargnames(agent, sym)
        if reqArgs is not None:
            args = ' '.join([("$" + str(x)) for x in reqArgs])
        else:
            args = ''
        restargs = restargnames(agent, sym)
        if restargs is not None:
            args = args + ' rest: ' + " ".join([str(x) for x in restargs])
        print " ", sym.name, args
Exemplo n.º 2
0
def _print_sym_list(agent, title, list):
    print title
    for sym in list:
        reqArgs = requiredargnames(agent, sym)
        if reqArgs is not None:
            args = " ".join([("$" + str(x)) for x in reqArgs])
        else:
            args = ""
        restargs = restargnames(agent, sym)
        if restargs is not None:
            args = args + " rest: " + " ".join([str(x) for x in restargs])
        print " ", sym.name, args
Exemplo n.º 3
0
def doc_symbol(mod, usage, f):
    """generates documentation for the specified symbol.  this is a
    subroutine of doc_module"""
    f.write('<div class="entry">')
    f.write('<dl>')
    modname = mod.get_modpath().name
    global all_symbols
    decls = [d for d in getPackageDecls(testagent, mod.filename)]
    decls.sort(decl_cmp)
    for decl in decls:
        sym = decl.asSymbol()

        if sym.modname == modname and decl.optMode(usage):
            all_symbols.append(sym)
            args = ' <span class="args">'
            required = requiredargnames(testagent, sym)
            if required:
                args = args + '$' + ' $'.join(required)
            restargs = restargnames(testagent, sym)
            if restargs:
                args = args + ' <em>rest: ' + ' '.join(restargs) + '</em>'
            args = args + "</span>"

            f.write('<dt><a name="' + anchorName(sym.id) + '"></a><b>' +
                    sym.id + '</b>' + args + '</dt>')

            f.write('<dd>')
            doc = get_fact(testagent, P_Doc, sym)
            if doc:
                f.write(doc + '<br />')

            features = get_fact(testagent, P_Features, sym)
            if features:
                f.write('<b>Features:</b> ' + htmlStr(features) + '<br />')

            properties = get_fact(testagent, P_Properties, sym)
            if properties:
                f.write('<b>Properties:</b> ' + htmlStr(properties) + '<br />')

            f.write('</dd>')

    f.write('</dl>')
    f.write('</div>')
Exemplo n.º 4
0
def doc_symbol(mod, usage, f):
    """generates documentation for the specified symbol.  this is a
    subroutine of doc_module"""
    f.write('<div class="entry">')
    f.write('<dl>')
    modname = mod.get_modpath().name
    global all_symbols
    decls = [d for d in getPackageDecls(testagent, mod.filename)]
    decls.sort(decl_cmp)
    for decl in decls:
        sym = decl.asSymbol()

        if sym.modname == modname and decl.optMode(usage):
            all_symbols.append(sym)
            args = ' <span class="args">'
            required = requiredargnames(testagent, sym)
            if required:
                args = args + '$' + ' $'.join(required)
            restargs = restargnames(testagent, sym)
            if restargs:
                args = args+' <em>rest: '+ ' '.join(restargs)+'</em>'
            args = args + "</span>"
            
            f.write('<dt><a name="'+anchorName(sym.id)+'"></a><b>'+sym.id+'</b>'+args+'</dt>')

            f.write('<dd>')
            doc = get_fact(testagent, P_Doc, sym)
            if doc:
                f.write(doc+'<br />')

            features = get_fact(testagent, P_Features, sym)
            if features:
                f.write('<b>Features:</b> '+htmlStr(features)+'<br />')

            properties = get_fact(testagent, P_Properties, sym)
            if properties:
                f.write('<b>Properties:</b> '+htmlStr(properties)+'<br />')

            f.write('</dd>')
                        
    f.write('</dl>')
    f.write('</div>')
Exemplo n.º 5
0
Arquivo: ppl.py Projeto: jbalint/spark
def ppl_translate_task(agent, task, map, output, taskid):
    debug("Start ppl_translate_task %s", task)
    if isinstance(task, DoTaskExpr):
        actexpr = task[0]  # was .actexpr
        # actsym = actexpr.actsym # doesn't work for cue as cue is not processed
        actsym = actexpr.term.key_term().sym_check_arity(ActSymInfo, actexpr)
        #print "ACTSYM", actsym
        if map.mapfirst(actsym.id, "taskname"):
            # first occurrence of this task name
            output.append(("superclasses", actsym.id, "Task"))
        if taskid is None:
            # We haven't been told to use a different id (e.g. procedurename)
            taskid = map.mapfind(task, "t")
            output.append(("instance-of", taskid, actsym.id))
        argnames = requiredargnames(actsym)  # doesn't handle rest args
        argtypefacts = agent.factslist1(P_ArgTypes, actsym)
        #print "argtypefacts", argtypefacts
        if argtypefacts:
            for argexpr, type in zip(actexpr, argtypefacts[0][1]):
                argid = ppl_term(agent, argexpr, map, output)
                output.append(("instance-of", argid, type.id))
        rolefacts = agent.factslist1(P_Roles, actsym)
        #print "rolefacts", rolefacts
        role_dict = {}
        if rolefacts:
            for role in rolefacts[0][1]:
                varsym = role[0]
                rolesym = role.functor
                role_dict[varsym] = rolesym
        for (argexpr, namesym, argnum) \
                in zip(actexpr, argnames, range(len(actexpr))):
            role = role_dict.get(namesym, None)
            if role is None:
                role = Symbol("arg%d" % argnum)
            argid = ppl_term(agent, argexpr, map, output)
            output.append((role.id, taskid, argid))
        return taskid
    else:
        pass  # TODO: work out what this should really be
Exemplo n.º 6
0
Arquivo: ppl.py Projeto: jbalint/spark
def ppl_translate_task(agent, task, map, output, taskid):
    debug("Start ppl_translate_task %s", task)
    if isinstance(task, DoTaskExpr):
        actexpr = task[0] # was .actexpr
        # actsym = actexpr.actsym # doesn't work for cue as cue is not processed
        actsym = actexpr.term.key_term().sym_check_arity(ActSymInfo, actexpr)
        #print "ACTSYM", actsym
        if map.mapfirst(actsym.id, "taskname"):
            # first occurrence of this task name
            output.append(("superclasses", actsym.id, "Task"))
        if taskid is None:
            # We haven't been told to use a different id (e.g. procedurename)
            taskid = map.mapfind(task, "t")
            output.append(("instance-of", taskid, actsym.id))
        argnames = requiredargnames(actsym) # doesn't handle rest args
        argtypefacts = agent.factslist1(P_ArgTypes, actsym)
        #print "argtypefacts", argtypefacts
        if argtypefacts:
            for argexpr, type in zip(actexpr, argtypefacts[0][1]):
                argid = ppl_term(agent, argexpr, map, output)
                output.append(("instance-of", argid, type.id))
        rolefacts = agent.factslist1(P_Roles, actsym)
        #print "rolefacts", rolefacts
        role_dict = {}
        if rolefacts:
            for role in rolefacts[0][1]:
                varsym = role[0]
                rolesym = role.functor
                role_dict[varsym] = rolesym
        for (argexpr, namesym, argnum) \
                in zip(actexpr, argnames, range(len(actexpr))):
            role = role_dict.get(namesym, None)
            if role is None:
                role = Symbol("arg%d"%argnum)
            argid = ppl_term(agent, argexpr, map, output)
            output.append((role.id, taskid, argid))
        return taskid
    else:
        pass # TODO: work out what this should really be