-
Notifications
You must be signed in to change notification settings - Fork 18
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 quasi quotation #17
Labels
Comments
harpocrates
added a commit
that referenced
this issue
Mar 23, 2017
Started implementing unquoting. So far, pretty much all my changes have been limited to the 'Quote' module. I've followed the approach detailed in #17 - "all" that remains is updating the grammar to use ViewPatterns instead of directly pattern matching (against possibly undefined things)
harpocrates
added a commit
that referenced
this issue
Mar 23, 2017
Started implementing unquoting. So far, pretty much all my changes have been limited to the 'Quote' module. I've followed the approach detailed in #17 - "all" that remains is updating the grammar to use ViewPatterns instead of directly pattern matching (against possibly undefined things)
harpocrates
added a commit
that referenced
this issue
Mar 24, 2017
Explained in detail the tradeoffs already mentioned in #17. Also cleaned up some code around quasiquotes.
Here is a simple example of why we need the
Even more insidiously (check
|
Alright. I've mulled over this for a week and I've come up with a new approach, which isn't a hack:
This may take some time... |
harpocrates
added a commit
that referenced
this issue
May 8, 2017
* Tweaked Haddock related documentation in a couple of places. * Expose only Language.Rust.Syntax (no AST, Ident, and Token modules). This will make is easier to address #17 while maintaining backwards compatibility (the pattern synonyms will be defined in the 'Syntax' module which otherwise currently only just re-exports 'AST') * Add key points of 0.1.0.0 release to CHANGELOG. fixes #7
This won't make the 0.1.0.0 release. Instead, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Besides the obvious quasi quotation, I want to capture variables with
SubstNt
tokens inExp
and bind variables withMatchNt
inPat
. The following interaction should work:Here is my current approach. It is terrible. I can't believe I have been reduced to this, but I've been thinking non-stop about this for 2 weeks now and have come up with nothing better.
Q (String -> Maybe Type)
function (instead ofString -> Q Type
) and use that to make the swapping function. Alternately, lex twice and extract all of the interesting tokens, look them up, and pass them in as a function in the second lexing pass.NonTerminal
s containingerror <variable-name>
- but of the right type!dataToPatQ
anddataToExpQ
, whenever something is of the right type, check if it is defined. If so, do nothing, otherwise, use the error message (ewwwwww!) to lookup variable or make an identifier pattern.Is there nothing better?
Maybe there is. Here are some unorganized thoughts on this topic:
P
monad over an arbitrary monad (in particularQ
andIdentity
, allowing me to swap tokens in this monad) - this is already done in another branch, although I have misgivings about performance. I had to disable the monomorphism restriction to get the generated files to compile, and I have a feeling that polymorphic lexer/parser will take a hit in performance.The "good"TM solution is probably an extensible AST with type families, but given that the AST is already ~1kloc, adding a type family for every constructor may get... a bit too big. Plus this also looks ugly to the end user.
Also, the solution described initially isn't so bad. It does not change the reliability of regular parsing - it only risks failing in the case of quasi quotes (which will be marked experimental and non-portable, and will only cause compile-time headaches).
The text was updated successfully, but these errors were encountered: