-
Notifications
You must be signed in to change notification settings - Fork 94
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
add file!()
and line!()
macros
#168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job. Only the comment about using self.source.path()
needs to be addressed for now. Especially nice touch re-using the assembly impl for LitStr
and LitNumber
!
fn expand_line_macro(&mut self, ast: &mut ast::MacroCall) -> Result<BuiltInMacro, ParseError> { | ||
let (l, _) = self | ||
.source | ||
.position_to_utf16cu_line_char(ast.open.span.start.into_usize()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah, not that it matters (line count should be the same), but it would be nice with an utf8 version of this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How'd that work - I can't see any information about the actual encoding of the incoming source? This should probably use the unicode variant though, not utf16.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utf16cu
stands for UTF-16 code units, the position function does some work to re-encode each character to utf-16 in order to find the column. An equivalent version for UTF-8 would simply rely on the emitted chars instead.
Not a blocker though, since the line will be the same.
All blockers are resolved. 🚀 |
Hello!
From discussion on Discord - this adds the
file!()
andline!()
macros, which transform into string and number literals representing the current filename and line number (1-indexed). I tried to follow the pattern fromformat!()
, but it seems a bit awkward being unable to implement these in runestick, instead feature-gating it inrune-modules
.