diff options
| author | tyropro <[email protected]> | 2026-05-22 22:14:23 +0100 |
|---|---|---|
| committer | tyropro <[email protected]> | 2026-05-22 22:15:15 +0100 |
| commit | 933605e7db844f695ca2471451518f2828324682 (patch) | |
| tree | ea60b0459b5bd6fbc55aacaf13a256d4af035016 | |
| parent | e853164a0cd623fc2f643689883442ddfb3622c0 (diff) | |
fix: added parity with lmc interpreter at https://peterhigginson.co.uk/lmc/
| -rw-r--r-- | src/main.rs | 2 | ||||
| -rw-r--r-- | src/parser.rs | 15 |
2 files changed, 5 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index 1629b26..34f7bde 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,5 +13,7 @@ fn main() { let instructions = parser::parse_file(file_contents.trim().to_string()); + parser::print_opcodes(&instructions); + interpreter::interpret(&instructions).unwrap(); } diff --git a/src/parser.rs b/src/parser.rs index 544e3ed..0b968d4 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -138,7 +138,8 @@ fn syntax_analysis(tokens: &Vec<Token>) -> Result<(), ()> { | Mnemonic::BranchPositive
| Mnemonic::BranchZero
| Mnemonic::Load
- | Mnemonic::Save => {
+ | Mnemonic::Save
+ | Mnemonic::Dat => {
if i + 1 < tokens.len() {
match tokens[i + 1] {
Token::Parameter(_) => (),
@@ -146,17 +147,6 @@ fn syntax_analysis(tokens: &Vec<Token>) -> Result<(), ()> { }
}
}
- Mnemonic::Dat => {
- if i + 1 < tokens.len() {
- match &tokens[i + 1] {
- Token::Parameter(param) => match param {
- Parameter::Literal(_) => (),
- Parameter::Label(_) => return Err(()),
- },
- _ => return Err(()),
- }
- }
- }
Mnemonic::Halt | Mnemonic::Input | Mnemonic::Output => {
if i + 1 < tokens.len() {
match tokens[i + 1] {
@@ -196,6 +186,7 @@ fn syntax_analysis(tokens: &Vec<Token>) -> Result<(), ()> { match tokens[i + 1] {
Token::Mnemonic(_) => (),
Token::Label(_) => (),
+ Token::LineBreak => (),
_ => return Err(()),
}
}
|
