aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xixanta')
-rw-r--r--lib/xixanta/src/assembler.rs11
-rw-r--r--lib/xixanta/src/parser.rs4
2 files changed, 6 insertions, 9 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs
index 32d7c14..851f3c3 100644
--- a/lib/xixanta/src/assembler.rs
+++ b/lib/xixanta/src/assembler.rs
@@ -1659,15 +1659,8 @@ impl<'a> Assembler<'a> {
let string = self.fetch_quoted_first_argument(node)?;
for ch in string.chars() {
- if !ch.is_ascii() {
- return Err(Error {
- line: node.value.line,
- message: "string can only contain ASCII characters".to_string(),
- source: self.source_for(node),
- global: false,
- });
- }
-
+ // NOTE: the parser guarantees that a string literal only contains
+ // ASCII characters.
self.push_bundle(Bundle::fill(ch as u8), node)?;
}
self.push_bundle(Bundle::fill(0x00), node)?;
diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs
index d42ff12..524f7c2 100644
--- a/lib/xixanta/src/parser.rs
+++ b/lib/xixanta/src/parser.rs
@@ -902,6 +902,10 @@ impl Parser {
// character (unless it was escaped through '\').
let mut prev = '"';
for ch in line.get(self.offset..).unwrap_or("").chars() {
+ if !ch.is_ascii() {
+ return Err(self.parser_error("using non-ASCII characters in a string"));
+ }
+
if ch == '"' && prev != '\\' {
self.next();