Compare commits

..

No commits in common. "c6906a65c411df66b98d28a92cecb53afab70464" and "ca1d67a54a028cf4f423d15d48e4e4ae68f4f48a" have entirely different histories.

2 changed files with 35 additions and 40 deletions

View File

@ -8,7 +8,7 @@ if exists("b:current_syntax")
endif endif
syn keyword Keyword break return let fn loop if else struct import or and not while for in mod pub syn keyword Keyword break return let fn loop if else struct import or and not while for in
syn keyword Special null syn keyword Special null
syn keyword Type int string bool syn keyword Type int string bool
syn keyword Boolean true false syn keyword Boolean true false
@ -48,7 +48,6 @@ syn match Comment "//.*$" contains=Todo
syn region Comment start=+/\*+ end=+\*/+ contains=Todo syn region Comment start=+/\*+ end=+\*/+ contains=Todo
syn match Identifier '[a-z_]\w*' syn match Identifier '[a-z_]\w*'
syn match Type '[A-Z]\w*' syn match Type '[A-Z]\w*'
@ -58,8 +57,4 @@ syn match Function ' \zs[a-zA-Z_]\w*\ze\s\{-}<.\{-}>\s\{-}(.\{-})'
syn region sligeBlock start="{" end="}" transparent fold syn region sligeBlock start="{" end="}" transparent fold
syn region sligeAnno start="#!\?\[" end="]" contains=Identifier,Type
hi def link sligeAnno PreProc
let b:current_syntax = "slige" let b:current_syntax = "slige"

View File

@ -2,59 +2,59 @@
// stdlib.slg // stdlib.slg
#[builtin(Exit)] #[builtin(Exit)]
pub fn exit(status_code: int) {} fn exit(status_code: int) {}
#[builtin(Print)] #[builtin(Print)]
pub fn print(msg: string) {} fn print(msg: string) {}
msg + "\n" msg + "\n"
pub fn println(msg: string) { print) } fn println(msg: string) { print) }
#[builtin(IntToString)] #[builtin(IntToString)]
pub fn int_to_string(number: int) -> string {} fn int_to_string(number: int) -> string {}
#[builtin(StringPushChar)] #[builtin(StringPushChar)]
pub fn string_push_char(str: string, value: int) -> string {} fn string_push_char(str: string, value: int) -> string {}
#[builtin(StringCharAt)] #[builtin(StringCharAt)]
pub fn string_char_at(str: string, index: int) -> int {} fn string_char_at(str: string, index: int) -> int {}
#[builtin(StringLength)] #[builtin(StringLength)]
pub fn string_length(str: string) -> int {} fn string_length(str: string) -> int {}
#[builtin(StringToInt)] #[builtin(StringToInt)]
pub fn string_to_int(str: string) -> int {} fn string_to_int(str: string) -> int {}
#[builtin(ArrayNew)] #[builtin(ArrayNew)]
pub fn array_new<T>() -> [T] {} fn array_new<T>() -> [T] {}
#[builtin(ArrayPush)] #[builtin(ArrayPush)]
pub fn array_push<T>(array: [T], value: T) {} fn array_push<T>(array: [T], value: T) {}
#[builtin(ArrayLength)] #[builtin(ArrayLength)]
pub fn array_length<T>(array: [T]) -> int {} fn array_length<T>(array: [T]) -> int {}
#[builtin(ArrayAt)] #[builtin(ArrayAt)]
pub fn array_at<T>(array: [T], index: int) -> T {} fn array_at<T>(array: [T], index: int) -> T {}
#[builtin(FileOpen)] #[builtin(FileOpen)]
pub fn file_open(filename: string, mode: string) -> int {} fn file_open(filename: string, mode: string) -> int {}
#[builtin(FileClose)] #[builtin(FileClose)]
pub fn file_close(file: int) {} fn file_close(file: int) {}
#[builtin(FileWriteString)] #[builtin(FileWriteString)]
pub fn file_write_string(file: int, content: string) -> int {} fn file_write_string(file: int, content: string) -> int {}
#[builtin(FileReadChar)] #[builtin(FileReadChar)]
pub fn file_read_char(file: int) -> int {} fn file_read_char(file: int) -> int {}
#[builtin(FileReadToString)] #[builtin(FileReadToString)]
pub fn file_read_to_string(file: int) -> string {} fn file_read_to_string(file: int) -> string {}
#[builtin(FileFlush)] #[builtin(FileFlush)]
pub fn file_flush(file: int) {} fn file_flush(file: int) {}
#[builtin(FileEof)] #[builtin(FileEof)]
pub fn file_eof(file: int) -> bool {} fn file_eof(file: int) -> bool {}
#[builtin(IntToString)] #[builtin(IntToString)]
pub fn itos(number: int) -> string {} fn itos(number: int) -> string {}
#[builtin(StringToInt)] #[builtin(StringToInt)]
pub fn stoi(str: string) -> int {} fn stoi(str: string) -> int {}
pub fn stdin() -> int { 0 } fn stdin() -> int { 0 }
pub fn stdout() -> int { 1 } fn stdout() -> int { 1 }
pub fn stderr() -> int { 2 } fn stderr() -> int { 2 }
pub fn file_read_line(file: int) -> string { fn file_read_line(file: int) -> string {
let line = ""; let line = "";
loop { loop {
if file_eof(file) { if file_eof(file) {
@ -69,20 +69,20 @@ pub fn file_read_line(file: int) -> string {
line line
} }
pub fn read_text_file(filename: string) -> string { fn read_text_file(filename: string) -> string {
let file = file_open(filename, "r"); let file = file_open(filename, "r");
let text = file_read_to_string(file); let text = file_read_to_string(file);
file_close(file); file_close(file);
text text
} }
pub fn input(prompt: string) -> string { fn input(prompt: string) -> string {
print("> "); print("> ");
file_flush(stdout()); file_flush(stdout());
file_read_line(stdin()) file_read_line(stdin())
} }
pub fn string_abs(number: int) -> int { fn string_abs(number: int) -> int {
let result = number; let result = number;
if number < 0 { if number < 0 {
result = number - (number * 2); result = number - (number * 2);
@ -90,7 +90,7 @@ pub fn string_abs(number: int) -> int {
result result
} }
pub fn string_split(str: string, seperator: int) -> [string] { fn string_split(str: string, seperator: int) -> [string] {
let result = array_new::<string>(); let result = array_new::<string>();
let i = 0; let i = 0;
@ -112,7 +112,7 @@ pub fn string_split(str: string, seperator: int) -> [string] {
result result
} }
pub fn string_slice(str: string, from: int, to: int) -> string { fn string_slice(str: string, from: int, to: int) -> string {
let result = ""; let result = "";
let i = from; let i = from;
loop { loop {
@ -128,7 +128,7 @@ pub fn string_slice(str: string, from: int, to: int) -> string {
result result
} }
pub fn string_contains(str: string, ch: int) -> bool { fn string_contains(str: string, ch: int) -> bool {
let len = string_length(str); let len = string_length(str);
for (let i = 0; i < len; i += 1) { for (let i = 0; i < len; i += 1) {
if str[i] == ch { if str[i] == ch {
@ -138,7 +138,7 @@ pub fn string_contains(str: string, ch: int) -> bool {
false false
} }
pub fn array_clone<T>(array: [T]) -> [T] { fn array_clone<T>(array: [T]) -> [T] {
let len = array_length(array); let len = array_length(array);
let result = array_new::<T>(); let result = array_new::<T>();
let i = 0; let i = 0;
@ -150,7 +150,7 @@ pub fn array_clone<T>(array: [T]) -> [T] {
result result
} }
pub fn array_sort_mut(array: [int]) { fn array_sort_mut(array: [int]) {
let len = array_length(array); let len = array_length(array);
for (let i = 0; i < len; i += 1) { for (let i = 0; i < len; i += 1) {
for (let j = i + 1; j < len; j += 1) { for (let j = i + 1; j < len; j += 1) {
@ -163,7 +163,7 @@ pub fn array_sort_mut(array: [int]) {
} }
} }
pub fn array_to_sorted(array: [int]) -> [int] { fn array_to_sorted(array: [int]) -> [int] {
let cloned = array_clone(array); let cloned = array_clone(array);
array_sort_mut(array); array_sort_mut(array);
cloned cloned