diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2025-02-12 10:14:15 +1300 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2025-02-12 10:14:15 +1300 |
commit | 1995f8a8f2cb5ea810afc173fe8dfa2f5355f684 (patch) | |
tree | f3aaa305f82fb7d424b59527e713ac781e5fa723 /src/tokens | |
parent | ce47e3b24ea37748b809cb5c53b217b6474e0fd3 (diff) | |
download | torque-asm-1995f8a8f2cb5ea810afc173fe8dfa2f5355f684.zip |
Separate syntactic and semantic token types by namespace
This will allow type names to be shared by both types of token.
Diffstat (limited to 'src/tokens')
-rw-r--r-- | src/tokens/mod.rs | 6 | ||||
-rw-r--r-- | src/tokens/syntactic.rs | 14 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/tokens/mod.rs b/src/tokens/mod.rs index 65f361c..edb7c19 100644 --- a/src/tokens/mod.rs +++ b/src/tokens/mod.rs @@ -1,8 +1,6 @@ -mod syntactic; -pub use syntactic::*; +pub mod syntactic; -mod semantic; -pub use semantic::*; +pub mod semantic; mod constant_expression; pub use constant_expression::*; diff --git a/src/tokens/syntactic.rs b/src/tokens/syntactic.rs index 000d178..162f1c0 100644 --- a/src/tokens/syntactic.rs +++ b/src/tokens/syntactic.rs @@ -1,12 +1,12 @@ use crate::*; -pub struct SyntacticToken { +pub struct Token { pub source: SourceSpan, - pub variant: SyntacticTokenVariant, + pub variant: TokenVariant, } -pub enum SyntacticTokenVariant { +pub enum TokenVariant { LabelDefinition(String), MacroDefinition(String), MacroDefinitionTerminator, @@ -24,11 +24,11 @@ pub enum SyntacticTokenVariant { Symbol(String), - Error(SyntacticParseError), + Error(ParseError), } #[derive(Debug)] -pub enum SyntacticParseError { +pub enum ParseError { InvalidHexadecimalLiteral(String), InvalidSymbolIdentifier(String), UnterminatedComment, @@ -36,9 +36,9 @@ pub enum SyntacticParseError { } -impl std::fmt::Debug for SyntacticToken { +impl std::fmt::Debug for Token { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - use SyntacticTokenVariant::*; + use TokenVariant::*; let start = &self.source.in_merged; let name = match &self.variant { LabelDefinition(name) => format!("LabelDefinition({name})"), |