Esempio 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()
Esempio 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()
Esempio 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 = "."
    args = FakeArgs()

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

    backend = CBackend(args, walker, module_name, path)
    backend.generate_code()
Esempio 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 = "."
    args = FakeArgs()

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

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