Exemple #1
0
 def get_completions(self, info):
     self.log.debug("get_completitons: info = %s" % info)
     token = info["help_obj"]
     matches = []
     # from the language environment:
     slist = scheme.execute_string_rm("(dir)")
     if not scheme.exception_q(slist):
         for item in slist:
             item_str = str(item)
             if item_str.startswith(token) and item_str not in matches:
                 matches.append(item_str)
     # special forms and constants:
     for item in ["define", "define!", "func", "callback", "if",
                  "help", "define-syntax", "begin", "lambda", "trace-lambda",
                  "try", "catch", "finally", "raise", "choose"]:
         if item.startswith(token) and item not in matches:
             matches.append(item)
     # add items from scheme.ENVIRONMENT
     for item in scheme.ENVIRONMENT:
         if item.startswith(token) and item not in matches:
             matches.append(item)
     # add properties and attributes if token is "numpy.ar"
     if "." in token:
         components, partial = token.rsplit(".", 1)
         slist = scheme.execute_string_rm("(dir %s)" % components)
         if not scheme.exception_q(slist):
             for item in slist:
                 item_str = str(item)
                 if item_str.startswith(partial) and item_str not in matches:
                     matches.append(components + "." + item_str)
     # done with language-specific completitions
     return matches
Exemple #2
0
 def get_completions(self, info):
     self.log.debug("get_completitons: info = %s" % info)
     token = info["help_obj"]
     matches = []
     # from the language environment:
     slist = scheme.execute_string_rm("(dir)")
     if not scheme.exception_q(slist):
         for item in slist:
             item_str = str(item)
             if item_str.startswith(token) and item_str not in matches:
                 matches.append(item_str)
     # special forms and constants:
     for item in [
             "define", "define!", "func", "callback", "if", "help",
             "define-syntax", "begin", "lambda", "trace-lambda", "try",
             "catch", "finally", "raise", "choose"
     ]:
         if item.startswith(token) and item not in matches:
             matches.append(item)
     # add items from scheme.ENVIRONMENT
     for item in scheme.ENVIRONMENT:
         if item.startswith(token) and item not in matches:
             matches.append(item)
     # add properties and attributes if token is "numpy.ar"
     if "." in token:
         components, partial = token.rsplit(".", 1)
         slist = scheme.execute_string_rm("(dir %s)" % components)
         if not scheme.exception_q(slist):
             for item in slist:
                 item_str = str(item)
                 if item_str.startswith(
                         partial) and item_str not in matches:
                     matches.append(components + "." + item_str)
     # done with language-specific completitions
     return matches
Exemple #3
0
 def get_kernel_help_on(self, info, level=0, none_on_fail=False):
     expr = info["code"]
     result = scheme.execute_string_rm("(help %s)" % expr)
     if not scheme.exception_q(result):
         return result
     elif expr in ["define", "define!", "func", "callback", "if",
                  "help", "define-syntax", "begin", "lambda", "trace-lambda",
                  "try", "catch", "finally", "raise", "choose"]:
         help_text = {
             "define": "(define NAME [DOCSTRING] VALUE) define a global variable (special form)", 
             "define!": "(define! NAME [DOCSTRING] VALUE) define a variable in the host system (special form)", 
             "func": "(func PROCEDURE) for wrapping Scheme procedures as a system function (special form)", 
             "callback": "(callback PROCEDURE) returns a host system function for system callbacks (special form)", 
             "if": "(if TEXT-EXPR TRUE-EXPR FALSE-EXPR) (special form)",
             "help": "(help ITEM) (special form)", 
             "define-syntax": "(define-syntax NAME NAME-TEST ...) (special form)", 
             "begin": "(begin EXPR...) (special form)", 
             "lambda": "(lambda (VAR...) EXPR...) or (lambda VAR EXPR...) (special form)", 
             "trace-lambda": "(trace-lambda NAME (VAR...) EXPR...) or (trace-lambda NAME VAR EXPR...) (special form)",
             "try": "(try EXPR (catch EXCEPTION NAME ...)...) (special form)", 
             "catch": "(try EXPR (catch EXCEPTION NAME ...) ...) (special form)", 
             "finally": "(try EXPR (catch EXCEPTION NAME ...)... (finally ...)) (special form)", 
             "raise": "(raise EXCEPTION) (special form)", 
             "choose": "Use (choose ITEM...) to setup non-deterministic interpreter, or use (choose) to go to next choice (special form)"
         }
         return help_text[expr]
     elif none_on_fail:
         return None
     else:
         return "No available help on '%s'" % expr
Exemple #4
0
 def get_kernel_help_on(self, info, level=0, none_on_fail=False):
     expr = info["code"]
     result = scheme.execute_string_rm("(help %s)" % expr)
     if not scheme.exception_q(result):
         return result
     elif expr in ["define", "define!", "func", "callback", "if",
                  "help", "define-syntax", "begin", "lambda", "trace-lambda",
                  "try", "catch", "finally", "raise", "choose"]:
         help_text = {
             "define": "(define NAME [DOCSTRING] VALUE) define a global variable (special form)",
             "define!": "(define! NAME [DOCSTRING] VALUE) define a variable in the host system (special form)",
             "func": "(func PROCEDURE) for wrapping Scheme procedures as a system function (special form)",
             "callback": "(callback PROCEDURE) returns a host system function for system callbacks (special form)",
             "if": "(if TEXT-EXPR TRUE-EXPR FALSE-EXPR) (special form)",
             "help": "(help ITEM) (special form)",
             "define-syntax": "(define-syntax NAME NAME-TEST ...) (special form)",
             "begin": "(begin EXPR...) (special form)",
             "lambda": "(lambda (VAR...) EXPR...) or (lambda VAR EXPR...) (special form)",
             "trace-lambda": "(trace-lambda NAME (VAR...) EXPR...) or (trace-lambda NAME VAR EXPR...) (special form)",
             "try": "(try EXPR (catch EXCEPTION NAME ...)...) (special form)",
             "catch": "(try EXPR (catch EXCEPTION NAME ...) ...) (special form)",
             "finally": "(try EXPR (catch EXCEPTION NAME ...)... (finally ...)) (special form)",
             "raise": "(raise EXCEPTION) (special form)",
             "choose": "Use (choose ITEM...) to setup non-deterministic interpreter, or use (choose) to go to next choice (special form)"
         }
         return help_text[expr]
     elif none_on_fail:
         return None
     else:
         return "No available help on '%s'" % expr
Exemple #5
0
 def initialize_debug(self, code):
     self.original_debug_code = code
     self.running = True
     scheme._startracing_on_q_star = True
     scheme.GLOBALS["TRACE_GUI"] = True
     scheme.GLOBALS["TRACE_GUI_COUNT"] = 0
     try:
         retval = scheme.execute_string_rm(code)
     except scheme.DebugException as e:
         retval = "highlight: [%s, %s, %s, %s]" % (e.data[0], e.data[1], e.data[2], e.data[3])
     except:
         return "Unhandled Error: " + code
     return retval
Exemple #6
0
 def initialize_debug(self, code):
     self.original_debug_code = code
     self.running = True
     scheme._startracing_on_q_star = True
     scheme.GLOBALS["TRACE_GUI"] = True
     scheme.GLOBALS["TRACE_GUI_COUNT"] = 0
     try:
         retval = scheme.execute_string_rm(code)
     except scheme.DebugException as e:
         retval = "highlight: [%s, %s, %s, %s]" % (e.data[0], e.data[1], e.data[2], e.data[3])
     except:
         return "Unhandled Error: " + code
     return retval
 def eval(self, code):
     if scheme:
         return scheme.execute_string_rm(code.strip())
     else:
         raise Exception("calysto_scheme is required")
Exemple #8
0
 def eval(self, code):
     if scheme:
         return scheme.execute_string_rm(code.strip())
     else:
         raise Exception("calysto_scheme is required")