diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-08-18 16:39:37 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-08-18 16:39:37 +0200 |
| commit | fcd4c9a267b407e653ed6b21ae87f219f3e4c4af (patch) | |
| tree | 0b5f3e9bf99ab7377fa0bb6d204661ac8fbe3380 /lib/xixanta/src/node.rs | |
| parent | d479b0fbd3778f5b6fc8b63f46aa0c5364e4fe7e (diff) | |
| download | tools.nes-fcd4c9a267b407e653ed6b21ae87f219f3e4c4af.tar.gz tools.nes-fcd4c9a267b407e653ed6b21ae87f219f3e4c4af.zip | |
Add global labels
These are labels that are declared by prefixing a '#' symbol to the
name, and it allows the label to be declared at the global scope instead
of the current one.
This is a feature which is not to be abused so to not make scopes
pointless, but it can be quite handy with some optimizations while not
abandoning scopes completely.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib/xixanta/src/node.rs')
| -rw-r--r-- | lib/xixanta/src/node.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs index 649f333..357b9e0 100644 --- a/lib/xixanta/src/node.rs +++ b/lib/xixanta/src/node.rs @@ -319,8 +319,10 @@ pub enum NodeType { /// '$'. The `left` node contains the inner expression. Literal, - /// A label statement, which only sets the `value`, the name of the label. - Label, + /// A label statement, which only sets the `value`, the name of the + /// label. If the inner boolean is true, then the label is considered to be + /// global, otherwise scopes apply. + Label(bool), /// A macro call. Note that a Value might also encode this, but when a Call /// has been detected, then there is no doubt on it. @@ -347,7 +349,8 @@ impl fmt::Display for NodeType { NodeType::Control(control_type) => write!(f, "control function ({control_type})"), NodeType::ControlBody => write!(f, "control function body"), NodeType::Literal => write!(f, "literal"), - NodeType::Label => write!(f, "label"), + NodeType::Label(true) => write!(f, "(global) label"), + NodeType::Label(false) => write!(f, "(scoped) label"), NodeType::Call => write!(f, "call"), NodeType::Fallthrough => write!(f, "fallthrough"), NodeType::Operation(op) => match op { |
