@@ -244,47 +244,44 @@ impl Executor {
244
244
245
245
let mut syntax = Vec :: new ( ) ; // Token string
246
246
let mut buffer = String :: new ( ) ; // Temporary storage
247
- let mut brackets = 0 ; // String's nest structure
248
- let mut parentheses = 0 ; // List's nest structure
249
- let mut hash = false ; // Is it Comment
250
- let mut escape = false ; // Flag to indicate next character is escaped
247
+ let mut in_brackets = 0 ; // String's nest structure
248
+ let mut in_parentheses = 0 ; // List's nest structure
249
+ let mut in_hash = false ; // Is it Comment
251
250
252
251
for c in code. chars ( ) {
253
252
match c {
254
- '\\' if !escape => {
255
- escape = true ;
256
- }
257
- '(' if !hash && !escape => {
258
- brackets += 1 ;
253
+ '(' => {
254
+ in_brackets += 1 ;
259
255
buffer. push ( '(' ) ;
260
256
}
261
- ')' if !hash && !escape => {
262
- brackets -= 1 ;
257
+ ')' => {
258
+ in_brackets -= 1 ;
263
259
buffer. push ( ')' ) ;
264
260
}
265
- '#' if !hash && !escape => {
266
- hash = true ;
261
+ '#' if !in_hash => {
262
+ in_hash = true ;
267
263
buffer. push ( '#' ) ;
268
264
}
269
- '#' if hash && !escape => {
270
- hash = false ;
265
+ '#' if in_hash => {
266
+ in_hash = false ;
271
267
buffer. push ( '#' ) ;
272
268
}
273
- '[' if !hash && brackets == 0 && !escape => {
274
- parentheses += 1 ;
269
+ '[' if in_brackets == 0 => {
270
+ in_parentheses += 1 ;
275
271
buffer. push ( '[' ) ;
276
272
}
277
- ']' if !hash && brackets == 0 && !escape => {
278
- parentheses -= 1 ;
273
+ ']' if in_brackets == 0 => {
274
+ in_parentheses -= 1 ;
279
275
buffer. push ( ']' ) ;
280
276
}
281
- ' ' if !hash && parentheses == 0 && brackets == 0 && !escape => {
277
+ ' ' if !in_hash && in_parentheses == 0 && in_brackets == 0 => {
282
278
if !buffer. is_empty ( ) {
283
279
syntax. push ( buffer. clone ( ) ) ;
284
280
buffer. clear ( ) ;
285
281
}
286
282
}
287
283
_ => {
284
+ <<<<<<< HEAD
288
285
if parentheses == 0 && brackets == 0 && ! hash {
289
286
if escape {
290
287
<<<<<<< HEAD
@@ -318,6 +315,9 @@ impl Executor {
318
315
buffer. push( c) ;
319
316
}
320
317
escape = false; // Reset escape flag for non-escape characters
318
+ =======
319
+ buffer. push( c) ;
320
+ >>>>>>> 76 e82be ( git)
321
321
}
322
322
}
323
323
}
@@ -350,6 +350,7 @@ impl Executor {
350
350
self . stack. push( Type :: Bool ( token. parse( ) . unwrap_or( true) ) ) ;
351
351
} else if chars[ 0 ] == '(' && chars[ chars. len( ) - 1 ] == ')' {
352
352
// Push string value on the stack
353
+ <<<<<<< HEAD
353
354
let string = {
354
355
let mut buffer = String :: new( ) ; // Temporary storage
355
356
let mut brackets = 0 ; // String's nest structure
@@ -426,6 +427,10 @@ impl Executor {
426
427
buffer
427
428
} ;
428
429
self . stack. push ( Type :: String ( string ) ) ;
430
+ =======
431
+ self . stack
432
+ . push( Type :: String ( token[ 1 ..token. len( ) - 1 ] . to_string( ) ) ) ;
433
+ >>>>>>> 76e82 be ( git)
429
434
} else if chars[ 0 ] == '[' && chars[ chars . len( ) - 1 ] == ']' {
430
435
// Push list value on the stack
431
436
let old_len = self . stack. len( ) ; // length of old stack
@@ -730,15 +735,10 @@ impl Executor {
730
735
// Standard output
731
736
"print" => {
732
737
let a = self . pop_stack( ) . get_string( ) ;
733
-
734
- let a = a. replace( "\\ n" , "\n " ) ;
735
- let a = a. replace( "\\ t" , "\t " ) ;
736
- let a = a. replace( "\\ r" , "\r " ) ;
737
-
738
738
if let Mode :: Debug = self . mode {
739
739
println!( "[Output]: {a}" ) ;
740
740
} else {
741
- print ! ( "{a}" ) ;
741
+ println ! ( "{a}" ) ;
742
742
}
743
743
}
744
744
@@ -902,6 +902,7 @@ impl Executor {
902
902
<<<<<<< HEAD
903
903
<<<<<<< HEAD
904
904
<<<<<<< HEAD
905
+ <<<<<<< HEAD
905
906
=======
906
907
>>>>>>> cdb5350 ( git )
907
908
@@ -919,6 +920,10 @@ impl Executor {
919
920
>>>>>>> 0 c174e6 ( Update main. rs)
920
921
=======
921
922
>>>>>>> cdb5350 ( git)
923
+ =======
924
+
925
+ self . log_print( String :: from( "Error! item not found in the list\n " ) ) ;
926
+ >>>>>>> 76e82 be ( git)
922
927
self. stack. push( Type :: Error ( String :: from( "item-not-found" ) ) ) ;
923
928
}
924
929
@@ -1431,6 +1436,7 @@ impl Executor {
1431
1436
<<<<<<< HEAD
1432
1437
<<<<<<< HEAD
1433
1438
<<<<<<< HEAD
1439
+ <<<<<<< HEAD
1434
1440
=======
1435
1441
=======
1436
1442
<<<<<<< HEAD
@@ -1453,6 +1459,8 @@ impl Executor {
1453
1459
>>>>>>> ce80cb2 ( git )
1454
1460
>>>>>>> 74 bbfe3 ( git )
1455
1461
>>>>>>> e1b0d54 ( git )
1462
+ =======
1463
+ >>>>>>> 76 e82be ( git)
1456
1464
"index" => {
1457
1465
let findhint = self . pop_stack ( ) . get_string ( ) ;
1458
1466
let findtarget = self . pop_stack ( ) . get_list ( ) ;
@@ -1480,6 +1488,7 @@ impl Executor {
1480
1488
<<<<<<< HEAD
1481
1489
<<<<<<< HEAD
1482
1490
<<<<<<< HEAD
1491
+ <<<<<<< HEAD
1483
1492
=======
1484
1493
>>>>>>> cdb5350 ( git )
1485
1494
=======
@@ -1508,6 +1517,8 @@ impl Executor {
1508
1517
>>>>>>> cdb5350 ( git )
1509
1518
=======
1510
1519
>>>>>>> e1b0d54 ( git)
1520
+ =======
1521
+ >>>>>>> 76 e82be ( git)
1511
1522
// If it is not recognized as a command, use it as a string.
1512
1523
_ => self . stack. push ( Type :: String ( command ) ) ,
1513
1524
}
0 commit comments