From a051139f6d59cbc77eff99e9417dc21d87eaba6a Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Mon, 13 Oct 2025 16:02:33 +1300 Subject: Change string argument syntax to list argument syntax Changes string arguments from "name" to [name], to prepare for generic lists in the language. Doesn't compile. --- src/stages/semantic.rs | 17 ++++++++++++----- src/stages/semantic_tokens.rs | 8 ++++---- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/stages/semantic.rs b/src/stages/semantic.rs index eb9e7b6..b72cfa8 100644 --- a/src/stages/semantic.rs +++ b/src/stages/semantic.rs @@ -431,11 +431,13 @@ impl SemanticParser { let token = self.syntactic.pop()?; let source = token.source; match token.value { + // Integer-type argument. SyntacticToken::Symbol(ScopedSymbol::Global(name)) => { let variant = ArgumentType::Integer; let definition = ArgumentDefinition { name, variant }; return Some(Tracked::from(definition, source)); } + // Block-type argument. SyntacticToken::BlockLiteral(mut tokens) => { if tokens.len() == 1 { let token = tokens.pop().unwrap(); @@ -446,11 +448,16 @@ impl SemanticParser { } } } - SyntacticToken::StringLiteral(string) => { - let variant = ArgumentType::String; - let name = string.string; - let definition = ArgumentDefinition { name, variant }; - return Some(Tracked::from(definition, source)); + // List-type argument. + SyntacticToken::Expression(mut tokens) => { + if tokens.len() == 1 { + let token = tokens.pop().unwrap(); + if let SyntacticToken::Symbol(ScopedSymbol::Global(name)) = token.value { + let variant = ArgumentType::List; + let definition = ArgumentDefinition { name, variant }; + return Some(Tracked::from(definition, source)); + } + } } _ => (), }; diff --git a/src/stages/semantic_tokens.rs b/src/stages/semantic_tokens.rs index f112f7f..95a7f21 100644 --- a/src/stages/semantic_tokens.rs +++ b/src/stages/semantic_tokens.rs @@ -21,7 +21,7 @@ pub struct ArgumentDefinition { pub enum ArgumentType { Integer, Block, - String, + List, } impl std::fmt::Display for ArgumentType { @@ -29,7 +29,7 @@ impl std::fmt::Display for ArgumentType { match self { ArgumentType::Integer => write!(f, "an integer"), ArgumentType::Block => write!(f, "a block"), - ArgumentType::String => write!(f, "a string"), + ArgumentType::List => write!(f, "a list"), } } } @@ -216,8 +216,8 @@ fn print_argument_definition(i: usize, argument: &ArgumentDefinition) { ArgumentType::Block => { indent!(i, "Argument({}, block)", argument.name) } - ArgumentType::String => { - indent!(i, "Argument({}, string)", argument.name) + ArgumentType::List => { + indent!(i, "Argument({}, list)", argument.name) } } } -- cgit v1.2.3-70-g09d2