@@ -334,9 +334,7 @@ impl Executor {
334
334
// Push bool value on the stack
335
335
self . stack . push ( Type :: Bool ( token. parse ( ) . unwrap_or ( true ) ) ) ;
336
336
} else if chars[ 0 ] == '(' && chars[ chars. len ( ) - 1 ] == ')' {
337
- // Push string value on the stack
338
- self . stack
339
- . push ( Type :: String ( token[ 1 ..token. len ( ) - 1 ] . to_string ( ) ) ) ;
337
+ // Processing string escape
340
338
let string = {
341
339
let mut buffer = String :: new ( ) ; // Temporary storage
342
340
let mut brackets = 0 ; // String's nest structure
@@ -382,12 +380,6 @@ impl Executor {
382
380
'r' => buffer. push_str ( "\\ r" ) ,
383
381
_ => buffer. push ( c) ,
384
382
}
385
- buffer. push ( match c {
386
- 'n' => '\n' ,
387
- 't' => '\t' ,
388
- 'r' => '\r' ,
389
- _ => c,
390
- } )
391
383
} else {
392
384
buffer. push ( c) ;
393
385
}
@@ -402,10 +394,8 @@ impl Executor {
402
394
}
403
395
}
404
396
buffer
405
- } ;
397
+ } ; // Push string value on the stack
406
398
self . stack . push ( Type :: String ( string) ) ;
407
- self . stack
408
- . push ( Type :: String ( token[ 1 ..token. len ( ) - 1 ] . to_string ( ) ) ) ;
409
399
} else if chars[ 0 ] == '[' && chars[ chars. len ( ) - 1 ] == ']' {
410
400
// Push list value on the stack
411
401
let old_len = self . stack . len ( ) ; // length of old stack
@@ -710,10 +700,15 @@ impl Executor {
710
700
// Standard output
711
701
"print" => {
712
702
let a = self . pop_stack ( ) . get_string ( ) ;
703
+
704
+ let a = a. replace ( "\\ n" , "\n " ) ;
705
+ let a = a. replace ( "\\ t" , "\t " ) ;
706
+ let a = a. replace ( "\\ r" , "\r " ) ;
707
+
713
708
if let Mode :: Debug = self . mode {
714
709
println ! ( "[Output]: {a}" ) ;
715
710
} else {
716
- println ! ( "{a}" ) ;
711
+ print ! ( "{a}" ) ;
717
712
}
718
713
}
719
714
0 commit comments