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

reserve identifier is for *type-id* is #759

Closed
wants to merge 2 commits into from
Closed

Conversation

ntrel
Copy link
Contributor

@ntrel ntrel commented Oct 16, 2023

Relevant lines from the grammar:

    //G is-as-expression:
    //G     prefix-expression
    //G     is-as-expression is-type-constraint
    //G     is-as-expression is-value-constraint
    //GTODO     type-id is-type-constraint

Both prefix-expression and type-id can be an unqualified-id. T is is not implemented yet, but when it is, it would conflict with be parsed as identifier is to test an expression.

I understand the usual way of disambiguating between a type or an expression is to require parens to force an expression, so I have done that here to fix 5 regression_tests. I have added a temporary error for identifier is, because that should be the unimplemented T is form.

Update: So I've moved the type-id form above prefix-expression in the grammar.

Relevant lines pasted from the grammar:
```c
    //G is-as-expression:
    //G     prefix-expression
    //G     is-as-expression is-value-constraint
    //GTODO     type-id is-type-constraint
```
A *prefix-expression* can be an *unqualified-id*, which can also be a
*type-id*. So when the latter is implemented, it would break any code
using `identifier is` to test an expression.

I understand the usual way of disambiguating is to require parens, so I
have done that here to fix 5 `regression_tests`.
@filipsajdak
Copy link
Contributor

I have implemented T is X on the cpp side here: #701. If you can express it on the cpp2 side you can generate a cpp2::is<T, X>() code. I have tested that on cpp side.

@ntrel ntrel changed the title Disambiguate identifier is Parse identifier is as *type-id* is Oct 21, 2023
@ntrel ntrel changed the title Parse identifier is as *type-id* is reserve identifier is for *type-id* is Oct 22, 2023
@ntrel
Copy link
Contributor Author

ntrel commented Oct 23, 2023

@filipsajdak Thanks! I've started working on type is type only for now, your Cpp1 for that looks quite simple - https://github.com/ntrel/cppfront/tree/type-is. type is template looks much more involved.

@filipsajdak
Copy link
Contributor

I have implemented solution for types on cpp2 side. I am struggling with type as a template.

If you will need any explanation just let me know.

@ntrel ntrel mentioned this pull request Oct 25, 2023
@ntrel
Copy link
Contributor Author

ntrel commented Oct 25, 2023

Closing in favour of #782.

@ntrel ntrel closed this Oct 25, 2023
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

Successfully merging this pull request may close these issues.

2 participants