From dba769e13ca5029643c6068e53fa34ae0fea8421 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Fri, 28 Feb 2025 13:23:20 +1300 Subject: Implement string literals String literals are treated as integers. If a string is passed as an integer argument to a packed binary literal, a new instance of the packed binary literal is invoked for every character in the string, with each character being passed to the packed binary literal as a Unicode character value. --- src/parsers/semantic.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/parsers/semantic.rs') diff --git a/src/parsers/semantic.rs b/src/parsers/semantic.rs index a58fb5f..00cfc80 100644 --- a/src/parsers/semantic.rs +++ b/src/parsers/semantic.rs @@ -74,6 +74,9 @@ impl SemanticParser { let invocation = InvocationParser::new(name, syn.source, &mut self.tokens).parse(); self.body.push(SemanticToken::Invocation(invocation)); } + SynVar::PackedBinaryLiteral(pbl) => { + self.body.push(SemanticToken::Word(pbl)); + } _ => { let variant = SemanticParseErrorVariant::InvalidToken; let error = SemanticParseError { source: syn.source, variant }; @@ -283,6 +286,10 @@ impl<'a> InvocationParser<'a> { let value = Value::Integer(Integer::Literal(integer)); Some(ArgumentInvocation { source, value }) } + SynVar::String(string) => { + let value = Value::Integer(Integer::String(string)); + Some(ArgumentInvocation { source, value }) + } SynVar::Expression(expr) => { let value = Value::Integer(Integer::Expression(expr)); Some(ArgumentInvocation { source, value }) -- cgit v1.2.3-70-g09d2