Skip to content

Update nim syntax to nim 2.0+ - #4237

Open
5BNeumann wants to merge 2 commits into
micro-editor:masterfrom
5BNeumann:master
Open

5BNeumann wants to merge 2 commits into
micro-editor:masterfrom
5BNeumann:master

Conversation

@5BNeumann

Copy link
Copy Markdown

This adds support for multi-line comments/strings, and fix some mistakes for the single line comments/string. (eg. "#" was considered a comment and not a string which contains a #)
I borrowed some of the logic from the C syntax.

Add support for multiline comments and string as well as fix the old single line comments and strings.

@Andriamanitra Andriamanitra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice touch to add raw string literals too while we are at it.

Comment thread runtime/syntax/nim.yaml

- constant.string:
start: "\"\"\""
end: "\"\"\""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be quite right.

The ending of the string literal is defined by the pattern """[^"], so this:
""""long string within quotes""""
Produces:
"long string within quotes"

https://nim-lang.org/docs/manual.html#lexical-analysis-triple-quoted-string-literals

Comment thread runtime/syntax/nim.yaml
Comment on lines +28 to +33
- constant.string:
start: "'"
end: "'"
skip: "\\\\."
rules:
- constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs single quotes are used for char literals (max 1 byte), not strings.

https://nim-lang.org/docs/manual.html#lexical-analysis-character-literals

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