def main(args): if args["help"]: print __doc__.rstrip() return None if not args["run"]: if args["--verbose"]: COMMAND_DEFAULTS["mvn"] = "mvn" logging.basicConfig(level=logging.DEBUG) log = logging.getLogger("quark") log.propagate = False hnd = ProgressHandler(verbose=args["--verbose"]) log.addHandler(hnd) hnd.setFormatter(logging.Formatter("%(message)s")) helpers.Code.identifier = "Quark %s run at %s" % (_metadata.__version__, datetime.datetime.now()) java = args["--java"] ruby = args["--ruby"] python = args["--python"] javascript = args["--javascript"] all = args["--all"] or not (java or python or javascript or ruby) output = args["--output"] try: backends = [] if java or all: check("mvn", ".") backends.append(backend.Java) if ruby or all: backends.append(backend.Ruby) if python or all: check("python", ".") backends.append(backend.Python) if javascript or all: check("npm", ".") backends.append(backend.JavaScript) filenames = args["<file>"] for url in filenames: if args["install"]: compiler.install(url, *backends) elif args["compile"]: compiler.compile(url, output, *backends) elif args["run"]: compiler.run(url, args["<args>"], *backends) else: assert False except compiler.QuarkError as err: command_log.warn("") return err command_log.warn("Done")
sys.exit(-1) config = {} if sys.argv[1] == '-c': # cannot use ConfigParser due to colons in keys from compiler import config config = compiler.read_config(sys.argv[2]) else: config.output = sys.argv[1] config.modules = sys.argv[2:] config.resources = {} for n,arg in enumerate(sys.argv): if arg[:2] == '-r': config.modules = sys.argv[2:n] def parse_res(k): match = re.match(r'^(.+?)\=(.+?)$',k) if match is None: print('invalid format for resource entry: ' + k) sys.exit(-2) return match.groups() config.resources = dict(parse_res(k) for k in sys.argv[n+1:]); break config['modules'] = config['modules'] or [] assert config['output'] compiler.run('medea', config)
def run_file(path=None): if script_file63(path): return L_load(path) else: return compiler.run(system.read_file(path))
#!/bin/env python import sys import os # must come first or python's compiler module is picked # definitely must rename the medea compiler module sys.path.insert(0, os.path.join('..','..')) import compiler configs = [ 'null-debug' , 'collated-debug' , 'null-release' , 'collated-release' ] if __name__ == '__main__': for cfg in configs: file = 'compile-config-' + cfg + '.txt' cfg_data = compiler.read_config(file) print cfg_data compiler.run(os.path.join('..', '..', 'medea'), cfg_data)
def L_load(path=None): __previous = has(setenv("target", toplevel=True), "value") setenv("target", toplevel=True)["value"] = "py" __code = compile_file(path) setenv("target", toplevel=True)["value"] = __previous return compiler.run(__code)
import compiler compiler.run() # PROCEDURE ESCREVER(Z:INTEIRO) # TYPEDEF Z AS INTEIRO; # INPUT Z; # RETURN Z; # END # PROCEDURE LER(C:INTEIRO)22 # OUTPUT <- C; # END # MAIN # TYPEDEF X1 AS INTEIRO; # TYPEDEF Y AS REAL; # X1 <- LER; # Y <- LER; # Y <- Y + 2;
def main(args): if args["help"]: print __doc__.rstrip() return None do_log = not args["run"] or args["--verbose"] if do_log: if args["--verbose"]: shell.COMMAND_DEFAULTS["mvn"] = "mvn" logging.basicConfig(level=logging.DEBUG) log = logging.getLogger("quark") log.propagate = False hnd = ProgressHandler(verbose=args["--verbose"]) log.addHandler(hnd) hnd.setFormatter(logging.Formatter("%(message)s")) version = "Quark %s run at %s" % (_metadata.__version__, datetime.datetime.now()) helpers.Code.identifier = version java = args["--java"] ruby = args["--ruby"] python = args["--python"] python3 = args["--python3"] javascript = args["--javascript"] all = args["--all"] or not (java or python or javascript or ruby or python3) output = args["--output"] offline = not args["--online"] try: shell.command_log.info("Checking environment") backends = [] if java or all: if args["install"]: shell.check("mvn") backends.append(backend.Java) if ruby or all: if args["install"]: shell.check("gem") backends.append(backend.Ruby) if python or all: if args["install"]: shell.check("python2") shell.check("pip2") backends.append(backend.Python) if python3 or all: if args["install"]: shell.check("python3") shell.check("pip3") backends.append(backend.Python3) if javascript or all: if args["install"]: shell.check("npm") backends.append(backend.JavaScript) filenames = args["<file>"] or [ compiler.join(None, compiler.BUILTIN_FILE) ] for url in filenames: c = compiler.Compiler(args["--include-stdlib"]) c.version_warning = args["--version-warning"] if args["install"]: compiler.install(c, url, offline, *backends) elif args["compile"]: compiler.compile(c, url, output, *backends) elif args["run"]: compiler.run(c, url, args["<args>"], *backends) elif args["docs"]: compiler.make_docs(c, url, output, args["--include-private"]) else: assert False except (KeyboardInterrupt, QuarkError) as err: if not args["run"]: shell.command_log.error("") if args["install"] and offline and isinstance(err, shell.ShellError): err = str(err) + "\n\n" err += "Please retry the command with the --online switch\n\n" err += " quark install --online " for opt in "--verbose --java --javascript --ruby --python --python3".split( ): if args[opt]: err += opt + " " err += " ".join(shell.quote(f) for f in args["<file>"]) err += "\n" return err except: # pylint: disable=bare-except if do_log: import inspect ast_stack = helpers.format_ast_stack(inspect.trace()) shell.command_log.error( "\n -- snip --\nInternal compiler error, %s\n\n" % version, exc_info=True) if ast_stack: shell.command_log.error("\nCompiler was looking at:\n%s\n" % ast_stack) instructions = textwrap.dedent("""\ Your code triggered an internal compiler error. Please report the issue at https://github.com/datawire/quark/issues """) if do_log: instructions += textwrap.dedent("""\ Please attach the above report up until the -- snip -- line with the issue. If at all possible also attach the quark file that caused the error. """) else: instructions += textwrap.dedent("""\ Please re-run the quark command with --verbose flag to get the full report. """) return instructions shell.command_log.warn("Done")
def main(args): if args["help"]: print __doc__.rstrip() return None do_log = not args["run"] or args["--verbose"] if do_log: if args["--verbose"]: shell.COMMAND_DEFAULTS["mvn"] = "mvn" logging.basicConfig(level=logging.DEBUG) log = logging.getLogger("quark") log.propagate = False hnd = ProgressHandler(verbose=args["--verbose"]) log.addHandler(hnd) hnd.setFormatter(logging.Formatter("%(message)s")) version = "Quark %s run at %s" % (_metadata.__version__, datetime.datetime.now()) helpers.Code.identifier = version java = args["--java"] ruby = args["--ruby"] python = args["--python"] python3 = args["--python3"] javascript = args["--javascript"] all = args["--all"] or not (java or python or javascript or ruby or python3) output = args["--output"] offline = not args["--online"] try: shell.command_log.info("Checking environment") backends = [] if java or all: if args["install"]: shell.check("mvn") backends.append(backend.Java) if ruby or all: if args["install"]: shell.check("gem") backends.append(backend.Ruby) if python or all: if args["install"]: shell.check("python2") shell.check("pip2") backends.append(backend.Python) if python3 or all: if args["install"]: shell.check("python3") shell.check("pip3") backends.append(backend.Python3) if javascript or all: if args["install"]: shell.check("npm") backends.append(backend.JavaScript) filenames = args["<file>"] or [compiler.join(None, compiler.BUILTIN_FILE)] for url in filenames: c = compiler.Compiler(args["--include-stdlib"]) c.version_warning = args["--version-warning"] if args["install"]: compiler.install(c, url, offline, *backends) elif args["compile"]: compiler.compile(c, url, output, *backends) elif args["run"]: compiler.run(c, url, args["<args>"], *backends) elif args["docs"]: compiler.make_docs(c, url, output, args["--include-private"]) else: assert False except (KeyboardInterrupt, QuarkError) as err: if not args["run"]: shell.command_log.error("") if args["install"] and offline and isinstance(err, shell.ShellError): err = str(err) + "\n\n" err += "Please retry the command with the --online switch\n\n" err += " quark install --online " for opt in "--verbose --java --javascript --ruby --python --python3".split(): if args[opt]: err += opt + " " err += " ".join(shell.quote(f) for f in args["<file>"]) err += "\n" return err except: # pylint: disable=bare-except if do_log: import inspect ast_stack = helpers.format_ast_stack(inspect.trace()) shell.command_log.error("\n -- snip --\nInternal compiler error, %s\n\n" % version, exc_info=True) if ast_stack: shell.command_log.error("\nCompiler was looking at:\n%s\n" % ast_stack) instructions = textwrap.dedent("""\ Your code triggered an internal compiler error. Please report the issue at https://github.com/datawire/quark/issues """) if do_log: instructions += textwrap.dedent("""\ Please attach the above report up until the -- snip -- line with the issue. If at all possible also attach the quark file that caused the error. """) else: instructions += textwrap.dedent("""\ Please re-run the quark command with --verbose flag to get the full report. """) return instructions shell.command_log.warn("Done")
import compiler print("wait it worked till here now let us see") print("type exit to exit") print("type help to get help") while True: text = input('scripy% ') if text == 'exit': break elif text == 'help': print( "Welcome to Scripy! Right now you can do basic condition checks and assign variables along with do maths operations" ) print( "use VAR to declare a variable, IF THEN ELIF ELSE for conditions, AND ,OR ,NOT for use with conditions" ) else: result, error = compiler.run('<stdin>', text) if error: print(error.as_string()) else: print(result)
config = {} if sys.argv[1] == '-c': # cannot use ConfigParser due to colons in keys from compiler import config config = compiler.read_config(sys.argv[2]) else: config.output = sys.argv[1] config.modules = sys.argv[2:] config.resources = {} for n, arg in enumerate(sys.argv): if arg[:2] == '-r': config.modules = sys.argv[2:n] def parse_res(k): match = re.match(r'^(.+?)\=(.+?)$', k) if match is None: print('invalid format for resource entry: ' + k) sys.exit(-2) return match.groups() config.resources = dict( parse_res(k) for k in sys.argv[n + 1:]) break config['modules'] = config['modules'] or [] assert config['output'] compiler.run('medea', config)