@@ -433,7 +433,7 @@ impl Executor {
433433 match command. as_str ( ) {
434434 // Commands of calculation
435435
436- // addition
436+ // Addition
437437 "add" => {
438438 let b = self . pop_stack ( ) . get_number ( ) ;
439439 let a = self . pop_stack ( ) . get_number ( ) ;
@@ -519,14 +519,14 @@ impl Executor {
519519 self . stack . push ( Type :: Bool ( !b) ) ;
520520 }
521521
522- // Is it equal
522+ // Judge is it equal
523523 "equal" => {
524524 let b = self . pop_stack ( ) . get_string ( ) ;
525525 let a = self . pop_stack ( ) . get_string ( ) ;
526526 self . stack . push ( Type :: Bool ( a == b) ) ;
527527 }
528528
529- // Is it less
529+ // Judge is it less
530530 "less" => {
531531 let b = self . pop_stack ( ) . get_number ( ) ;
532532 let a = self . pop_stack ( ) . get_number ( ) ;
@@ -554,8 +554,8 @@ impl Executor {
554554
555555 // Repeat string a number of times
556556 "repeat" => {
557- let count = self . pop_stack ( ) . get_number ( ) ; // 回数
558- let text = self . pop_stack ( ) . get_string ( ) ; // 文字列
557+ let count = self . pop_stack ( ) . get_number ( ) ; // Count
558+ let text = self . pop_stack ( ) . get_string ( ) ; // String
559559 self . stack . push ( Type :: String ( text. repeat ( count as usize ) ) ) ;
560560 }
561561
@@ -598,7 +598,7 @@ impl Executor {
598598 self . stack . push ( Type :: String ( text. replace ( & before, & after) ) )
599599 }
600600
601- // split string by key
601+ // Split string by the key
602602 "split" => {
603603 let key = self . pop_stack ( ) . get_string ( ) ;
604604 let text = self . pop_stack ( ) . get_string ( ) ;
@@ -633,7 +633,7 @@ impl Executor {
633633 ) )
634634 }
635635
636- // Is it finding in string
636+ // Judge is it find in string
637637 "find" => {
638638 let word = self . pop_stack ( ) . get_string ( ) ;
639639 let text = self . pop_stack ( ) . get_string ( ) ;
@@ -781,17 +781,17 @@ impl Executor {
781781
782782 // Commands of control
783783
784- // evaluate string as program
784+ // Evaluate string as program
785785 "eval" => {
786786 let code = self . pop_stack ( ) . get_string ( ) ;
787787 self . evaluate_program ( code)
788788 }
789789
790790 // Conditional branch
791791 "if" => {
792- let condition = self . pop_stack ( ) . get_bool ( ) ; // condition
793- let code_else = self . pop_stack ( ) . get_string ( ) ; // else code
794- let code_if = self . pop_stack ( ) . get_string ( ) ; // if code
792+ let condition = self . pop_stack ( ) . get_bool ( ) ; // Condition
793+ let code_else = self . pop_stack ( ) . get_string ( ) ; // Code of else
794+ let code_if = self . pop_stack ( ) . get_string ( ) ; // Code of If
795795 if condition {
796796 self . evaluate_program ( code_if)
797797 } else {
@@ -818,7 +818,7 @@ impl Executor {
818818 thread:: spawn ( move || executor. evaluate_program ( code) ) ;
819819 }
820820
821- // exit a process
821+ // Exit a process
822822 "exit" => {
823823 let status = self . pop_stack ( ) . get_number ( ) ;
824824 std:: process:: exit ( status as i32 ) ;
@@ -884,11 +884,11 @@ impl Executor {
884884
885885 // Get index of the list
886886 "index" => {
887- let findhint = self . pop_stack ( ) . get_string ( ) ;
888- let findtarget = self . pop_stack ( ) . get_list ( ) ;
887+ let target = self . pop_stack ( ) . get_string ( ) ;
888+ let list = self . pop_stack ( ) . get_list ( ) ;
889889
890- for index in 0 .. ( findtarget . len ( ) ) {
891- if findhint == findtarget [ index ] . clone ( ) . get_string ( ) {
890+ for ( index, item ) in list . iter ( ) . enumerate ( ) {
891+ if target == item . clone ( ) . get_string ( ) {
892892 self . stack . push ( Type :: Number ( index as f64 ) ) ;
893893 return ;
894894 }
@@ -920,7 +920,7 @@ impl Executor {
920920 self . stack . push ( Type :: List ( list) ) ;
921921 }
922922
923- // Iteration
923+ // Iteration for the list
924924 "for" => {
925925 let code = self . pop_stack ( ) . get_string ( ) ;
926926 let vars = self . pop_stack ( ) . get_string ( ) ;
@@ -1040,7 +1040,7 @@ impl Executor {
10401040
10411041 // Commands of memory manage
10421042
1043- // pop in the stack
1043+ // Pop in the stack
10441044 "pop" => {
10451045 self . pop_stack ( ) ;
10461046 }
@@ -1159,7 +1159,7 @@ impl Executor {
11591159 let element = match data. get ( index) {
11601160 Some ( value) => value,
11611161 None => {
1162- self . log_print ( format ! ( "Error! initial data is shortage\n " ) ) ;
1162+ self . log_print ( "Error! initial data is shortage\n " . to_string ( ) ) ;
11631163 self . stack
11641164 . push ( Type :: Error ( "instance-shortage" . to_string ( ) ) ) ;
11651165 return ;
0 commit comments