From e2f2850f20f162df8741480933041bee6f9683e1 Mon Sep 17 00:00:00 2001 From: thecoolguy62aws <150736455+thecoolguy62aws@users.noreply.github.com> Date: Sat, 2 May 2026 10:17:46 -0700 Subject: [PATCH] Add Lox Language --- .gitmodules | 3 +++ grammars.yml | 2 ++ lib/linguist/languages.yml | 10 +++++++++- samples/Lox/fibonacci_numbers.lox | 11 +++++++++++ samples/Lox/inherited_method.lox | 22 ++++++++++++++++++++++ vendor/grammars/lox-language | 1 + 6 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 samples/Lox/fibonacci_numbers.lox create mode 100644 samples/Lox/inherited_method.lox create mode 160000 vendor/grammars/lox-language diff --git a/.gitmodules b/.gitmodules index b1350e9350..2ac94a9d9e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1593,3 +1593,6 @@ [submodule "vendor/grammars/zephir-sublime"] path = vendor/grammars/zephir-sublime url = https://github.com/phalcon/zephir-sublime +[submodule "vendor/grammars/lox-language"] + path = vendor/grammars/lox-language + url = https://github.com/danman113/lox-language.git diff --git a/grammars.yml b/grammars.yml index 5a4b7d8136..773ebf04c7 100644 --- a/grammars.yml +++ b/grammars.yml @@ -888,6 +888,8 @@ vendor/grammars/logos: - source.logos vendor/grammars/logtalk.tmbundle: - source.logtalk +vendor/grammars/lox-language: +- source.lox vendor/grammars/lua.tmbundle: - source.lua vendor/grammars/m3: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index c11c9046d6..5b82ce0c93 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -4357,6 +4357,14 @@ LoomScript: tm_scope: source.loomscript ace_mode: text language_id: 212 +Lox: + type: programming + extensions: + - ".lox" + tm_scope: source.lox + ace_mode: text + color: "#f1ead7" + language_id: 640917978 Lua: type: programming tm_scope: source.lua @@ -7682,7 +7690,7 @@ TMDL: extensions: - ".tmdl" aliases: - - "Tabular Model Definition Language" + - Tabular Model Definition Language tm_scope: source.tmdl ace_mode: text language_id: 769162295 diff --git a/samples/Lox/fibonacci_numbers.lox b/samples/Lox/fibonacci_numbers.lox new file mode 100644 index 0000000000..0c61e8e48a --- /dev/null +++ b/samples/Lox/fibonacci_numbers.lox @@ -0,0 +1,11 @@ +// Amount of digits +var n = 10; + +var a = 0; +var b = 1; +for (var i = 0; i < n; i = i + 1) { + print a; + var temp = a; + a = b; + b = temp + b; +} diff --git a/samples/Lox/inherited_method.lox b/samples/Lox/inherited_method.lox new file mode 100644 index 0000000000..8b49b532d1 --- /dev/null +++ b/samples/Lox/inherited_method.lox @@ -0,0 +1,22 @@ +class Foo { + inFoo() { + print "in foo"; + } +} + +class Bar < Foo { + inBar() { + print "in bar"; + } +} + +class Baz < Bar { + inBaz() { + print "in baz"; + } +} + +var baz = Baz(); +baz.inFoo(); // expect: in foo +baz.inBar(); // expect: in bar +baz.inBaz(); // expect: in baz diff --git a/vendor/grammars/lox-language b/vendor/grammars/lox-language new file mode 160000 index 0000000000..eb6a234e93 --- /dev/null +++ b/vendor/grammars/lox-language @@ -0,0 +1 @@ +Subproject commit eb6a234e9354f9a0c9db4119e719ac8895342896