Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions runtime/syntax/nim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,42 @@ rules:
- constant.number: "\\b0[ocC][0-7][0-7_]+\\b"
- constant.number: "\\b0[bB][01][01_]+\\b"
- constant.number: "\\b[0-9_]((\\.?)[0-9_]+)?[eE][+\\-][0-9][0-9_]+\\b"
- constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'"
- comment: "[[:space:]]*(?:[^\\\\]|^)#.*$"
- comment:
start: "\\#\\["
end: "\\]\\#"

- 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]+\\})"

- constant.string:
start: "(r|R)\""
end: "(\"|$)"
skip: "\\\\."
rules: []

- 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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is how the python3 syntax handles multi-line comments and it works pretty much how it should with the new changes. (""""long string within quotes"""" does give the expected result which was not the case prior to the newest commit.)

skip: "\\\\."
rules: []

- todo: "(TODO|FIXME|XXX):?"
- constant.string:
start: "'"
end: "('|$)"
skip: "\\\\."
rules:
- error: "[[:graph:]]{2,}'"
- constant.specialChar: "\\\\([\"'abceflnprtv\\\\]|\\d+|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\})"

- comment:
start: "#\\["
end: "\\]#"
rules:
- todo: "(TODO|FIXME|XXX):?"

- comment:
start: "#"
end: "$"
rules:
- todo: "(TODO|FIXME|XXX):?"