mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-01 16:38:36 +01:00
Add Odin submodule and syntax test file
This commit is contained in:
parent
5c43ddb56c
commit
2e7ab99099
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -266,3 +266,6 @@
|
||||
[submodule "assets/syntaxes/02_Extra/Idris2"]
|
||||
path = assets/syntaxes/02_Extra/Idris2
|
||||
url = https://github.com/buzden/sublime-syntax-idris2
|
||||
[submodule "assets/syntaxes/02_Extra/sublime-odin"]
|
||||
path = assets/syntaxes/02_Extra/sublime-odin
|
||||
url = https://github.com/odin-lang/sublime-odin
|
||||
|
@ -22,6 +22,7 @@
|
||||
- Map `ndjson` extension to JSON syntax, see #3209 (@keith-hall)
|
||||
- Map files with `csproj`, `vbproj`, `props` and `targets` extensions to XML syntax, see #3213 (@keith-hall)
|
||||
- Add debsources syntax to highlight `/etc/apt/sources.list` files, see #3215 (@keith-hall)
|
||||
- Add syntax test file for GDScript highlighting, see #XYZ (@chetanjangir0)
|
||||
|
||||
## Themes
|
||||
|
||||
|
1
assets/syntaxes/02_Extra/sublime-odin
vendored
Submodule
1
assets/syntaxes/02_Extra/sublime-odin
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 5d6a0ed41e41ec3709ec74f40686dc3761d6596e
|
27
tests/syntax-tests/highlighted/Odin/test.odin
vendored
Normal file
27
tests/syntax-tests/highlighted/Odin/test.odin
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
[38;2;249;38;114mpackage[0m[38;2;248;248;242m main[0m
|
||||
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcore:fmt[0m[38;2;230;219;116m"[0m
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcore:math[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[38;2;166;226;46mVector[0m[38;2;248;248;242m :: [0m[3;38;2;102;217;239mstruct[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m components: [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;166;226;46meuclidean_distance[0m[38;2;248;248;242m :: [0m[3;38;2;102;217;239mproc[0m[38;2;248;248;242m(v1: Vector, v2: Vector) -> [0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;102;217;239mlen[0m[38;2;248;248;242m(v1.components) != [0m[38;2;102;217;239mlen[0m[38;2;248;248;242m(v2.components) {[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mpanic[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mVectors must be same dimension[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m sum: [0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m = [0m[38;2;190;132;255m0.0[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m i, comp [0m[38;2;249;38;114min[0m[38;2;248;248;242m v1.components {[0m
|
||||
[38;2;248;248;242m diff := comp - v2.components[i];[0m
|
||||
[38;2;248;248;242m sum += diff * diff;[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m math.[0m[38;2;102;217;239msqrt[0m[38;2;248;248;242m(sum);[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;166;226;46mmain[0m[38;2;248;248;242m :: [0m[3;38;2;102;217;239mproc[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m v1: Vector = Vector{components = [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m{[0m[38;2;190;132;255m1.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m2.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m3.0[0m[38;2;248;248;242m}};[0m
|
||||
[38;2;248;248;242m v2: Vector = Vector{components = [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m{[0m[38;2;190;132;255m4.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m6.0[0m[38;2;248;248;242m, [0m[38;2;190;132;255m8.0[0m[38;2;248;248;242m}};[0m
|
||||
[38;2;248;248;242m dist: [0m[3;38;2;102;217;239mf64[0m[38;2;248;248;242m = [0m[38;2;102;217;239meuclidean_distance[0m[38;2;248;248;242m(v1, v2);[0m
|
||||
[38;2;248;248;242m fmt.[0m[38;2;102;217;239mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mDistance:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m, dist);[0m
|
||||
[38;2;248;248;242m}[0m
|
27
tests/syntax-tests/source/Odin/test.odin
vendored
Normal file
27
tests/syntax-tests/source/Odin/test.odin
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import "core:fmt"
|
||||
import "core:math"
|
||||
|
||||
Vector :: struct {
|
||||
components: []f64,
|
||||
}
|
||||
|
||||
euclidean_distance :: proc(v1: Vector, v2: Vector) -> f64 {
|
||||
if len(v1.components) != len(v2.components) {
|
||||
panic("Vectors must be same dimension")
|
||||
}
|
||||
sum: f64 = 0.0;
|
||||
for i, comp in v1.components {
|
||||
diff := comp - v2.components[i];
|
||||
sum += diff * diff;
|
||||
}
|
||||
return math.sqrt(sum);
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
v1: Vector = Vector{components = []f64{1.0, 2.0, 3.0}};
|
||||
v2: Vector = Vector{components = []f64{4.0, 6.0, 8.0}};
|
||||
dist: f64 = euclidean_distance(v1, v2);
|
||||
fmt.println("Distance:", dist);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user