aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/node.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-08 12:34:47 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-09 16:01:39 +0100
commit8b1c270910fce13077864bf39d6e88971a6eb062 (patch)
tree2a441b58d46905f680749c1c074e9b55a27f0d6e /lib/xixanta/src/node.rs
parent4f5710aa516ab149d132cdb5863db08f08c10563 (diff)
downloadtools.nes-8b1c270910fce13077864bf39d6e88971a6eb062.tar.gz
tools.nes-8b1c270910fce13077864bf39d6e88971a6eb062.zip
Implement the .include statement
This needed some heavy lifting when it comes to how files were located. This means that statements like .include/.incbin now take into consideration a new list made out of SourceInfo, which holds enough information to translate from which file a node comes from. This has also been added into errors, so they are more informative on what went wrong. In order to tests this, besides all the regular unit tests, a new e2e test has been added. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/node.rs')
-rw-r--r--lib/xixanta/src/node.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs
index f919ade..1ec2ed9 100644
--- a/lib/xixanta/src/node.rs
+++ b/lib/xixanta/src/node.rs
@@ -140,6 +140,7 @@ pub enum ControlType {
IncBin,
StartRepeat,
EndRepeat,
+ IncludeSource,
}
impl fmt::Display for ControlType {
@@ -160,6 +161,7 @@ impl fmt::Display for ControlType {
ControlType::IncBin => write!(f, ".incbin"),
ControlType::StartRepeat => write!(f, ".repeat"),
ControlType::EndRepeat => write!(f, ".endrepeat"),
+ ControlType::IncludeSource => write!(f, ".include"),
}
}
}
@@ -305,7 +307,7 @@ impl NodeType {
}
}
-/// A Position Node. This is a node on a binary tree which holds a PString as a
+/// A Positioned Node. This is a node on a tree which holds a PString as a
/// value. The node type determines the actual representation of the value and
/// both childs (see the `NodeType` enum). Moreover, out of convenience, a node
/// also holds an optional list of arguments, which simplifies arrangements such
@@ -330,6 +332,10 @@ pub struct PNode {
/// Convenience list used by some node types in order to express a list of
/// optional arguments.
pub args: Option<Vec<PNode>>,
+
+ /// Index on the list of SourceInfo's maintained by both the parser and the
+ /// assembler.
+ pub source: usize,
}
/// Whether there is a body for a given node and whether it starts or ends it.