diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-10-29 14:49:44 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-12 07:54:51 +0100 |
| commit | d2d6d90acf2e9a8ccb4cbcec619d2a0d49cd462a (patch) | |
| tree | e3c7c11f4ca78d9202a6f85b6fff30a5552baa18 /lib/xixanta/src/node.rs | |
| parent | e9f149a590b019a0c2f55d1fb407461df1119ff2 (diff) | |
| download | tools.nes-d2d6d90acf2e9a8ccb4cbcec619d2a0d49cd462a.tar.gz tools.nes-d2d6d90acf2e9a8ccb4cbcec619d2a0d49cd462a.zip | |
Don't rely on the identifier for control identity
Instead, use a new enum type to identify the control statements that we
actually support. This way the assembler is more easily aware on the
control that it's dealing with, and can be more sure on certain aspects
of the implementation on control support.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/node.rs')
| -rw-r--r-- | lib/xixanta/src/node.rs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs index a28d625..c787394 100644 --- a/lib/xixanta/src/node.rs +++ b/lib/xixanta/src/node.rs @@ -82,6 +82,24 @@ impl PString { } } +/// The type of control function being used. Use this enum in order to detect +/// which control function was detected instead of the node value. +#[derive(Debug, Clone, PartialEq)] +pub enum ControlType { + Hibyte, + Lobyte, + StartMacro, + EndMacro, + StartProc, + EndProc, + StartScope, + EndScope, + Segment, + Byte, + Word, + Addr, +} + /// The PNode type. #[derive(Debug, Clone, PartialEq)] pub enum NodeType { @@ -106,10 +124,12 @@ pub enum NodeType { Assignment, /// A control statement (e.g. ".proc foo"). The `value` string contains the - /// name of the function, the `left` an optional identifier (e.g. the "foo" - /// on ".proc foo"), and the `args` contain any possible arguments that have - /// been passed to this control statement. - Control, + /// name of the function as it was provided (use the `ControlType` value of + /// the enum to detect which function was exactly provided), the `left` an + /// optional identifier (e.g. the "foo" on ".proc foo"), and the `args` + /// contain any possible arguments that have been passed to this control + /// statement. + Control(ControlType), /// A literal expression, that is, something that starts with '#', '%' or /// '$'. The `left` node contains the inner expression. @@ -130,7 +150,7 @@ impl fmt::Display for NodeType { NodeType::Instruction => write!(f, "instruction"), NodeType::Indirection => write!(f, "indirection"), NodeType::Assignment => write!(f, "assignment"), - NodeType::Control => write!(f, "control function"), + NodeType::Control(_) => write!(f, "control function"), NodeType::Literal => write!(f, "literal"), NodeType::Label => write!(f, "label"), NodeType::Call => write!(f, "call"), |
