コード例 #1
0
 def default(self, line):
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code.
     """
     result = yacc.parse(line)
     print "result is: ", result
     print lis.eval(result)
コード例 #2
0
ファイル: mini-lisp.py プロジェクト: jht585/PLFinal
def main():
    with open('testfile.c', 'r') as content_file:
        content = content_file.read()
        AST = yacc.parse(content)
        print AST
        if AST != None:
            lis.eval(AST)
コード例 #3
0
ファイル: mini-lisp.py プロジェクト: erinbleiweiss/PLProject6
 def default(self, line):
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code.
     """
     result = yacc.parse(line)
     print "result is: ", result
     print lis.eval(result)
コード例 #4
0
ファイル: bak.HMM.py プロジェクト: agent509/PLFinalProject
def p_expression(p):
    '''expression : primary 
                  | function
                  | vardeclarations
                  | letdeclarations'''
    p[0] = p[1]
    print p[0]
    print lis.eval(p[0])
コード例 #5
0
ファイル: mini-lisp.py プロジェクト: amyhre16/PLProject6
 def default(self, line):       
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code.
     """
     result = yacc.parse(line)  # parsing the line and evaluating the line; this yacc refers to the yacc that's in ply folder
     # result is the ast
     print "result is: ", result
     import lis
     print lis.eval(result)
     '''
コード例 #6
0
def callJSON(func):
	global r20functions
	if func.get('type')=='lisp':
		if lis:
			lis.eval(lis.parse(str(func['content'])))
		else:
			sendMsgToR20('Cannot execute lisp function, lisp functions rely on lispy2 by Peter Norvig, available here:  http://norvig.com/lispy2.html')
	else:
		r20functions=reload(r20functions)
		r20functions.getFunc(func['name'])(func)
コード例 #7
0
def callJSON(func):
    global r20functions
    if func.get('type') == 'lisp':
        if lis:
            lis.eval(lis.parse(str(func['content'])))
        else:
            sendMsgToR20(
                'Cannot execute lisp function, lisp functions rely on lispy2 by Peter Norvig, available here:  http://norvig.com/lispy2.html'
            )
    else:
        r20functions = reload(r20functions)
        r20functions.getFunc(func['name'])(func)
コード例 #8
0
ファイル: mini-lisp.py プロジェクト: ltierrablanca/PLProject6
    def default(self, line):
        """Called on an input line when the command prefix is not recognized.
           In that case we execute the line as Python code.
        """
        print "\nParsing input with YACC:"
        result = yacc.parse(line)
        # This result is the Abstract Syntax Tree.
        print "The result is: ", result

        # Imports lis.py methods in the same folder, then passes the result for evaluation.
        import lis
        print ("\nEvaluating result with Lis.py:")
        print lis.eval(result)
コード例 #9
0
ファイル: mini-lisp.py プロジェクト: slimyangy/PLProject6
 def default(self, line):       
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code.
     """
     # from class
     '''
     result = yacc.parse(line)
     s = lisp_str(result)
     if s != 'nil':
         print s
     '''
     result = yacc.parse(line)
     print "result is: ", result
     import lis
     print lis.eval(result)
コード例 #10
0
ファイル: mini-lisp.py プロジェクト: Sulstice/PLFinal
 def default(self, line):       
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code."""
     ast = yacc.parse(line)
     print ('AST:', ast)
     import lis
     print ('RESULT:', lis.eval(ast))
    def default(self, line):
        """Called on an input line when the command prefix is not recognized.
           In that case we execute the line as Python code.
        """
        result = yacc.parse(line)

        import lis
        r = lis.eval(result)
        if r is not None: print r
コード例 #12
0
 def default(self, line):       
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code.
     """
     result = yacc.parse(line)
     print "AST is".format(result)
     r = lis.eval(result)
     if r is not None:
         print r
コード例 #13
0
ファイル: mini-lisp.py プロジェクト: jht585/PLProject6
 def default(self, line):
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code.
     """
     AST = yacc.parse(line)
     s = lisp_str(AST)
     if s != 'nil':
         print("Parsed input: " + s)
         print("into AST: " + str(AST))
         print("Trying to evaluate result...")
         result = lis.eval(AST)
         print(result)
コード例 #14
0
ファイル: mini-lisp.py プロジェクト: jht585/PLProject6
 def default(self, line):       
     """Called on an input line when the command prefix is not recognized.
        In that case we execute the line as Python code.
     """
     AST = yacc.parse(line)
     s = lisp_str(AST)
     if s != 'nil':
         print ("Parsed input: " + s)
         print ("into AST: " + str(AST))
         print ("Trying to evaluate result...")
         result = lis.eval(AST)
         print (result)
コード例 #15
0
ファイル: lisp_annotations.py プロジェクト: IzzyBrand/arc
def test(task_name, func_string, subset='train'):
    with open(f'ARC/data/training/{task_name}.json') as f:
        j = json.load(f)

    prog = parse(func_string)

    correct = True
    for i, t in enumerate(j[subset]):
        input_grid = np.array(t['input'])
        prog_with_input = ['define', 'grid', input_grid, prog]
        pred = eval(prog_with_input)
        #print(pred)
        # vis(pred)
        target = np.array(t['output'])
        correct &= match(pred, target)

    return correct
コード例 #16
0
ファイル: player.py プロジェクト: 0atman/THE-GRID
    def notes(self, world, *args):
        if not self.__dict__.get('note_store'):
            self.note_store = []
            self.save()
        if len(args) == 0:
            if self.note_store:
                for n, note in enumerate(self.note_store):
                    print("note #" + str(n) + "\n" + note.split('\n')[0])
            else:
                print("No notes.")

        elif len(args) > 0:
            if str(args[0]).lower() in ['new', 'create', 'write', 'add']:
                self.writenote()
                return
            if str(args[0]).lower() in ['delete', 'del', 'rm']:
                try:
                    del self.note_store[int(args[1])]
                    self.save()
                    print('Deleted.')
                except ValueError:
                    print("Bad note ID.")
                except IndexError:
                    print("Can't find that note ID")
                return
            if str(args[0]).lower() in ['run']:
                try:
                    for line in self.note_store[int(args[1])].split('\n'):
                        val = lis.eval(lis.parse(line))
                        if val:
                            print(lis.lispstr(val))
                    print()
                except IndexError:
                    print("Can't find that note ID")
                return
            if str(args[0]).lower() in ['drop']:
                try:
                    dropped_note = self.note_store[int(args[1])]
                    del self.note_store[int(args[1])]
                    self.save()
                    room_data = get_room(self.x, self.y)
                    if not room_data.get('data'):
                        room_data['data'] = []
                    room_data['data'].append(dropped_note)

                    put_room(self.x, self.y, room_data)
                except ValueError:
                    raise  # print("Bad note ID.")
                except IndexError:
                    raise  # print("Can't find that note ID")
                return
            elif type(args[0]) == int:
                try:
                    print(
                        "note #" +
                        str(args[0]) + " " +
                        self.note_store[int(args[0])]
                    )
                    return
                except ValueError:
                    print("Bad note ID.")
                    return
                except IndexError:
                    print("Can't find that note ID")
                    return
コード例 #17
0
ファイル: main.py プロジェクト: rokujyouhitoma/lis.py
def mainloop(statements):
    for statement in statements:
        if len(statement) != 0:
            tokens = parse(statement)
            print(eval(tokens))
コード例 #18
0
ファイル: HMM.py プロジェクト: agent509/PLFinalProject
def p_letdeclarations(p):
    '''letdeclarations : LET IDENTIFIER EQUALS expression'''

    a = lis.eval(p[4])
    p[0] = ['let'] + [p[2]] + [a]