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

Implements parsing for #pragma, handles the multiple case niavely #372

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

LemonInTheDark
Copy link
Contributor

I'm using a second hashmap to track multiple'd files. Not sure that this is the best way of going about it, but it's a living

I'm using a second hashmap to track multiple'd files. Not sure that this
is the best way of going about it, but it's a living
@@ -952,6 +967,18 @@ impl<'ctx> Preprocessor<'ctx> {
expect_token!((text) = Token::String(text));
self.context.register_error(DMError::new(self.last_input_loc, format!("#{} {}", ident, text)));
}
"pragma" if disabled => {}
"pragma" => {
expect_token!((text) = Token::String(text));
Copy link
Owner

Choose a reason for hiding this comment

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

You probably mean Ident here, not String

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it, but are you sure? #warn uses String() and its input isn't "'d at all, it's just the text after the #warn

Copy link
Owner

Choose a reason for hiding this comment

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

It's stupid, but there's a hack in lexer.rs for this: if ident == "warn" || ident == "error" {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in fucking tears

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I add to that or just keep as is

Copy link
Owner

Choose a reason for hiding this comment

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

As written is fine. The reason is that #warn and #error want to treat the whole rest of the line as one big string. #pragma is (for now...) followed by ordinary tokens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright. is there anything else you want me to do here?

crates/dreammaker/src/preprocessor.rs Outdated Show resolved Hide resolved
@SpaceManiac SpaceManiac merged commit a50249e into SpaceManiac:master Oct 17, 2023
@SpaceManiac SpaceManiac added this to the suite v1.8 milestone Nov 19, 2023
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

Successfully merging this pull request may close these issues.

2 participants