summaryrefslogtreecommitdiff
path: root/src/parsers/semantic.rs
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-02-28 13:23:20 +1300
committerBen Bridle <ben@derelict.engineering>2025-02-28 13:34:23 +1300
commitdba769e13ca5029643c6068e53fa34ae0fea8421 (patch)
tree47b45ecddaf08bcef19de29ad65206c34af85f53 /src/parsers/semantic.rs
parent1a810d036195395c182f6cd6e011b8fb868d9872 (diff)
downloadtorque-asm-dba769e13ca5029643c6068e53fa34ae0fea8421.zip
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.
Diffstat (limited to 'src/parsers/semantic.rs')
-rw-r--r--src/parsers/semantic.rs7
1 files changed, 7 insertions, 0 deletions
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 })