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

Disallow different characters after certain operators #67

Merged
merged 2 commits into from
Nov 28, 2021

Conversation

alex-pinkus
Copy link
Owner

Not all the operators in scanner.c are the same. In some cases, the
operators should be ignored if the character after them potentially lets
them be a custom operator themselves. In other cases, the operator
should be ignored if it's followed by alphanumeric characters (since
that would make it an identifier).

We solve this by adding a new list for the "illegal terminators" and
checking against those. This has the bonus of letting us add two new
semi suppressors:

  1. as, the bare keyword, now that we aren't fooled by having it at the
    start of a word
  2. + and -, but only when followed by whitespace - when there's no
    whitespace between the operator and the subsequent token, but there is
    whitespace before it, Swift treats it as a prefix operator. We just have
    to check the trailing whitespace here because we're just concerned about
    semi suppression.

Not all the operators in `scanner.c` are the same. In some cases, the
operators should be ignored if the character after them potentially lets
them be a custom operator themselves. In other cases, the operator
should be ignored if it's followed by alphanumeric characters (since
that would make it an identifier).

We solve this by adding a new list for the "illegal terminators" and
checking against those. This has the bonus of letting us add two new
semi suppressors:
1. `as`, the bare keyword, now that we aren't fooled by having it at the
start of a word
2. `+` and `-`, but only when followed by whitespace - when there's no
whitespace between the operator and the subsequent token, but there _is_
whitespace before it, Swift treats it as a prefix operator. We just have
to check the trailing whitespace here because we're just concerned about
semi suppression.
The test runner script was always forking, even if it only had one
iteration it needed to run. Instead, we can fork only if we're running
everything.
@alex-pinkus alex-pinkus merged commit 0ce5a77 into main Nov 28, 2021
@alex-pinkus alex-pinkus deleted the check-termination-after-operator branch November 28, 2021 22:22
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.

1 participant