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
37 changes: 22 additions & 15 deletions runtime/syntax/gdscript.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,45 @@ rules:
# Built-in constants
- constant: "\\b(INF|NAN|PI|TAU)\\b"
- constant.bool: "\\b(null|true|false)\\b"
# Function calls
- identifier: "\\b[a-zA-Z_][a-zA-Z_0-9]+\\("
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not * as in line 21 with [a-zA-Z_][a-zA-Z_0-9]*?
It should follow the same rule for the function name, at least I'd expect.

# Built-in functions
- identifier: "\\b(abs|acos|asin|atan|atan2|ceil|clamp|convert|cos|cosh|db2linear|decimals|deg2rad|ease|exp|float|floor|fmod|fposmod|hash|int|isinf|isnan|lerp|linear2db|load|log|max|min|nearest_po2|pow|preload|print|printerr|printraw|prints|printt|rad2deg|rand_range|rand_seed|randomize|randi|randf|range|round|seed|sin|slerp|sqrt|str|str2var|tan|typeof|var2str|weakref)\\b"
# Built-in node names
- identifier: "\\b(AnimationPlayer|AnimationTreePlayer|Button|Control|Engine|HTTPClient|HTTPRequest|Input|InputEvent|MainLoop|Node|Node2D|OS|SceneTree|Spatial|StreamPeer|PacketPeer|PacketPeerUDP|Timer|Tween)\\b"
- identifier: "\\b(abs|acos|asin|atan|atan2|bool|ceil|clamp|convert|cos|cosh|db2linear|decimals|deg2rad|ease|exp|float|floor|fmod|fposmod|hash|int|isinf|isnan|lerp|linear2db|load|log|max|min|nearest_po2|pow|preload|print|printerr|printraw|prints|printt|rad2deg|rand_range|rand_seed|randomize|randi|randf|range|round|seed|sin|slerp|sqrt|str|str2var|tan|typeof|var2str|weakref)\\b"
# Types
- type: "\\b(AABB|Array|Basis|Color|Dictionary|NodePath|Object|Plane|PoolByteArray|PoolColorArray|PoolIntArray|PoolRealArray|PoolVector2Array|PoolVector3Array|Quat|Rect2|RID|String|Transform|Transform2D|Vector2|Vector3)\\b"
- type: "\\b(AABB|Array|Basis|Callable|Color|Dictionary|NodePath|Object|PackedByteArray|PackedColorArray|PackedFloat32Array|PackedFloat64Array|PackedInt32Array|PackedInt64Array|PackedVector2Array|PackedVector3Array|PackedVector4Array|Plane|PoolByteArray|PoolColorArray|PoolIntArray|PoolRealArray|PoolVector2Array|PoolVector3Array|Projection|Quat|Quaternion|Rect2|Rect2i|RID|Signal|String|StringName|Transform|Transform2D|Transform3D|Variant|Vector2|Vector2i|Vector3|Vector3i|Vector4|Vector4i|void)\\b"
# Class names (PascalCase)
- identifier: "\\b([A-Z][a-zA-Z0-9_]*)\\b"
# Constant names (CONSTANT_CASE)
- constant: "\\b([A-Z][A-Z0-9_]*)\\b"
# Definitions
- identifier: "func [a-zA-Z_0-9]+"
- identifier: "func\\s+[a-zA-Z_][a-zA-Z_0-9]*"
# Annotations
- statement.meta: "@[A-Za-z_][A-Za-z0-9_]*\\b"
# Keywords
- statement: "\\b(and|as|assert|break|breakpoint|class|const|continue|elif|else|enum|export|extends|for|func|if|in|is|map|master|mastersync|match|not|onready|or|pass|remote|remotesync|return|self|setget|slave|slavesync|signal|sync|tool|var|while|yield)\\b"
- statement: "\\b(and|as|assert|await|break|breakpoint|class|class_name|const|continue|elif|else|enum|export|extends|for|func|get|if|in|is|map|master|mastersync|match|not|onready|or|pass|remote|remotesync|return|self|set|setget|slave|slavesync|signal|static|super|sync|tool|var|when|while|yield)\\b"

# Operators
- statement: "[.:;,+*|=!\\%@]|<|>|/|-|&"
- statement: "[.:;,+*|=!\\%]|<|>|/|-|&"

# Parentheses
- statement: "[(){}]|\\[|\\]"

# Numbers
- constant: "\\b[0-9]+\\b"
- constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'"
- constant.number: "-?\\b(?:0[xX](?:[0-9a-fA-F]_?)+|0[bB](?:[01]_?)+|(?:(?:[0-9]_?)*\\.(?:[0-9]_?)+)(?:[eE]-?(?:[0-9]_?)+)?|(?:[0-9]_?)+\\.?(?:[eE]-?(?:[0-9]_?)+)?)\\b"

- comment:
- constant.string:
start: "\"\"\""
end: "\"\"\""
skip: "\\\\."
rules:
- todo: "(TODO|XXX|FIXME):?"
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"

- comment:
start: "'''"
end: "'''"
- constant.string:
start: "\'\'\'"
end: "\'\'\'"
skip: "\\\\."
rules:
- todo: "(TODO|XXX|FIXME):?"
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"

- constant.string:
start: "\""
Expand Down