[fine] Remember to use this function
This commit is contained in:
parent
723b231b0d
commit
5f67aa72d5
1 changed files with 2 additions and 19 deletions
|
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
parser::{Child, SyntaxTree, Tree, TreeKind, TreeRef},
|
parser::{Child, SyntaxTree, Tree, TreeKind, TreeRef},
|
||||||
semantics::{Declaration, Environment, Location, Semantics, Type},
|
semantics::{string_constant_to_string, Declaration, Environment, Location, Semantics, Type},
|
||||||
tokens::TokenKind,
|
tokens::TokenKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -330,24 +330,7 @@ fn compile_literal(c: &mut Compiler, t: TreeRef, tr: &Tree) -> CR {
|
||||||
Instruction::PushFalse
|
Instruction::PushFalse
|
||||||
}),
|
}),
|
||||||
Type::String => {
|
Type::String => {
|
||||||
let mut result = String::new();
|
let result = string_constant_to_string(tok.as_str());
|
||||||
let mut input = tok.as_str().chars();
|
|
||||||
while let Some(ch) = input.next() {
|
|
||||||
if ch == '\\' {
|
|
||||||
if let Some(ch) = input.next() {
|
|
||||||
match ch {
|
|
||||||
'n' => result.push('\n'),
|
|
||||||
'r' => result.push('\r'),
|
|
||||||
't' => result.push('\t'),
|
|
||||||
_ => result.push(ch),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.push(ch)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.push(ch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let index = c.add_string(result);
|
let index = c.add_string(result);
|
||||||
c.push(Instruction::PushString(index))
|
c.push(Instruction::PushString(index))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue