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

Allowed characters in identifiers #817

Open
gabrielhdt opened this issue Jan 18, 2022 · 6 comments
Open

Allowed characters in identifiers #817

gabrielhdt opened this issue Jan 18, 2022 · 6 comments

Comments

@gabrielhdt
Copy link
Member

The following line does not typecheck:

symbol foo/bar: TYPE;

and yield the following error message

[...] The proof is not finished.
@gabrielhdt
Copy link
Member Author

gabrielhdt commented Jan 18, 2022

Perhaps, because of the comments, we must not allow / in identifiers.

@gabrielhdt

This comment has been minimized.

@gabrielhdt
Copy link
Member Author

The pull request #818 solves the issue

@fblanqui
Copy link
Member

The problem is that foo/bar is parsed as 3 separate identifiers foo / bar because / is not allowed in identifiers except as a single-letter identifier. I agree that the message is not nice. A way to get a better message is to ask the lexer to output an error message in case an identifier containing / (but reduced to /) is parsed.

@fblanqui fblanqui changed the title Parsing identifiers Unclear error message for "identifiers" containing / Jan 19, 2022
@fblanqui
Copy link
Member

To solve this issue, I would rather suggest to do:

let separ_letter = [%sedlex.regexp? Chars " ,;.:\r\t\n(){}[]\""]
let special_letter = [%sedlex.regexp? Chars "`@/|$?"]
let forbidden_letter = [%sedlex.regexp? separ_letter | special_letter]
let allowed_letter = [%sedlex.regexp? Compl forbidden_letter]
let regid = [%sedlex.regexp? Plus allowed_letter]
let badid = [%sedlex.regexp? Plus allowed_letter, Plus (special_letter, Star allowed_letter)]
[...]
| '/' | regid -> UID(Utf8.lexeme lb)
| badid -> fail lb "Forbidden identifier"

@gabrielhdt gabrielhdt changed the title Unclear error message for "identifiers" containing / Allowed characters in identifiers Jan 25, 2022
@gabrielhdt
Copy link
Member Author

My concern is rather that the syntax of identifiers is not really clear. It seems odd to me to allow / by itself but not in anything else. IMO nobody will remember or use that, even when writing translators.

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