@@ -441,37 +441,47 @@ pub fn run(
441441 let mut types = false ;
442442 let mut position = x + 1 ;
443443 let _square_brackets = 0 ;
444- let mut exists = memory_names. len ( ) ;
445-
446- if memory_names. contains ( & contents[ position + 1 ] ) {
447- for item in 0 ..memory_names. len ( ) {
448- if memory_names[ item] == contents[ position + 1 ] {
449- exists = item;
450- }
451- }
452- }
444+ let mut infer = false ;
445+ let mut find_int_str = false ;
453446
454447 // get type
455- if contents[ position] == "int"
456- || contents[ position] == "str"
457- || contents[ position] == "arr"
458- || contents[ position] == "grp"
459- || contents[ position] == "inf"
460- {
461- if exists != memory_names. len ( ) {
462- memory_types[ exists] = contents[ position] . to_string ( ) ;
463- memory_names[ exists] = contents[ position + 1 ] . clone ( ) ;
464- } else {
465- memory_types. push ( contents[ position] . to_string ( ) ) ;
466- memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
467- }
448+ if contents[ position] == "int" {
449+ memory_types. push ( String :: from ( "int" ) ) ;
450+ memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
451+ position += 1 ;
452+ } else if contents[ position] == "str" {
453+ memory_types. push ( String :: from ( "str" ) ) ;
454+ memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
455+ position += 1 ;
456+ } else if contents[ position] == "arr" {
457+ memory_types. push ( String :: from ( "arr" ) ) ;
458+ memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
459+ position += 1 ;
460+ } else if contents[ position] == "grp" {
461+ memory_types. push ( String :: from ( "grp" ) ) ;
462+ memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
468463 position += 1 ;
469464 } else if contents[ position] == "anon" {
465+ memory_types. push ( String :: from ( "anon" ) ) ;
470466 types = true ;
471- if exists != memory_names. len ( ) {
472- memory_types[ exists] = "anon" . to_string ( ) ;
467+ } else {
468+ infer = true ;
469+ }
470+ if infer == true {
471+ if contents[ x + 3 ] == "[" {
472+ memory_types. push ( String :: from ( "arr" ) ) ;
473+ memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
474+ position += 1 ;
475+ } else if contents[ x + 3 ] == "\" " {
476+ memory_types. push ( String :: from ( "str" ) ) ;
477+ memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
478+ position += 1 ;
479+ } else if contents[ x + 3 ] == "{" {
480+ memory_types. push ( String :: from ( "grp" ) ) ;
481+ memory_names. push ( contents[ position + 1 ] . clone ( ) ) ;
482+ position += 1 ;
473483 } else {
474- memory_types . push ( String :: from ( "anon" ) ) ;
484+ find_int_str = true
475485 }
476486 }
477487
@@ -494,9 +504,10 @@ pub fn run(
494504 let mut pass_vec: Vec < String > = Vec :: new ( ) ;
495505 pass_vec. push ( "a" . to_string ( ) ) ;
496506 pass_vec. push ( "(" . to_string ( ) ) ;
497- if contents[ x + 1 ] == "int" {
507+
508+ if memory_types[ memory_types. len ( ) - 1 ] == "int" {
498509 pass_vec. push ( "math" . to_string ( ) ) ;
499- pass_vec. push ( "(" . to_string ( ) ) ;
510+ pass_vec. push ( "(" . to_string ( ) )
500511 }
501512 loop {
502513 if contents[ position] == "\n " || contents[ position] == ";" {
@@ -505,6 +516,9 @@ pub fn run(
505516 pass_vec. push ( contents[ position] . clone ( ) . to_string ( ) ) ;
506517 position += 1 ;
507518 }
519+ if memory_types[ memory_types. len ( ) - 1 ] == "int" {
520+ pass_vec. push ( ")" . to_string ( ) ) ;
521+ }
508522 pass_vec. push ( ")" . to_string ( ) ) ;
509523 let value = functions:: getstring (
510524 0 ,
@@ -548,41 +562,23 @@ pub fn run(
548562 }
549563 }
550564 name. push_str ( & * group_memory[ location] ) ;
551- if exists != memory_names. len ( ) {
552- memory_names[ exists] = name. clone ( ) ;
553- memory_values[ exists] = value_group[ d] . clone ( ) ;
554- memory_types[ exists] = "str" . parse ( ) . unwrap ( ) ;
555- } else {
556- memory_names. push ( name. clone ( ) ) ;
557- memory_values. push ( value_group[ d] . clone ( ) ) ;
558- memory_types. push ( "str" . parse ( ) . unwrap ( ) ) ;
559- }
565+ memory_names. push ( name. clone ( ) ) ;
566+ memory_values. push ( value_group[ d] . clone ( ) ) ;
567+ memory_types. push ( "str" . parse ( ) . unwrap ( ) ) ;
560568 }
561569 } else if memory_types[ memory_types. len ( ) - 1 ] == "int" {
562570 let number = meval:: eval_str ( value. clone ( ) . as_str ( ) ) ;
563571 if number. is_ok ( ) {
564- if exists != memory_values. len ( ) {
565- memory_values[ exists] = number. unwrap ( ) . to_string ( ) ;
566- } else {
567- memory_values. push ( number. unwrap ( ) . to_string ( ) ) ;
568- }
569- } else if exists != memory_values. len ( ) {
570- memory_values[ exists] = value. clone ( ) ;
572+ memory_values. push ( number. unwrap ( ) . to_string ( ) ) ;
571573 } else {
572574 memory_values. push ( value. clone ( ) ) ;
573575 }
574- } else if exists != memory_values. len ( ) {
575- memory_values[ exists] = value. clone ( ) ;
576576 } else {
577577 memory_values. push ( value. clone ( ) ) ;
578578 }
579579
580580 if types {
581- if exists != memory_names. len ( ) {
582- memory_names[ exists] = value. clone ( ) ;
583- } else {
584- memory_names. push ( value. clone ( ) ) ;
585- }
581+ memory_names. push ( value. clone ( ) ) ;
586582 }
587583 if dev {
588584 println ! ( "memory_names: {:?}" , memory_names) ;
0 commit comments