From edd6441339a53cb893f672ae20ffd4e5d0b10082 Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Mon, 3 Feb 2025 14:16:49 +0100 Subject: [PATCH] Add Jule language Co-authored-by: mertcandav Signed-off-by: Adam Perkowski --- .gitmodules | 3 ++ grammars.yml | 2 + lib/linguist/languages.yml | 10 +++++ samples/Jule/bigint.jule | 23 ++++++++++ samples/Jule/generic.jule | 42 +++++++++++++++++++ samples/Jule/json.jule | 28 +++++++++++++ vendor/README.md | 1 + vendor/grammars/vscode-jule | 1 + .../git_submodule/vscode-jule.dep.yml | 42 +++++++++++++++++++ 9 files changed, 152 insertions(+) create mode 100644 samples/Jule/bigint.jule create mode 100644 samples/Jule/generic.jule create mode 100644 samples/Jule/json.jule create mode 160000 vendor/grammars/vscode-jule create mode 100644 vendor/licenses/git_submodule/vscode-jule.dep.yml diff --git a/.gitmodules b/.gitmodules index 65d5ef54e..ccaf9c097 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1338,6 +1338,9 @@ [submodule "vendor/grammars/vscode-jest"] path = vendor/grammars/vscode-jest url = https://github.com/jest-community/vscode-jest +[submodule "vendor/grammars/vscode-jule"] + path = vendor/grammars/vscode-jule + url = https://github.com/julelang/vscode-jule.git [submodule "vendor/grammars/vscode-just"] path = vendor/grammars/vscode-just url = https://github.com/nefrob/vscode-just.git diff --git a/grammars.yml b/grammars.yml index 219734dcf..9ffcf8427 100644 --- a/grammars.yml +++ b/grammars.yml @@ -1201,6 +1201,8 @@ vendor/grammars/vscode-janet: - source.janet vendor/grammars/vscode-jest: - source.jest.snap +vendor/grammars/vscode-jule: +- source.jule vendor/grammars/vscode-just: - source.just vendor/grammars/vscode-lean: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index b5eebfe28..db16a3128 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -3592,6 +3592,16 @@ Jsonnet: - ".libsonnet" tm_scope: source.jsonnet language_id: 664885656 +Jule: + type: programming + color: "#5f7489" + aliases: + - julelang + extensions: + - ".jule" + tm_scope: source.jule + ace_mode: text + language_id: 90868683 Julia: type: programming extensions: diff --git a/samples/Jule/bigint.jule b/samples/Jule/bigint.jule new file mode 100644 index 000000000..5353b84f8 --- /dev/null +++ b/samples/Jule/bigint.jule @@ -0,0 +1,23 @@ +// This work is marked with CC0 1.0 Universal +// https://creativecommons.org/publicdomain/zero/1.0 + +use "std/fmt" +use "std/math/big" +use "std/os" + +fn main() { + fmt::Println("This program computes size of the big integers.") + for { + fmt::Print("Integer: ") + line := os::Stdin().ReadLine()! + i := big::Int.Parse(line, 0) else { + fmt::Println("error: conversion failed, please write a valid integer") + continue + } + bits := i.BitLen() + fmt::Println("Bits: ", bits) + fmt::Println("Bytes: ", bits/8) + fmt::Println("Fits in 64-bit signed int: ", i.IsI64()) + fmt::Println("Fits in 64-bit unsigned int: ", i.IsU64()) + } +} \ No newline at end of file diff --git a/samples/Jule/generic.jule b/samples/Jule/generic.jule new file mode 100644 index 000000000..1affbcf93 --- /dev/null +++ b/samples/Jule/generic.jule @@ -0,0 +1,42 @@ +// This work is marked with CC0 1.0 Universal +// https://creativecommons.org/publicdomain/zero/1.0 + +use "std/math/rand" +use "std/time" + +fn Max[S: []E, E: ordered](mut s: S): E { + if len(s) == 0 { + panic("Max: empty slice") + } + mut m := s[0] + for _, e in s[1:] { + if m < e { + m = e + } + } + ret m +} + +fn Min[S: []E, E: ordered](mut s: S): E { + if len(s) == 0 { + panic("Min: empty slice") + } + mut m := s[0] + for _, e in s[1:] { + if m > e { + m = e + } + } + ret m +} + +fn main() { + rand := rand::Rand.New(rand::NewSource(u64(time::Now().Nanosecond()))) + mut s := make([]int, 10) + for i in s { + s[i] = rand.Intn(100) + } + println(s) + println(Max(s)) + println(Min(s)) +} \ No newline at end of file diff --git a/samples/Jule/json.jule b/samples/Jule/json.jule new file mode 100644 index 000000000..ba30a27f3 --- /dev/null +++ b/samples/Jule/json.jule @@ -0,0 +1,28 @@ +// This work is marked with CC0 1.0 Universal +// https://creativecommons.org/publicdomain/zero/1.0 + +use "std/encoding/json" +use "std/math" + +struct Foo { + Bar: str + Baz: i64 + Buz: bool + Fiz: f64 +} + +fn main() { + mut f := Foo{ + Bar: "foobarbaz", + Baz: 89, + Buz: true, + Fiz: math::Pi, + } + println(f) + bytes := json::Encode(f)! + println(str(bytes)) + f = Foo{} + println(f) + json::Decode(bytes, f)! + println(f) +} \ No newline at end of file diff --git a/vendor/README.md b/vendor/README.md index f2b1a53f6..c7431647e 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -291,6 +291,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Jison Lex:** [cdibbs/language-jison](https://github.com/cdibbs/language-jison) - **Jolie:** [fmontesi/language-jolie](https://github.com/fmontesi/language-jolie) - **Jsonnet:** [google/language-jsonnet](https://github.com/google/language-jsonnet) +- **Jule:** [julelang/vscode-jule](https://github.com/julelang/vscode-jule) - **Julia:** [JuliaEditorSupport/atom-language-julia](https://github.com/JuliaEditorSupport/atom-language-julia) - **Julia REPL:** [JuliaEditorSupport/atom-language-julia](https://github.com/JuliaEditorSupport/atom-language-julia) - **Jupyter Notebook:** [Nixinova/NovaGrammars](https://github.com/Nixinova/NovaGrammars) diff --git a/vendor/grammars/vscode-jule b/vendor/grammars/vscode-jule new file mode 160000 index 000000000..27662b251 --- /dev/null +++ b/vendor/grammars/vscode-jule @@ -0,0 +1 @@ +Subproject commit 27662b2519b6780c86314e0c3e7ba6be21f3ff03 diff --git a/vendor/licenses/git_submodule/vscode-jule.dep.yml b/vendor/licenses/git_submodule/vscode-jule.dep.yml new file mode 100644 index 000000000..162db127f --- /dev/null +++ b/vendor/licenses/git_submodule/vscode-jule.dep.yml @@ -0,0 +1,42 @@ +--- +name: vscode-jule +version: 27662b2519b6780c86314e0c3e7ba6be21f3ff03 +type: git_submodule +homepage: https://github.com/julelang/vscode-jule.git +license: bsd-3-clause +licenses: +- sources: LICENSE + text: | + BSD 3-Clause License + + Copyright (c) 2022, Mertcan DAVULCU + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- sources: README.md + text: |- + The extension is distributed under the terms of the BSD 3-Clause license.
+ [See License Details](LICENSE) +notices: []