-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add assembly SourceLocation & SourceToken
This commit introduces new data structures that will associate metadata with a token. The introduced SourceLocation struct will allow the link between a source path; either from a library or a disk MASM file, into a parsed token - hence, also to its Instruction, Operation, and AST location. SourceLocation is split from SourceToken because the former is intended to be used globally, and the latter is specific to the parsing process. related issue: #857
- Loading branch information
Showing
4 changed files
with
207 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SOURCE LOCATION | ||
// ================================================================================================ | ||
|
||
/// A struct containing information about the location of a source item. | ||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct SourceLocation { | ||
line: u32, | ||
column: u32, | ||
} | ||
|
||
impl SourceLocation { | ||
|
||
// CONSTRUCTORS | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
/// Creates a new instance of [SourceLocation]. | ||
pub const fn new(line: u32, column: u32) -> Self { | ||
Self { line, column } | ||
} | ||
|
||
// PUBLIC ACCESSORS | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
/// Returns the line of the location. | ||
pub const fn line(&self) -> u32 { | ||
self.line | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.