florianschanda / miss_hit

MATLAB Independent, Small & Safe, High Integrity Tools - code formatter and more
GNU General Public License v3.0
158 stars 21 forks source link

array in array parsing #252

Closed BrunoSalami closed 2 years ago

BrunoSalami commented 2 years ago

MISS_HIT Component affected Please choose one from:

Your MATLAB/Octave environment

Your operating system and Python version

Describe the bug [-.1 -[1]] should be parsed as an array with two elements. However, miss_hit interprets this as a scalar (sums up -.1 and -1 -> -1.1)

$ ./mh_debug_parser test.m --tree
In test.m, line 1
| [-.1 -[1]] % [-.1 -1]
|          ^ style: end statement with a semicolon
----------------------------------------------------------------------
--  Parse tree for test.m
Root: Script_File
  Statements: Sequence_Of_Statements
    Statements: Naked_Expression_Statement
      Expression: Matrix_Expression
        Content: Row_List
          Items: Row
            Items: Binary_Operation -
              LHS: Unary_Operation -
                Expression: Number_Literal <.1>
              RHS: Matrix_Expression
                Content: Row_List
                  Items: Row
                    Items: Number_Literal <1>
florianschanda commented 2 years ago

@BrunoSalami this was actually pretty easy to fix.

BrunoSalami commented 2 years ago

hi florian,

confirmed! it's working correctly now:

$ ./mh_debug_parser test.m --tree
In test.m, line 1
| [-.1 -[1]] % [-.1 -1]
|          ^ style: end statement with a semicolon
----------------------------------------------------------------------
--  Parse tree for test.m
Root: Script_File
  Statements: Sequence_Of_Statements
    Statements: Naked_Expression_Statement
      Expression: Matrix_Expression
        Content: Row_List
          Items: Row
            Items: Unary_Operation -
              Expression: Number_Literal <.1>
            Items: Unary_Operation -
              Expression: Matrix_Expression
                Content: Row_List
                  Items: Row
                    Items: Number_Literal <1>
BrunoSalami commented 2 years ago

I found another one of those, see https://github.com/florianschanda/miss_hit/issues/253