示例#1
0
def test_dispatcher_ast_path():
    d = State.get_dispatcher()
    node = d.parse("echo a b c")
    assert d.describe(node) == "command list"  # note: for CommandList node
示例#2
0
def d():
    return State.get_dispatcher()
示例#3
0
def test_osh_transformer_omits_sentence():
    d = State.get_dispatcher()
    tree = d.parse("echo a b c;")
    assert isinstance(tree.children[0], d.nodes.get('SimpleCommand'))
示例#4
0
from whitenoise import WhiteNoise

app = Flask(__name__)
app.config.from_object('config')

app.wsgi_app = WhiteNoise(app.wsgi_app,
                          root='app/static/',
                          prefix='/',
                          index_file=True)

# Helper funcs ----------------------------------------------------------------
from antlr_plsql import grammar as plsql_grammar, ast as plsql_ast
from antlr_tsql import grammar as tsql_grammar, ast as tsql_ast
from shellwhat.State import State

shell_ast = State.get_dispatcher().ast

import ast as python_ast
from .CytoListener import parse_from_grammar
from .ast_dump import dump_node

grammars = {'plsql': plsql_grammar, 'tsql': tsql_grammar}

ast_parsers = {
    'python': python_ast,
    'plsql': plsql_ast,
    'tsql': tsql_ast,
    'shell': shell_ast
}