diff --git a/src/sasm.rs b/src/sasm.rs index 430c67f..3bbc7b9 100644 --- a/src/sasm.rs +++ b/src/sasm.rs @@ -11,6 +11,7 @@ pub fn sasm_read(s: String) -> Words { pub fn sasm_read_func<'a>(lines: &mut impl Iterator) -> Words { let mut words = Vec::new(); while let Some(line) = lines.next() { + let line = line.trim_start(); if line == "end" { break; } @@ -20,7 +21,7 @@ pub fn sasm_read_func<'a>(lines: &mut impl Iterator) -> Words { } fn sasm_parse<'a>(line: &str, words: &mut Vec, lines: &mut impl Iterator) { - let line: Vec<_> = line.trim_start().split(" ").collect(); + let line: Vec<_> = line.split(" ").collect(); match line[0] { "dump" => words.push(Word::Key(Keyword::Dump)), "def" => words.push(Word::Key(Keyword::Def(line[1].to_owned()))), diff --git a/test.sasm b/test.sasm index 212985a..7c99922 100644 --- a/test.sasm +++ b/test.sasm @@ -4,5 +4,34 @@ func main 1 Hello, world! end HW call println + call test const mega 3 end + +func test 0 + call [ + const func 5 + const mega 0 + const mega 1 + const mega 2 + const mega 3 + const mega 4 + end + call call + call ] + objcall iter + objpush + const func 1 + const mega 5 + call * + end + objpop + objcall map + objpush + const func 0 + call _str + call println + end + objpop + objcall foreach +end