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

Fix syntax is ignore after multi-line comment #313

Merged
merged 4 commits into from
Dec 26, 2022

Conversation

GreasySlug
Copy link
Member

@GreasySlug GreasySlug commented Dec 26, 2022

Fixes #311.

A one-line comment was executed after a multi-line comment.
That's why, syntax after multi-line comments was ignored.

There may also be a whitespace after the multi-line comment.
This could be invalid, please check.

a =
#[comment]#    1#Is this valid?

I made it syntax error.

Changes proposed in this PR:

  • Fix syntax is ignore after multi-line comment

@mtshiba

@mtshiba
Copy link
Member

mtshiba commented Dec 26, 2022

I would like to make multiline comment grammatically equivalent to space. This follows other languages. So, a comment at the beginning of a sentence is a syntax error.

i #[: Int]# = 1
↓
i = 1

#[]# print! "a"
↓
 print! "a" # syntax error

@GreasySlug
Copy link
Member Author

I would like to make multiline comment grammatically equivalent to space. This follows other languages. So, a comment at the beginning of a sentence is a syntax error.

Does the length of the whitespace change depending on the content of the multi-line comment?
Or one whitespace regardless of content?

#[]# a = 1
#[sample]# b = 1
↓
[ ]a = 1
[ ]b = 1
or
[ ]a = 1
[       ]b = 1

@mtshiba
Copy link
Member

mtshiba commented Dec 26, 2022

Since comments, like spaces, are not tokens, their length is grammatically meaningless.

Comments have the same meaning as spaces, but they are not replaced by an actual spaces.

However, its length must be taken into account when dealing with token locations.

@GreasySlug
Copy link
Member Author

Yes, there is indeed a problem of misalignment caused by comments.
I'll start a separate Issue for this.

@GreasySlug GreasySlug merged commit 68e0622 into erg-lang:main Dec 26, 2022
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.

Unwanted behavior of multiline comment
2 participants