UserNobody14 / tree-sitter-dart

Attempt to make a tree-sitter grammar for dart
MIT License
59 stars 36 forks source link

Pattern parser problem in switch and loops #45

Closed dalugm closed 1 year ago

dalugm commented 1 year ago

Hi there, currently I met two problem which parser shows error when parsering the official doc.

First:

https://dart.dev/language/patterns#switch-statements-and-expressions

switch (obj) {
  case 1:
    print('one');

  // ERROR happens when parsering the below line, other lines were parsered correctly.
  case >= first && <= last:
    print('in range');

  case (var a, var b):
    print('a = $a, b = $b');

  default:
}

Second:

https://dart.dev/language/patterns#for-and-for-in-loops

// ERROR
for (var MapEntry(key: key, value: count) in hist.entries) {
  print('$key occurred $count times');
}

// ERROR
for (var MapEntry(:key, value: count) in hist.entries) {
  print('$key occurred $count times');
}

Except the above, it works as I expected ;)

TimWhiting commented 1 year ago

Fixed