Created
September 17, 2013 09:43
-
-
Save SimonRichardson/6592225 to your computer and use it in GitHub Desktop.
Create a string from a series of raw identifiers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro $string { | |
| case {_ ([$x $inner ...] $rest ...)} => { | |
| var ctx = #{$x}, | |
| value = ctx[0].token.value, | |
| str = makeValue(value, #{here}); | |
| return withSyntax($val = [str]) { | |
| return #{'[' + $val + $string($inner ...) + ']' + $string($rest ...)} | |
| } | |
| } | |
| case {_ ($x $rest ...) } => { | |
| var ctx = #{$x}, | |
| value = ctx[0].token.value, | |
| str = makeValue(value, #{here}); | |
| return withSyntax($val = [str]) { | |
| return #{$val + $string($rest ...)} | |
| } | |
| } | |
| case {_ ()} => { | |
| return #{''}; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a.b.c[x + 1]becomes'a.b.c[x + 1]'