Skip to content
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

Perhaps a new token is better? #1

Open
njlr opened this issue Jan 16, 2018 · 1 comment
Open

Perhaps a new token is better? #1

njlr opened this issue Jan 16, 2018 · 1 comment

Comments

@njlr
Copy link

njlr commented Jan 16, 2018

I was reading your proposal and found:

-> is the only token used and required by this proposal. Several people suggested -> for code injection purposes. It's already a valid c++ token, which mean there is no need to add any new token or keyword, and -> represents injection pretty well.

Perhaps a new token is actually better? One reason why C++ is so slow to compile is due to the reuse of tokens. It requires the compiler to examine the context of tokens to disambiguate them.

@cor3ntin
Copy link
Owner

Fortunately, there should be no need to examine the context.
-> followed by {, (, class, struct or namespace means injection, otherwise it means operator-> or trailing return type.
You only ever need to look up one token a head, which seems rather sensible given all the crazy things involved in parsing some other constructs.

if(token.is("->") and nextToken.is_identifier()) {
      // not injection
}
else {
    // probably injection
}

What other token would you propose ? we are running short on them. Maybe => ?

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

No branches or pull requests

2 participants