Skip to content

Commit

Permalink
added vim highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
nic-gaffney committed Jun 27, 2023
1 parent 54a2023 commit 8c9bd55
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
50 changes: 30 additions & 20 deletions examples/mandelbrot.sloth
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 1 addition & 0 deletions vim/ftdetect.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
au BufRead,BufNewFile *.sloth set filetype=sloth
8 changes: 8 additions & 0 deletions vim/syntax.vim
Original file line number Diff line number Diff line change
@@ -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 "#.*"

0 comments on commit 8c9bd55

Please sign in to comment.