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

v.yaml didn't seem to contain some V lang keywords and was seemingly out-of-date. #3591

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
64 changes: 28 additions & 36 deletions runtime/syntax/v.yaml
Original file line number Diff line number Diff line change
@@ -1,71 +1,63 @@
filetype: v

detect:
filename: "\\.v$"

rules:
# Conditionals and control flow
- preproc: "\\b(module|import)\\b"
- statement: "\\b(if|else|for|match|select|defer|or|unsafe)\\b"
- statement: "\\b(if|else|for|match|select|defer|or|unsafe|asm|defer|go|goto|lock|match|or|rlock|select|spawn|unsafe)\\b"
- statement: "\\b(sizeof|typeof)\\b"
- statement: "\\b(break|continue|goto|return)\\b"
- type.keyword: "\\b(assert|const|enum|fn|struct|interface|type)\\b"
- type.keyword: "\\b(pub|mut|__global)\\b"
- statement: "\\b(as|in|is)\\b"
- type.keyword: "\\b(assert|const|enum|fn|struct|interface|type|implements|shared|static|union|volatile)\\b"
- type.keyword: "\\b(pub|mut|__global|__offsetof)\\b"

- preproc: "\\$\\b(if|else)\\b"
- identifier.os: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|android|solaris|haiku)\\b"
- identifier.compiler: "\\b(gcc|tinyc|clang|mingw|msvc|cplusplus)\\b"
- identifier.platform: "\\b(amd64|aarch64|x64|x32|little_endian|big_endian)\\b"
- identifier.other: "\\b(debug|test|js|glibc|prealloc|no_bounds_checking)\\b"
- constant.bool: "\\b(true|false)\\b"
- constant.none: "\\b(none)\\b"

- identifier.class: "\\b([A-Z][A-Za-z0-9_]*)\\b"
- identifier.function: "\\b([a-z_]+\\()"
- symbol.operator: "\\b(i[ns])\\b|[-+/*<>!=~*%&:|,.?]"
Comment on lines -19 to -21
Copy link
Collaborator

Choose a reason for hiding this comment

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

No class, function and operator support any longer?

- symbol.attribute:
start: "^\\["
end: "\\]$"
rules:
- default: ".*"
- symbol: "\\b(deprecated|direct_array_access|if|inline|live|ref_only|typedef|windows_stdcall)\\b"
Comment on lines -22 to -27
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really not needed any longer?


# Types
- type: "\\b(byte|u(16|32|64|128)|i(nt|8|16|64|128)|f(32|64))\\b"
- type: "\\b(bool|cha[nr]|map|rune|string)\\b"
- type: "\\b(any(_int|_float)?|size_t|(uint|byte|char|void)ptr)\\b"
- constant.bool: "\\b(true|false)\\b"
- constant.none: "\\b(none)\\b"

# Brackets
- symbol.brackets: "(\\{|\\})"
- symbol.brackets: "(\\(|\\))"
- symbol.brackets: "(\\[|\\])"

# Numbers and strings
- constant.number: "\\b(0b[01_]+)\\b"
- constant.number: "\\b(0o[0-7_]+)\\b"
- constant.number: "\\b(0x[0-9a-fA-F_]+)\\b"
- constant.number: "\\b([0-9_]+)\\b"


- constant.string:
start: "\""
end: "\""
start: "`"
end: "`"
skip: "\\\\."
rules:
- constant.specialChar: "%."
- constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]"
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"

- constant.string:
start: "'"
end: "'"
skip: "\\\\."
rules:
- constant.specialChar: "%."
- constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]"
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"

- constant.string:
start: "`"
end: "`"
start: "\""
end: "\""
skip: "\\\\."
rules:
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"

# Brackets
- symbol.brackets: "(\\{|\\})"
- symbol.brackets: "(\\(|\\))"
- symbol.brackets: "(\\[|\\])"
codemanticism marked this conversation as resolved.
Show resolved Hide resolved

# Numbers and strings
- constant.number: "\\b(0b[01_]+)\\b"
- constant.number: "\\b(0o[0-7_]+)\\b"
- constant.number: "\\b(0x[0-9a-fA-F_]+)\\b"
- constant.number: "\\b([0-9_]+)\\b"
- comment:
start: "//"
end: "$"
Expand Down