diff --git a/README.md b/README.md index f661de9..f0ee820 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,4 @@ export def cmat { - [ ] Figure out reusing functions across exported functions - [x] Comments - [ ] Anonyms functions + - [ ] Label keyword \ No newline at end of file diff --git a/bin/keyboard.dm42 b/bin/keyboard.dm42 index b594957..9a9651d 100644 --- a/bin/keyboard.dm42 +++ b/bin/keyboard.dm42 @@ -1,12 +1,26 @@ -// Lets you use your calculator to compose scores of utmost beauty. - +// Lets you use your calculator to compose scores of utmost elegance. export def key { - GETKEY + GETKEY1 STO 00 - if { } >= { 10 } { + + // Exit if key 33 is pressed (EXIT) + if { DUP } == { 33 } { + DROP + STOP + } + + // Play tone 0 if key 10 is pressed (SIN) + if { DUP } == { 10 } { + DROP TONE 0 GTO key } + + // Do nothing if other keys are pressed + if { } > { 10 } { + GTO key + } + TONE IND 00 GTO key } diff --git a/src/tokenize.rs b/src/tokenize.rs index d906fda..96b0fbe 100644 --- a/src/tokenize.rs +++ b/src/tokenize.rs @@ -48,7 +48,7 @@ impl Tokenizer { // Comments if self.idx + 2 < self.chars.len() && &self.chars[self.idx..self.idx + 2] == &['/', '/'] { - while self.chars[self.idx] != '\n' { + while self.idx < self.chars.len() && self.chars[self.idx] != '\n' { self.idx += 1; } self.skip_whitespace();