Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in initialization of Parser #22

Open
shalakhansidmul opened this issue Oct 1, 2018 · 1 comment
Open

Error in initialization of Parser #22

shalakhansidmul opened this issue Oct 1, 2018 · 1 comment

Comments

@shalakhansidmul
Copy link

shalakhansidmul commented Oct 1, 2018

The method daast_from_str(filename, args=None) in parser.py initializes Parser with filename and optional args. The args are used as options in initialization of Resolver. Initializing Parser without the optional args throws the following error during initialization of Resolver:
options does not have attribute module_name.
To fix this, we have modified the method daast_from_str as follows:
We have created an option parameter and passed it as the argument to constructor of Parser.

    """Generates DistAlgo AST from source string.

    'src' is the DistAlgo source string to parse. Optional argument 'filename'
    specifies the filename that appears in error messages, defaults to
    '<str>'. Optional argument 'args' is a Namespace object containing the
    command line parameters for the compiler. Returns the generated DistAlgo
    AST.

    """
    try:
        options = Namespace()
        options.benchmark=False
        options.debug=None
        options.dump_ast=False
        options.geninc=False
        options.genpsd=False
        options.incfile=None,
        options.infile=filename
        options.interactive=False
        options.module_name='__main__'
        options.optimize=-1
        options.outfile=None
        options.psdfile=None
        options.write_bytecode=False

        # dt = Parser(filename, args)
        dt = Parser(filename, options)
        rawast = parse(src, filename)
        dt.visit(rawast)
        sys.stderr.write("%s compiled with %d errors and %d warnings.\n" %
                     (filename, dt.errcnt, dt.warncnt))
        if dt.errcnt == 0:
            return dt.program
    except SyntaxError as e:
        sys.stderr.write("%s:%d:%d: SyntaxError: %s" % (e.filename, e.lineno,
                                                    e.offset, e.text))
    return None`

@scottstoller
Copy link

if this is the correct fix, please incorporate it in the master branch (or tell us it is OK, and we will do that). if this is not the correct fix, please tell us what is. our program that prints a DistAlgo AST as a DistAlgo program relies on this fix. thanks! --scott

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants