diff --git a/README.md b/README.md index 58ecf82..806236f 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ The currently available opcodes are as follows: - `p` - print out the arguments: `pHello World!` prints "Hello World!" - `a`, `s`, `m`, `d` - add, subtract, multiply, and divide, respectively: `a2-2` adds 2 + 2. - `l` - declare a variable: `lv9` declares variable `v` with value `9`; doing `p$v` prints out 9. +- `#` - comment: the interpreter will skip this line. Here's an example "Hello world" program: @@ -58,7 +59,7 @@ Read [this guide](https://git-send-email.io) for more information. - [x] Better documentation - [ ] Ability to explicitly print math output and assign math output to variables -- [ ] Add support for comments (should be pretty easy) +- [x] Add support for comments (should be pretty easy) - [ ] Unit testing and CI/CD ## License diff --git a/src/main.rs b/src/main.rs index 05416eb..4905d78 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,6 +88,7 @@ impl Program { 'm' => println!("{}", eval::do_math(self.args_or_vars(arguments), '*')), 'd' => println!("{}", eval::do_math(self.args_or_vars(arguments), '/')), 'l' => self.add_var(arguments), + '#' => {}, // Do nothing for comments _ => panic!("SyntaxError: No such opcode: {}", self.pc) } }