jrmoulton / tree-sitter-slint

A Tree Sitter parser for slint
MIT License
3 stars 2 forks source link

Parse error #2

Open Decodetalkers opened 2 years ago

Decodetalkers commented 2 years ago

image

Decodetalkers commented 2 years ago
Button := TouchArea {
    min-height: t.min-height;
    min-width: t.min-width + 10px;
    property text <=> t.text;
    Rectangle {
        border-width: 1.5px;
        border-color: root.has-hover ? Palette.widget-stroke : transparent;
        border-radius: 3px;
        background: root.pressed ? Palette.widget-background.darker(30%) : Palette.widget-background;
        t := Label {
            width: 100%;
            horizontal-alignment: center;
        }
    }
}

this also get error

Decodetalkers commented 2 years ago
Button := TouchArea {
    min-height: t.min-height;
    min-width: t.min-width + 10px;
    property text <=> t.text;
    Rectangle {
        border-width: 1.5px;
        border-color: root.has-hover ? Palette.widget-stroke : transparent;
        border-radius: 3px;
        background: root.pressed ? Palette.widget-background.darker(30%) : Palette.widget-background;
        t := Label {
            width: 100%;
            horizontal-alignment: center;
        }
    }
}

this also get error

the result of tree-sitter parse is

(source_file [0, 0] - [15, 0]
  (component_definition [0, 0] - [14, 1]
    name: (user_type_identifier [0, 0] - [0, 6])
    super_type: (user_type_identifier [0, 10] - [0, 19])
    (field_declaration_list [0, 20] - [14, 1]
      (field_declaration_list_body [0, 20] - [13, 5]
        (variable_set_equal [1, 4] - [1, 29]
          prev_name: (var_identifier [1, 4] - [1, 14])
          (assignment_prec_operator [1, 14] - [1, 15])
          (var_identifier [1, 16] - [1, 28]
            (post_identifier [1, 18] - [1, 28])))
        (variable_set_equal [2, 4] - [2, 34]
          prev_name: (var_identifier [2, 4] - [2, 13])
          (assignment_prec_operator [2, 13] - [2, 14])
          (add_binary_expression [2, 15] - [2, 33]
            (var_identifier [2, 15] - [2, 26]
              (post_identifier [2, 17] - [2, 26]))
            (add_prec_operator [2, 27] - [2, 28])
            (value [2, 29] - [2, 33]
              (value_with_units [2, 29] - [2, 33]
                (number [2, 29] - [2, 31]
                  (int_number [2, 29] - [2, 31]))
                (unit_type [2, 31] - [2, 33])))))
        (ERROR [3, 4] - [4, 8]
          (ERROR [3, 13] - [3, 17])
          (ERROR [3, 22] - [3, 23])
          (ERROR [3, 24] - [3, 28])
          (ERROR [4, 4] - [4, 8]))
        (component_definition [4, 8] - [13, 5]
          super_type: (builtin_type_identifier [4, 8] - [4, 13])
          (field_declaration_list [4, 14] - [13, 5]
            (field_declaration_list_body [4, 14] - [12, 9]
              (variable_set_equal [5, 8] - [5, 28]
                prev_name: (var_identifier [5, 8] - [5, 20])
                (assignment_prec_operator [5, 20] - [5, 21])
                (value [5, 22] - [5, 27]
                  (value_with_units [5, 22] - [5, 27]
                    (number [5, 22] - [5, 25]
                      (float_number [5, 22] - [5, 25]))
                    (unit_type [5, 25] - [5, 27]))))
              (variable_set_equal [6, 8] - [6, 75]
                prev_name: (var_identifier [6, 8] - [6, 20])
                (assignment_prec_operator [6, 20] - [6, 21])
                (ternary_expression [6, 22] - [6, 74]
                  (var_identifier [6, 22] - [6, 36]
                    (reference_identifier [6, 22] - [6, 26])
                    (post_identifier [6, 27] - [6, 36]))
                  (var_identifier [6, 39] - [6, 60]
                    (post_identifier [6, 47] - [6, 60]))
                  (value [6, 63] - [6, 74]
                    (language_constant [6, 63] - [6, 74]))))
              (variable_set_equal [7, 8] - [7, 27]
                prev_name: (var_identifier [7, 8] - [7, 21])
                (assignment_prec_operator [7, 21] - [7, 22])
                (value [7, 23] - [7, 26]
                  (value_with_units [7, 23] - [7, 26]
                    (number [7, 23] - [7, 24]
                      (int_number [7, 23] - [7, 24]))
                    (unit_type [7, 24] - [7, 26]))))
              (variable_set_equal [8, 8] - [8, 101]
                prev_name: (var_identifier [8, 8] - [8, 18])
                (assignment_prec_operator [8, 18] - [8, 19])
                (ternary_expression [8, 20] - [8, 100]
                  (var_identifier [8, 20] - [8, 32]
                    (reference_identifier [8, 20] - [8, 24])
                    (post_identifier [8, 25] - [8, 32]))
                  (var_identifier [8, 35] - [8, 72]
                    (post_identifier [8, 43] - [8, 60])
                    (post_identifier [8, 61] - [8, 72]
                      (function_call [8, 61] - [8, 72]
                        (function_identifier [8, 61] - [8, 67])
                        (call_signature [8, 67] - [8, 72]
                          parameters: (formal_parameters [8, 67] - [8, 72]
                            (formal_parameter [8, 68] - [8, 71]
                              (value [8, 68] - [8, 71]
                                (value_with_units [8, 68] - [8, 71]
                                  (number [8, 68] - [8, 70]
                                    (int_number [8, 68] - [8, 70]))
                                  (unit_type [8, 70] - [8, 71])))))))))
                  (var_identifier [8, 75] - [8, 100]
                    (post_identifier [8, 83] - [8, 100]))))
              (component_definition [9, 8] - [12, 9]
                name: (user_type_identifier [9, 8] - [9, 9])
                super_type: (user_type_identifier [9, 13] - [9, 18])
                (field_declaration_list [9, 19] - [12, 9]
                  (field_declaration_list_body [9, 19] - [11, 41]
                    (variable_set_equal [10, 12] - [10, 24]
                      prev_name: (var_identifier [10, 12] - [10, 17])
                      (assignment_prec_operator [10, 17] - [10, 18])
                      (value [10, 19] - [10, 23]
                        (value_with_units [10, 19] - [10, 23]
                          (number [10, 19] - [10, 22]
                            (int_number [10, 19] - [10, 22]))
                          (unit_type [10, 22] - [10, 23]))))
                    (variable_set_equal [11, 12] - [11, 41]
                      prev_name: (var_identifier [11, 12] - [11, 32])
                      (assignment_prec_operator [11, 32] - [11, 33])
                      (var_identifier [11, 34] - [11, 40]))))))))))))
test.slint  0 ms    (ERROR [3, 4] - [4, 8])
jrmoulton commented 2 years ago

Yeah the two way assignment is a known issue and one of the features of the language that I missed in the parser. I think it should be a simple fix just by adding the two way operator to the operators list and adding it to the queries. I'll look into the fix soon