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
Parsing in macros should provide proper positions #6489
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6489?orig=1 |
@xeno-by said: |
@jrudolph said: |
@retronym said: In the macro context, |
@densh said (edited on Aug 29, 2013 12:51:09 PM UTC): |
@densh said: As far as I understood your last paragraph you'd like a tree generated by: c.parse("foo bar") to have positions within the current file where c.parse was called instead of fake temporary one generated just for parsing? |
@jrudolph said (edited by @xeno-by on Sep 6, 2013 12:35:39 PM UTC): The other idea was, that you are usually not parsing static stuff but stuff coming into the macro as literal string trees. These literal strings will have position from their original file, obviously. However, you would usually don't parse the complete literal string but only a part of it. In this case I would like the parsed tree's positions to point to the right segment in the original file. We would need a parse method with a signature similar to this: def parse(literalString: Literal, offset: Int, length: Int): Tree It would take the specified slice of the literal string and call the normal parse method on it but would then use the resulting positions only as an offset into the original literal string position. As an example, consider a macro call parse(literal, 12, 6) // 12 = offset of '3' in string, 6 = length of expression The resulting tree for I guess the use-case for this is getting less important with string interpolation basically providing other means for embedding scala expressions in strings but still having something like this would enable custom string interpolation schemes. |
@retronym said: |
From https://groups.google.com/forum/?fromgroups=#!topic/scala-user/bxY0q0nCO4E
The text was updated successfully, but these errors were encountered: