Add support for commenting out lines
This commit is contained in:
parent
237a1fae31
commit
80f4556786
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue