diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-09-26 15:53:57 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-12 07:41:30 +0100 |
| commit | 184c39579227c0add80a61d489c242120001d6b6 (patch) | |
| tree | 48737e0e00b5fb655090a1c9a4fc216dcf278cc0 /lib/xixanta/src/opcodes.rs | |
| parent | 54e1239fcccb2383e5caa88844a7229b5441c31e (diff) | |
| download | tools.nes-184c39579227.tar.gz tools.nes-184c39579227.zip | |
Re-work the parser from scratch
The initial implementation was incredibly naive on how complex an
assembler can actually be. Because of this, it never bothered to define
and produce a proper AST, and hence it was overall extremely fragile on
(not so) corner cases.
This commit re-writes everything from scratch for the parser, and it
should really be the last fundamental change to the parser other than
minor additions/features here and there.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/opcodes.rs')
| -rw-r--r-- | lib/xixanta/src/opcodes.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/xixanta/src/opcodes.rs b/lib/xixanta/src/opcodes.rs index a716545..e849126 100644 --- a/lib/xixanta/src/opcodes.rs +++ b/lib/xixanta/src/opcodes.rs @@ -19,6 +19,12 @@ pub struct Entry { pub affected_on_page: bool, } +#[derive(Debug)] +pub struct Control { + pub has_identifier: bool, + pub required_args: Option<usize>, +} + lazy_static! { pub static ref INSTRUCTIONS: HashMap<String, HashMap<AddressingMode, ShortEntry>> = { let mut instrs = HashMap::new(); @@ -669,4 +675,25 @@ lazy_static! { opcodes }; + + pub static ref CONTROL_FUNCTIONS: HashMap<String, Control> = { + let mut functions = HashMap::new(); + + functions.insert(String::from(".hibyte"), Control { has_identifier: false, required_args: Some(1) }); + functions.insert(String::from(".lobyte"), Control { has_identifier: false, required_args: Some(1) }); + functions.insert(String::from(".macro"), Control { has_identifier: true, required_args: None }); + functions.insert(String::from(".proc"), Control { has_identifier: true, required_args: Some(0) }); + functions.insert(String::from(".scope"), Control { has_identifier: true, required_args: Some(0) }); + functions.insert(String::from(".end"), Control { has_identifier: false, required_args: Some(0) }); + functions.insert(String::from(".endscope"), Control { has_identifier: false, required_args: Some(0) }); + functions.insert(String::from(".endproc"), Control { has_identifier: false, required_args: Some(0) }); + functions.insert(String::from(".endmacro"), Control { has_identifier: false, required_args: Some(0) }); + functions.insert(String::from(".segment"), Control { has_identifier: false, required_args: Some(1) }); + functions.insert(String::from(".byte"), Control { has_identifier: false, required_args: None }); + functions.insert(String::from(".db"), Control { has_identifier: false, required_args: None }); + functions.insert(String::from(".word"), Control { has_identifier: false, required_args: None }); + functions.insert(String::from(".dw"), Control { has_identifier: false, required_args: None }); + + functions + }; } |
