From fcd4c9a267b407e653ed6b21ae87f219f3e4c4af Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 18 Aug 2026 16:39:37 +0200 Subject: Add global labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- lib/xixanta/src/node.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/xixanta/src/node.rs') 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 { -- cgit v1.2.3