Skip to content
This repository has been archived by the owner on Aug 21, 2018. It is now read-only.

Parse string interpolation expressions #10

Open
Gama11 opened this issue Feb 28, 2017 · 3 comments
Open

Parse string interpolation expressions #10

Gama11 opened this issue Feb 28, 2017 · 3 comments

Comments

@Gama11
Copy link
Member

Gama11 commented Feb 28, 2017

Right now, it's all just one token:

@Simn
Copy link
Member

Simn commented Mar 11, 2017

Any suggestions for a representation?

@nadako
Copy link
Member

nadako commented Mar 11, 2017

what come to mind mind is something like Array<StringPart> where

enum StringPart {
 PString(string:Token);
 PIdent(dollar:Token, ident:Token);
 PExpr(dollar:Token, bropen:Token, expr:Expr, brclose:Token);
}

@Simn
Copy link
Member

Simn commented Mar 12, 2017

This is giving me a bit of a headache. I checked how roslyn does it: They tokenize a single string token (like we do now), then create a fresh scanner/parser to break it up into multiple tokens, which themselves contain parsed data in the case of expressions, or something like that.

For starters, I'm having architectural issues because emitters can't really create new parsers as that would require them to refer to themselves recursively. This could probably be solved in some way, but I'm not sure how to properly do it.

Then there's the problem of the token list. By the time the original string token is emitted, it is already part of the token list. We would have to replace it with the result of the recursive parsing operation.

Overall, this seems very complicated. It might be a better idea to leave it unchanged for now and provide an entry point "interpolated_string". The result can then be combined through the incremental parsing API that we hopefully manage to get right at some point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants