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

Add GDScript(Godot script) language support #1175

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.en.txt
Expand Up @@ -216,3 +216,4 @@ Contributors:
- Taisuke Fujimoto <temp-impl@users.noreply.github.com>
- Boone Severson <boone.severson@gmail.com>
- Victor Zhou <OiCMudkips@users.noreply.github.com>
- Geequlim <geequlim@gmail.com>
3 changes: 2 additions & 1 deletion CHANGES.md
@@ -1,7 +1,7 @@
## Version 9.4.0 (unreleased)

New languages:

- *GDScript* by [Geequlim][]
- *PureBASIC* by [Tristano Ajmone][]
- *BNF* by [Oleg Efimov][]

Expand All @@ -17,6 +17,7 @@ Improvements:
- [Boone Severson][] updated Verilog to comply with IEEE 1800-2012 SystemVerilog
- [Victor Zhou][] improved rules for comments and strings in PowerShell files

[Geequlim]: https://github.com/Geequlim
[Tristano Ajmone]: https://github.com/tajmone
[Taisuke Fujimoto]: https://github.com/temp-impl
[Oleg Efimov]: https://github.com/Sannis
Expand Down
2 changes: 2 additions & 0 deletions docs/css-classes-reference.rst
Expand Up @@ -218,6 +218,8 @@ Language names and aliases
+-------------------------+---------------------------------------------------+
| GAUSS | gauss, gss |
+-------------------------+---------------------------------------------------+
| GDScript | gd, godot, gdscript |
+-------------------------+---------------------------------------------------+
| Gherkin | gherkin |
+-------------------------+---------------------------------------------------+
| Go | go, golang |
Expand Down
101 changes: 101 additions & 0 deletions src/languages/gdscript.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions test/detect/gdscript/default.txt
@@ -0,0 +1,71 @@
# a file is a class!
# inheritance

tool
extends BaseClass

# member variables
var a = 5
var s = "Hello"
# built-in types
var v2 = Vector2(1, 2)
var v3 = Vector3(1, 2, 3)
var rect = Rect2(0, 0, 20, 20)
var node = Sprite.new()

# constants
const a = 5
const f = sin(20) # sin() is a built-in function

# static function
static func sum2(a, b):
return a + b

# Cache the enemy class
const enemy_class = preload("enemy.gd")

# export variables
export var text
export(int, FLAGS) var spell_elements = ELEMENT_WIND | ELEMENT_WATER
export(String, FILE, GLOBAL, "*.png") var tool_image

# setters/getters
var variable = value setget setterfunc, getterfunc

# signals
signal your_signal_name
signal your_signal_name_with_args(a,b)

# function
func some_function(param1, param2):
var local_var = 5

if param1 < local_var:
print(param1)
elif param2 > 5:
print(param2)
else:
print("fail!")

for i in range(20):
print(i)

while(param2 != 0):
param2 -= 1

var local_var2 = param1+3
return local_var2


# An inner class in this class file
class SomeInnerClass:
var a = 5
func print_value_of_a():
print(a)

# This is the constructor of the class file's main class
func _init():
var c = SomeInnerClass.new()
c.print_value_of_a()
# instance a resource
var enermy = enemy_class.instance()