dev
Bill 2 years ago
parent 5a163a6af9
commit 1732835692

@ -1,6 +1,7 @@
# put environment specific configuration here # put environment specific configuration here
## GLOBAL CONFIGURATION FLAGS ## GLOBAL CONFIGURATION FLAGS
version_string = '0.3.3a'
add_path_to_ldpath = True add_path_to_ldpath = True
rebuild_backend = True rebuild_backend = True
run_backend = True run_backend = True
@ -47,7 +48,6 @@ def init_config():
os_platform = 'cygwin' os_platform = 'cygwin'
# deal with msys dependencies: # deal with msys dependencies:
if os_platform == 'win': if os_platform == 'win':
add_dll_dir(cygroot) add_dll_dir(cygroot)
add_dll_dir(os.path.abspath('./msc-plugin')) add_dll_dir(os.path.abspath('./msc-plugin'))
# print("adding path") # print("adding path")

@ -1,10 +1,58 @@
import os import aquery_config
help_message = '''\
======================================================
AQUERY COMMANDLINE HELP
======================================================
Run prompt.py without supplying with any arguments to run in interactive mode.
--help, -h
print out this help message
--version, -v
returns current version of AQuery
--mode, -m Optional[threaded|IPC]
execution engine run mode:
threaded or 1 (default): run the execution engine and compiler/prompt in separate threads
IPC, standalong or 2: run the execution engine in a new process which uses shared memory to communicate with the compiler process
--script, -s [SCRIPT_FILE]
script mode: run the aquery script file
--parse-only, -p
parse only: parse the file and print out the AST
'''
from engine.ast import Context
if __name__ == '__main__': if __name__ == '__main__':
import mimetypes import mimetypes
mimetypes._winreg = None mimetypes._winreg = None
state = None
nextcmd = ''
def check_param(param, args = False) -> bool:
global nextcmd
import sys
for p in param:
if p in sys.argv:
if args:
return True
pos = sys.argv.index(p)
if len(sys.argv) > pos + 1:
nextcmd = sys.argv[pos + 1]
return True
return False
if check_param(['-v', '--version'], True):
print(aquery_config.version_string)
exit()
if check_param(['-h', '--help'], True):
print(help_message)
exit()
import os
from dataclasses import dataclass from dataclasses import dataclass
import enum import enum
from tabnanny import check from tabnanny import check
@ -25,30 +73,11 @@ from engine.utils import base62uuid
import atexit import atexit
import threading import threading
import ctypes import ctypes
import aquery_config
import numpy as np import numpy as np
from engine.utils import ws from engine.utils import ws
from engine.utils import add_dll_dir from engine.utils import add_dll_dir
## GLOBALS BEGIN
nullstream = open(os.devnull, 'w') nullstream = open(os.devnull, 'w')
help_message = '''\
Run prompt.py without supplying with any arguments to run in interactive mode.
--help, -h
print out this help message
--version, -v
returns current version of AQuery
--mode, -m Optional[threaded|IPC]
execution engine run mode:
threaded or 1 (default): run the execution engine and compiler/prompt in separate threads
IPC, standalong or 2: run the execution engine in a new process which uses shared memory to communicate with the compiler process
--script, -s [SCRIPT_FILE]
script mode: run the aquery script file
--parse-only, -p
parse only: parse the file and print out the AST
'''
## GLOBALS END
## CLASSES BEGIN ## CLASSES BEGIN
class RunType(enum.Enum): class RunType(enum.Enum):
@ -351,9 +380,19 @@ def main(running = lambda:True, next = input, state = None):
elif q == 'rr': # run elif q == 'rr': # run
state.set_ready() state.set_ready()
continue continue
elif q == 'script': elif q.startswith('script'):
# TODO: script mode qs = re.split(r'[ \t]', q)
pass if len(qs) > 1:
qs = qs[1]
with open(qs) as file:
qs = file.readline()
from engine.utils import _Counter
while(qs):
while(not ws.sub('', qs) or qs.strip().startswith('#')):
qs = file.readline()
cnt = _Counter(1)
main(lambda : cnt.inc(-1) > 0, lambda:qs.strip(), state)
qs = file.readline()
elif q.startswith('save2'): elif q.startswith('save2'):
filename = re.split(r'[ \t]', q) filename = re.split(r'[ \t]', q)
if (len(filename) > 1): if (len(filename) > 1):
@ -396,29 +435,13 @@ def main(running = lambda:True, next = input, state = None):
## MAIN ## MAIN
if __name__ == '__main__': if __name__ == '__main__':
state = None
nextcmd = ''
def check_param(param:List[str], args = False) -> bool:
global nextcmd
for p in param:
if p in sys.argv:
if args:
return True
pos = sys.argv.index(p)
if len(sys.argv) > pos + 1:
nextcmd = sys.argv[pos + 1]
return True
return False
if check_param(['-h', '--help'], True):
print(help_message)
exit()
if len(sys.argv) == 2: if len(sys.argv) == 2:
nextcmd = sys.argv[1] nextcmd = sys.argv[1]
if nextcmd.startswith('-'): if nextcmd.startswith('-'):
nextcmd = '' nextcmd = ''
nextcmd = 'test.aquery' #nextcmd = 'test.aquery'
if nextcmd or check_param(['-s', '--script']): if nextcmd or check_param(['-s', '--script']):
with open(nextcmd) as file: with open(nextcmd) as file:
nextcmd = file.readline() nextcmd = file.readline()
@ -444,7 +467,7 @@ if __name__ == '__main__':
if any([s in nextcmd for s in ipc_string]): if any([s in nextcmd for s in ipc_string]):
server_mode = RunType.IPC server_mode = RunType.IPC
elif any([s in nextcmd for s in thread_string]): elif any([s in nextcmd for s in thread_string]):
server_mode = RunType.Threaded server_mode = RunType.Threaded
main(state=state) main(state=state)

@ -25,7 +25,8 @@ def exec(stmts, cxt = None, keep = False):
generate(s, cxt) generate(s, cxt)
else: else:
generate(stmts_stmts, cxt) generate(stmts_stmts, cxt)
cxt.print(cxt.queries) for q in cxt.queries:
cxt.print(q.strip())
return cxt return cxt
__all__ = ["initialize", "generate", "exec", "saved_cxt"] __all__ = ["initialize", "generate", "exec", "saved_cxt"]

Loading…
Cancel
Save