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

Fix #172 #342

Merged
merged 2 commits into from
Aug 15, 2017
Merged

Fix #172 #342

merged 2 commits into from
Aug 15, 2017

Conversation

sparkprime
Copy link
Contributor

@@ -138,7 +138,8 @@ <h2 id="lexing">Lexing</h2>
first subsequent line that does not begin with <i>W</i>, and it is an error if this line does not
contain some optional whitespace followed by <code>|||</code>. The content of the string is the
concatenation of all the lines that began with <i>W</i> but with that prefix stripped. The line
ending style in the file is preserved in the string.</li>
ending style in the file is preserved in the string. This form cannot be used in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test for that would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

core/ast.h Outdated
/** Represents import "file". */
struct Import : public AST {
LiteralString *file;
Import(const LocationRange &lr, const Fodder &open_fodder, LiteralString *file)
// Must be a LiteralString.
Copy link
Collaborator

@sbarzowski sbarzowski Aug 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why not keep it *LiteralString?

(Also it doesn't compile on Travis and I think it's because of that).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the desugarer visitor allows editing the AST *&, so everything has to be an AST *.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True of CompilerPass too, actually.

Copy link
Collaborator

@sbarzowski sbarzowski Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, yes, but it can be handled while keeping Import::file a *LiteralString. Instead of:

desugar(ast->file, obj_level);

you could:

AST *file = ast->file;
desugar(file, obj_level);
ast->file = dynamic_cast<LiteralString *>(file);

And it may be better, because:
a) It's more explicit - it clearly states that it needs to be LiteralString, but in this case desugarer could potentially put something else there.
b) In general a little bit nicer data structures and a little more code within some functions is better than the other way around, imo.

@sbarzowski
Copy link
Collaborator

LGTM

@sparkprime sparkprime merged commit 9265a9c into google:master Aug 15, 2017
@sparkprime sparkprime deleted the fix_import_desugar branch August 15, 2017 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants