aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornic-gaffney <gaffney_nic@protonmail.com>2023-06-26 21:29:43 -0500
committernic-gaffney <gaffney_nic@protonmail.com>2023-06-26 21:29:43 -0500
commit8c9bd55e161ba5fcaea626a1db2e0b685ac4f096 (patch)
tree998dba9c480ca1342b3bf5d4fd418848577ac563
parent54a2023adac82dc2d25c7de3eb5c5d54a9c0e83a (diff)
downloadsloth-8c9bd55e161ba5fcaea626a1db2e0b685ac4f096.tar.gz
added vim highlighting
-rw-r--r--examples/mandelbrot.sloth50
-rw-r--r--vim/ftdetect.vim1
-rw-r--r--vim/syntax.vim8
3 files changed, 39 insertions, 20 deletions
diff --git a/examples/mandelbrot.sloth b/examples/mandelbrot.sloth
index fb22b88..f9ebdc8 100644
--- a/examples/mandelbrot.sloth
+++ b/examples/mandelbrot.sloth
@@ -1,24 +1,34 @@
-val size: Int = 200;
-val maxVal: Float = 4.0;
-val maxIter: Int = 50;
-val plane: Float = 4.0;
+foreign fn termpos(x: Int, y: Int);
+foreign fn print(str: String);
-for x in 0 .. size {
- for y in 0 .. size {
- var cReal: Float = (x * plane / size) - 2;
- var cImg: Float = (y * plane / size) - 2;
- var zReal: Float = 0;
- var zImg: Float = 0;
- var count: Float = 0;
- while (zReal * zReal + zImg * zImg) <= maxVal && count < 4{
- var temp: Float = (zReal * zReal) - (zImg * zImg) + cReal;
- zImg = 2 * zReal * zImg + cImg;
- zReal = temp;
- count += 1;
- }
- if count == maxIter {
- termpos(x, y);
- print("*");
+fn main() Int{
+ var size: Float = 200.0;
+ var maxVal: Float = 4.0;
+ var maxIter: Int = 50;
+ var plane: Float = 4.0;
+ # lmao
+ var x: Int = 0;
+ while x < size {
+ var y: Int = 0;
+ while y < size {
+ var cReal: Float = (x * plane / size) - 2.0;
+ var cImg: Float = (y * plane / size) - 2.0;
+ var zReal: Float = 0.0;
+ var zImg: Float = 0.0;
+ var count: Int = 0;
+ while (zReal * zReal + zImg * zImg) <= maxVal && count < 4{
+ var temp: Float = (zReal * zReal) - (zImg * zImg) + cReal;
+ zImg = 2.0 * zReal * zImg + cImg;
+ zReal = temp;
+ count = count + 1;
+ }
+ if count == maxIter {
+ termpos(x, y);
+ print("*");
+ }
+ y = y + 1;
}
+ x = x + 1;
}
+ return 0;
}
diff --git a/vim/ftdetect.vim b/vim/ftdetect.vim
new file mode 100644
index 0000000..c19a7ca
--- /dev/null
+++ b/vim/ftdetect.vim
@@ -0,0 +1 @@
+au BufRead,BufNewFile *.sloth set filetype=sloth
diff --git a/vim/syntax.vim b/vim/syntax.vim
new file mode 100644
index 0000000..af0f062
--- /dev/null
+++ b/vim/syntax.vim
@@ -0,0 +1,8 @@
+:syntax keyword Statement while fn foreign fn var if else return as in
+:syntax keyword Type Int String Float Void Bool
+:syntax match Number '[1234567890]'
+:syntax match Operator '[+ \- \* \/ <= == >= &&]'
+:syntax region String start=+"+ skip=+\\+ end=+"+
+:syntax match paren "("
+:syntax match Function "\w\+\s*(" contains=paren
+:syntax match Comment "#.*"