Exemplo n.º 1
0
def go (args):
    with open (args.file) as f:
        asn1def = f.read()

    parse_tree = parser.parse_asn1(asn1def)
    modules = build_semantic_model(parse_tree)
    assert (len(modules) == 1)
    base, ext = os.path.splitext (args.file)
    parts = os.path.split (base)
    module_name = parts[-1]
    if args.outdir:
        path = args.outdir
    else:
        path = "."

    if args.lang == 'python':
        from tinyber.py_nodes import PythonBackend as Backend
        from tinyber import py_nodes as nodes
    elif args.lang == 'c':
        from tinyber.c_nodes import CBackend as Backend
        from tinyber import c_nodes as nodes

    # pull in the python-specific node implementations
    walker = Walker (modules[0], nodes)
    walker.walk()

    backend = Backend (args, walker, module_name, path)
    backend.generate_code()
Exemplo n.º 2
0
def go(args):
    with open(args.file) as f:
        asn1def = f.read()

    parse_tree = parser.parse_asn1(asn1def)
    modules = build_semantic_model(parse_tree)
    assert (len(modules) == 1)
    base, ext = os.path.splitext(args.file)
    parts = os.path.split(base)
    module_name = parts[-1]
    if args.outdir:
        path = args.outdir
    else:
        path = "."

    if args.lang == 'python':
        from tinyber.py_nodes import PythonBackend as Backend
        from tinyber import py_nodes as nodes
    elif args.lang == 'c':
        from tinyber.c_nodes import CBackend as Backend
        from tinyber import c_nodes as nodes

    # pull in the python-specific node implementations
    walker = Walker(modules[0], nodes)
    walker.walk()

    backend = Backend(args, walker, module_name, path)
    backend.generate_code()
Exemplo n.º 3
0
def generate(infilename, outfilename):
    class FakeArgs(object):
        no_standalone = False

    import os
    with open(infilename) as f:
        asn1def = f.read()

    parse_tree = parser.parse_asn1(asn1def)
    modules = build_semantic_model(parse_tree)
    assert (len(modules) == 1)

    module_name = outfilename
    path = "tests"
    args = FakeArgs()

    # pull in the python-specific node implementations
    walker = Walker(modules[0], nodes)
    walker.walk()

    backend = Backend(args, walker, module_name, path)
    backend.generate_code()
Exemplo n.º 4
0
def generate(infilename, outfilename):
    class FakeArgs(object):
        no_standalone = False

    import os
    with open(infilename) as f:
        asn1def = f.read()

    parse_tree = parser.parse_asn1(asn1def)
    modules = build_semantic_model(parse_tree)
    assert (len(modules) == 1)

    module_name = outfilename
    path = "tests"
    args = FakeArgs()

    # pull in the python-specific node implementations
    walker = Walker(modules[0], nodes)
    walker.walk()

    backend = Backend(args, walker, module_name, path)
    backend.generate_code()