@@ -654,6 +654,25 @@ impl Parser {
654654 object : Box :: new ( base) ,
655655 key : Box :: new ( Expression :: Value ( Value :: Number ( num) ) ) ,
656656 } ) ,
657+ Expression :: Call { ref function, ref args } => match * * function {
658+ Expression :: Identifier ( ref key_name) => Ok ( Expression :: Call {
659+ function : Box :: new ( Expression :: MemberAccess {
660+ object : Box :: new ( base) ,
661+ key : Box :: new ( Expression :: Value ( Value :: String ( key_name. clone ( ) ) ) ) ,
662+ } ) ,
663+ args : args. clone ( ) ,
664+ } ) ,
665+ Expression :: Value ( Value :: Number ( num) ) => Ok ( Expression :: Call {
666+ function : Box :: new ( Expression :: MemberAccess {
667+ object : Box :: new ( base) ,
668+ key : Box :: new ( Expression :: Value ( Value :: Number ( num) ) ) ,
669+ } ) ,
670+ args : args. clone ( ) ,
671+ } ) ,
672+ _ => Err ( format ! (
673+ "Expected identifier or number after '.' but got {:?} at {}:{}" , key, self . peek( ) . line, self . peek( ) . column
674+ ) ) ,
675+ } ,
657676 _ => Err ( format ! (
658677 "Expected identifier or number after '.' but got {:?} at {}:{}" ,
659678 key, self . peek( ) . line, self . peek( ) . column
@@ -979,7 +998,7 @@ impl Parser {
979998 if self . eat ( & TokenType :: Operator ( "=" . to_string ( ) ) ) {
980999 let value = self . parse_binary ( 0 ) ?;
9811000 Ok ( Statement :: Assignment {
982- is_global : false ,
1001+ is_global : true ,
9831002 identifier : target_expr,
9841003 value,
9851004 } )
@@ -997,7 +1016,7 @@ impl Parser {
9971016 right : Box :: new ( right) ,
9981017 } ;
9991018 Ok ( Statement :: Assignment {
1000- is_global : false ,
1019+ is_global : true ,
10011020 identifier : target_expr,
10021021 value : combined_expr,
10031022 } )
0 commit comments