tree-sitter-abl 0.0.50 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/grammar.js CHANGED
@@ -36,13 +36,24 @@ module.exports = grammar({
36
36
  conflicts: ($) => [
37
37
  [$.sort_clause],
38
38
  [$.string_literal],
39
- [$.if_statement]
39
+ [$.if_statement],
40
+ [$._name, $.radio_set_phrase],
41
+ [$.radio_set_phrase, $._expression],
42
+ [$._list_items, $._expression],
43
+ [$.size_phrase, $.frame_definition],
44
+ [$.dataset_expression, $.object_access],
45
+ [$.in_frame_phrase, $._expression],
46
+ [$.include, $.constant],
47
+ [$.include_argument],
48
+ [$.include_argument, $._constant_value],
49
+ [$._literal, $._expression]
40
50
  ],
41
51
 
42
52
  rules: {
43
- source_code: ($) => repeat(choice($._statement, $.class_statement, $._definition, $.do_block, $.interface_statement)),
53
+ source_code: ($) => repeat(choice($._statement, $.class_statement, $._definition, $.do_block, $.interface_statement, $.method_statement, $.constant)),
44
54
 
45
- body: ($) => seq(":", repeat(choice($._statement, $._definition, $.do_block))),
55
+
56
+ body: ($) => seq(":", repeat(choice($._statement, $._definition, $.do_block, prec(-1, $.annotation)))),
46
57
 
47
58
  _statement_body: ($) => choice($.do_block, prec(2, $._statement)),
48
59
 
@@ -55,6 +66,7 @@ module.exports = grammar({
55
66
  choice(
56
67
  $._definition,
57
68
  $.var_statement,
69
+ $.include,
58
70
  seq(
59
71
  optional($.annotation),
60
72
  $.method_statement
@@ -72,13 +84,14 @@ module.exports = grammar({
72
84
  repeat(
73
85
  choice(
74
86
  $._definition,
87
+ $.annotation,
75
88
  $.method_statement
76
89
  )
77
- )
90
+ ),
78
91
  ),
79
92
 
80
93
  case_body: ($) =>
81
- seq(":", repeat1($.case_when_branch), optional($.case_otherwise_branch)),
94
+ seq(":", repeat1(prec.right(seq(optional($.annotation), $.case_when_branch, optional($.annotation)))), optional(seq(optional($.annotation), $.case_otherwise_branch, optional($.annotation)))),
82
95
 
83
96
  enum_body: ($) => seq(":", repeat1($.enum_definition)),
84
97
 
@@ -162,7 +175,11 @@ module.exports = grammar({
162
175
  kw("TEARDOWN"),
163
176
  kw("AFTERALL"),
164
177
  kw("AFTER"),
165
- kw("IGNORE")
178
+ kw("IGNORE"),
179
+ //These are extra annotations that we added for the OpenEdge ABL Formatter.
180
+ //For more details, please visit: https://marketplace.visualstudio.com/items?itemName=BalticAmadeus.openedge-abl-formatter
181
+ kw("ABLFORMATTEREXCLUDESTART"),
182
+ kw("ABLFORMATTEREXCLUDEEND"),
166
183
  ),
167
184
  $._terminator
168
185
  ),
@@ -190,7 +207,8 @@ module.exports = grammar({
190
207
  _literal: ($) =>
191
208
  choice(
192
209
  $.number_literal,
193
- $.string_literal
210
+ $.string_literal,
211
+ $.date_literal
194
212
  ),
195
213
 
196
214
  boolean_literal: ($) =>
@@ -240,6 +258,7 @@ module.exports = grammar({
240
258
  $.number_literal,
241
259
  $.string_literal,
242
260
  $.boolean_literal,
261
+ $.null_expression,
243
262
  $.function_call,
244
263
  $.array_literal,
245
264
  $.array_access,
@@ -273,25 +292,46 @@ module.exports = grammar({
273
292
  ),
274
293
  field("name", $.identifier),
275
294
  field("value", $.string_literal),
276
- $.constant
295
+ $.constant,
296
+ $.identifier
277
297
  ),
278
298
 
279
299
  include: ($) =>
280
- seq(
300
+ prec.right(1, seq(
281
301
  "{",
282
- $.file_name,
302
+ choice(
303
+ $.file_name,
304
+ prec(1, alias($.include_file_path, $.file_name)),
305
+ $.identifier
306
+ ),
283
307
  repeat($.include_argument),
284
308
  "}"
285
- ),
309
+ )),
310
+
311
+ include_file_path: ($) =>
312
+ prec.right(repeat1(choice(
313
+ $.constant,
314
+ /[A-z-_|0-9|\/\.]+/i
315
+ ))),
286
316
 
287
317
  // IDENTIFIERS
288
318
 
289
- identifier: ($) => /[A-Z|a-z|\-|\\_]{1}[#A-Z|a-z|\-|\\_|0-9]*/i,
319
+ identifier: ($) => /[A-Z|a-z|\-|\\_]{1}[#+&A-Z|a-z|\-|\\_|0-9]*/i,
320
+
321
+ // variable_name: ($) => choice(
322
+ // $.identifier,
323
+ // seq($.identifier, "&")
324
+ // ),
290
325
 
291
326
  constant: ($) =>
292
327
  seq("{", optional("&"), $._constant_value, "}"),
293
328
 
294
- _constant_value: ($) => choice($.identifier, $._integer_literal),
329
+ _constant_value: ($) => choice(
330
+ $.identifier,
331
+ $._integer_literal,
332
+ seq($.identifier, "=", choice($.identifier, $._integer_literal, $.string_literal)),
333
+ seq($.identifier, repeat1(choice(/[\s\-()a-zA-Z0-9]+/)))
334
+ ),
295
335
 
296
336
  qualified_name: ($) =>
297
337
  seq(
@@ -369,7 +409,6 @@ module.exports = grammar({
369
409
 
370
410
  field_option: ($) =>
371
411
  choice(
372
- // $._bgcolor,
373
412
  $._column_label,
374
413
  // $._dcolor,
375
414
  $._label,
@@ -526,8 +565,8 @@ module.exports = grammar({
526
565
 
527
566
  type_tuning: ($) =>
528
567
  choice(
529
- seq(kw("AS"), field("type", $._type)),
530
- seq(kw("LIKE"), field("type", $._type))
568
+ seq(kw("AS"), field("type", choice($._type, $.string_literal))),
569
+ seq(kw("LIKE"), field("type", choice($._type, $.string_literal)))
531
570
  ),
532
571
 
533
572
  using: ($) =>
@@ -650,6 +689,7 @@ module.exports = grammar({
650
689
  $.string_literal,
651
690
  $.number_literal,
652
691
  $.null_expression,
692
+ $.constant,
653
693
  $._binary_expression,
654
694
  $.unary_expression,
655
695
  $.function_call
@@ -726,13 +766,13 @@ module.exports = grammar({
726
766
  ),
727
767
 
728
768
  object_access: ($) =>
729
- seq(
769
+ prec(2, seq(
730
770
  field(
731
771
  "object",
732
772
  choice($.new_expression, $.function_call, $.constant, $._name)
733
773
  ),
734
774
  repeat1(seq(alias($._namecolon, ":"), field("property", $.identifier)))
735
- ),
775
+ )),
736
776
 
737
777
  member_access: ($) =>
738
778
  seq(
@@ -743,7 +783,10 @@ module.exports = grammar({
743
783
  ),
744
784
 
745
785
  case_condition: ($) =>
746
- seq(optional(seq(kw("OR"), kw("WHEN"))), choice($._literal, $.boolean_literal, $.logical_expression, $.comparison_expression, $.unary_expression, $.object_access)),
786
+ seq(
787
+ optional(seq(kw("OR"), kw("WHEN"))),
788
+ choice($._literal, $.boolean_literal, $.logical_expression, $.comparison_expression, $.unary_expression, $.object_access, $.null_expression, $.function_call)
789
+ ),
747
790
 
748
791
  case_when_branch: ($) =>
749
792
  seq(kw("WHEN"), repeat1($.case_condition), kw("THEN"), $._statement_body),
@@ -778,18 +821,22 @@ module.exports = grammar({
778
821
  variable: ($) => choice(field("name", $.identifier), $.assignment),
779
822
 
780
823
  enum_member: ($) =>
824
+ prec.right(
781
825
  seq(
826
+ repeat($.annotation),
782
827
  field("name", $.identifier),
783
828
  field(
784
829
  "value",
785
830
  optional(
786
831
  seq(
787
832
  kw("="),
788
- _list(choice($.identifier, $._literal),",")
833
+ _list(choice($.identifier, $._literal, $.null_expression),",")
789
834
  )
790
835
  )
791
- )
792
- ),
836
+ ),
837
+ repeat($.annotation),
838
+ )
839
+ ),
793
840
 
794
841
  function_call: ($) =>
795
842
  prec.right(
@@ -874,24 +921,21 @@ module.exports = grammar({
874
921
  optional(seq(kw("BY"), choice($._integer_literal, $.unary_expression)))
875
922
  ),
876
923
 
877
- // combo_box_phrase: ($) =>
878
- // seq(
879
- // kw("COMBO-BOX"),
880
- // repeat(
881
- // choice(
882
- // $._list_items,
883
- // $._inner_lines,
884
- // $.size_phrase,
885
- // kw("SORT"),
886
- // $._tooltip,
887
- // kw("SIMPLE"),
888
- // kw("DROP-DOWN"),
889
- // kw("DROP-DOWN-LIST"),
890
- // $._max_chars,
891
- // seq(kw("AUTO-COMPLETION"), optional(kw("UNIQUE-MATCH")))
892
- // )
893
- // )
894
- // ),
924
+ combo_box_phrase: ($) =>
925
+ seq(
926
+ kw("COMBO-BOX"),
927
+ repeat(
928
+ choice(
929
+ $._list_items,
930
+ $.size_phrase,
931
+ kw("SORT"),
932
+ kw("SIMPLE"),
933
+ kw("DROP-DOWN"),
934
+ kw("DROP-DOWN-LIST"),
935
+ seq(kw("AUTO-COMPLETION"), optional(kw("UNIQUE-MATCH")))
936
+ )
937
+ )
938
+ ),
895
939
 
896
940
  // editor_phrase: ($) =>
897
941
  // seq(
@@ -913,17 +957,24 @@ module.exports = grammar({
913
957
  // )
914
958
  // ),
915
959
 
916
- // radio_set_phrase: ($) =>
917
- // seq(
918
- // kw("RADIO-SET"),
919
- // optional(choice(seq(kw("HORIZONTAL"), optional(kw("EXPAND"))), kw("VERTICAL"))),
920
- // seq(
921
- // kw("RADIO-BUTTONS"),
922
- // field("label", $.identifier), ",", field("value", $.identifier),
923
- // repeat(seq(",", field("label", $.identifier), ",", field("value", $.identifier)))
924
- // ),
925
- // optional($._tooltip)
926
- // ),
960
+ radio_set_phrase: ($) =>
961
+ seq(
962
+ kw("RADIO-SET"),
963
+ optional(choice(seq(kw("HORIZONTAL"), optional(kw("EXPAND"))), kw("VERTICAL"))),
964
+ seq(
965
+ kw("RADIO-BUTTONS"),
966
+ field("label", choice($.string_literal, $.identifier)),
967
+ ",",
968
+ field("value", choice($.string_literal, $.identifier, $._expression)),
969
+ repeat(seq(
970
+ ",",
971
+ field("label", choice($.string_literal, $.identifier)),
972
+ ",",
973
+ field("value", choice($.string_literal, $.identifier, $._expression))
974
+ ))
975
+ ),
976
+ optional($.size_phrase)
977
+ ),
927
978
 
928
979
  // selection_list_phrase: ($) =>
929
980
  // seq(
@@ -969,9 +1020,9 @@ module.exports = grammar({
969
1020
  seq(
970
1021
  kw("VIEW-AS"),
971
1022
  choice(
972
- // $.combo_box_phrase,
1023
+ $.combo_box_phrase,
973
1024
  // $.editor_phrase,
974
- // $.radio_set_phrase,
1025
+ $.radio_set_phrase,
975
1026
  // $.selection_list_phrase,
976
1027
  // $.slider_phrase,
977
1028
  // seq(
@@ -1042,6 +1093,7 @@ module.exports = grammar({
1042
1093
  // $.at_phrase, // TODO
1043
1094
  seq(kw("CANCEL-BUTTON"), $.identifier),
1044
1095
  kw("CENTERED"),
1096
+ // $._bgcolor,
1045
1097
  // color specification
1046
1098
  $._position,
1047
1099
  seq($.number_literal, kw("COLUMNS")),
@@ -1049,7 +1101,6 @@ module.exports = grammar({
1049
1101
  // seq(kw("CONTEXT-HELP-FILE"), $.identifier),
1050
1102
  seq(kw("DEFAULT-BUTTON"), $.identifier),
1051
1103
  // kw("DROP-TARGET"),
1052
- seq(optional($._expression), kw("DOWN")),
1053
1104
  // kw("EXPORT"),
1054
1105
  seq(kw("WIDGET-ID"), $.number_literal),
1055
1106
  $._font,
@@ -1123,7 +1174,7 @@ module.exports = grammar({
1123
1174
 
1124
1175
  in_frame_phrase: ($) =>
1125
1176
  seq(
1126
- $.object_access,
1177
+ choice($.object_access, $.function_call),
1127
1178
  kw("IN"),
1128
1179
  $._frame
1129
1180
  ),
@@ -1175,20 +1226,26 @@ module.exports = grammar({
1175
1226
  choice($.do_block, kw("REVERT"))
1176
1227
  )),
1177
1228
 
1178
- // _on_statement_widget_phrase: ($) =>
1179
- // prec(2, seq(
1180
- // _list(choice($.identifier, $.constant), ","),
1181
- // $.of_phrase,
1182
- // repeat(
1183
- // seq(
1184
- // kw("OR"),
1185
- // _list(choice($.identifier, $.constant), ","),
1186
- // $.of_phrase
1187
- // )
1188
- // ),
1189
- // optional(kw("ANYWHERE")),
1190
- // choice($.do_block, prec(2, $._statement), kw("REVERT"), seq(kw("PERSISTENT"), $.run_statement))
1191
- // )),
1229
+ _on_statement_widget_phrase: ($) =>
1230
+ prec(2, seq(
1231
+ _list(choice($.identifier, $.constant, $.string_literal), ","),
1232
+ choice(
1233
+ seq(kw("OF"), kw("FRAME"), choice($._name, $.constant)),
1234
+ seq(kw("OF"), _list(choice($._name, $.constant), ","), optional(seq(kw("IN"), kw("FRAME"), choice($._name, $.constant))))
1235
+ ),
1236
+ repeat(
1237
+ seq(
1238
+ kw("OR"),
1239
+ _list(choice($.identifier, $.constant, $.string_literal), ","),
1240
+ choice(
1241
+ seq(kw("OF"), kw("FRAME"), choice($._name, $.constant)),
1242
+ seq(kw("OF"), _list(choice($._name, $.constant), ","), optional(seq(kw("IN"), kw("FRAME"), choice($._name, $.constant))))
1243
+ )
1244
+ )
1245
+ ),
1246
+ optional(kw("ANYWHERE")),
1247
+ choice($.do_block, $.run_statement, prec(2, $._statement), kw("REVERT"), seq(kw("PERSISTENT"), $.run_statement))
1248
+ )),
1192
1249
 
1193
1250
  // TODO: Refactor
1194
1251
  // image_phrase: ($) =>
@@ -1300,13 +1357,13 @@ module.exports = grammar({
1300
1357
 
1301
1358
  _label: ($) => seq(kw("LABEL"), _list($.string_literal, ",")),
1302
1359
 
1303
- // _list_items: ($) =>
1304
- // seq(
1305
- // choice(
1306
- // kw("LIST-ITEMS"),
1307
- // kw("LIST-ITEM-PAIRS")),
1308
- // _list($.string_literal,",")
1309
- // ),
1360
+ _list_items: ($) =>
1361
+ seq(
1362
+ choice(
1363
+ kw("LIST-ITEMS"),
1364
+ kw("LIST-ITEM-PAIRS")),
1365
+ _list(choice($._literal, $._expression), ",")
1366
+ ),
1310
1367
 
1311
1368
  // _max_chars: ($) => seq(kw("MAX-CHARS"), $.number_literal),
1312
1369
 
@@ -1322,8 +1379,10 @@ module.exports = grammar({
1322
1379
  choice(
1323
1380
  $.variable_definition,
1324
1381
  $.buffer_definition,
1382
+ $.browse_definition,
1325
1383
  // $.button_definition,
1326
1384
  $.query_definition,
1385
+ $.rectangle_definition,
1327
1386
  $.temp_table_definition,
1328
1387
  $.workfile_definition,
1329
1388
  $.property_definition,
@@ -1332,7 +1391,7 @@ module.exports = grammar({
1332
1391
  $.dataset_definition,
1333
1392
  $.stream_definition,
1334
1393
  // $.image_definition,
1335
- // $.frame_definition,
1394
+ $.frame_definition,
1336
1395
  $.parameter_definition
1337
1396
  ),
1338
1397
 
@@ -1409,17 +1468,30 @@ module.exports = grammar({
1409
1468
  $._terminator
1410
1469
  ),
1411
1470
 
1412
- // frame_definition: ($) =>
1413
- // seq(
1414
- // $._define,
1415
- // repeat($._tuning),
1416
- // kw("FRAME"),
1417
- // field("name", $.identifier),
1418
- // // form item
1419
- // seq(optional(choice(kw("HEADER"), kw("BACKGROUND")))), // head item
1420
- // optional($.frame_phrase)
1421
-
1422
- // ),
1471
+ frame_definition: ($) =>
1472
+ seq(
1473
+ $._define,
1474
+ repeat($._tuning),
1475
+ kw("FRAME"),
1476
+ field("name", choice($.identifier, $.constant)),
1477
+ repeat(choice($.identifier, $.constant, $.object_access)),
1478
+ optional(seq(
1479
+ kw("WITH"),
1480
+ repeat1(choice(
1481
+ $.size_phrase,
1482
+ seq(kw("SIZE-PIXELS"), $.number_literal, kw("BY"), $.number_literal),
1483
+ kw("NO-BOX"),
1484
+ seq(kw("FONT"), $.number_literal),
1485
+ seq(kw("BGCOLOR"), $.number_literal),
1486
+ seq(kw("FGCOLOR"), $.number_literal),
1487
+ kw("SCROLLABLE"),
1488
+ kw("RESIZABLE")
1489
+ ))
1490
+ )),
1491
+ optional(seq(kw("AT"), kw("COLUMN"), field("column", choice($.number_literal, $.identifier)))),
1492
+ optional(seq(kw("ROW"), field("row", choice($.number_literal, $.identifier)))),
1493
+ $._terminator
1494
+ ),
1423
1495
 
1424
1496
  // image_definition: ($) =>
1425
1497
  // seq(
@@ -1458,10 +1530,10 @@ module.exports = grammar({
1458
1530
 
1459
1531
  _table_option: ($) =>
1460
1532
  choice(
1461
- kw("TABLE "),
1533
+ kw("TABLE"),
1462
1534
  kw("TABLE-HANDLE"),
1463
1535
  kw("DATASET-HANDLE"),
1464
- kw("DATASET ")
1536
+ kw("DATASET")
1465
1537
  ),
1466
1538
 
1467
1539
  _parameter_definition_option: ($) =>
@@ -1472,6 +1544,49 @@ module.exports = grammar({
1472
1544
  seq(kw("DATASET"), optional(token.immediate(kw("-HANDLE"))))
1473
1545
  ),
1474
1546
 
1547
+ browse_definition: ($) =>
1548
+ seq(
1549
+ $._define,
1550
+ repeat($._tuning),
1551
+ kw("BROWSE"),
1552
+ field("name", $.identifier),
1553
+ optional(seq(kw("QUERY"), field("query", $.identifier))),
1554
+ optional(seq(
1555
+ kw("DISPLAY"),
1556
+ repeat1(
1557
+ seq(
1558
+ $._expression,
1559
+ optional(seq(kw("COLUMN-LABEL"), $.string_literal))
1560
+ )
1561
+ )
1562
+ )),
1563
+ optional(seq(
1564
+ kw("WITH"),
1565
+ repeat1(choice(
1566
+ seq($.number_literal, kw("DOWN")),
1567
+ seq(kw("WIDTH"), $.number_literal),
1568
+ kw("MULTIPLE"),
1569
+ kw("SINGLE")
1570
+ ))
1571
+ )),
1572
+ $._terminator
1573
+ ),
1574
+
1575
+ rectangle_definition: ($) =>
1576
+ seq(
1577
+ $._define,
1578
+ repeat($._tuning),
1579
+ kw("RECTANGLE"),
1580
+ field("name", $.identifier),
1581
+ optional(seq(
1582
+ kw("SIZE"),
1583
+ $.number_literal,
1584
+ kw("BY"),
1585
+ $.number_literal
1586
+ )),
1587
+ $._terminator
1588
+ ),
1589
+
1475
1590
  property_definition: ($) =>
1476
1591
  seq(
1477
1592
  $._define,
@@ -1642,13 +1757,15 @@ module.exports = grammar({
1642
1757
  $.object_access,
1643
1758
  $.member_access,
1644
1759
  $.function_call,
1645
- $.array_access
1760
+ $.array_access,
1761
+ $.in_frame_phrase
1646
1762
  )
1647
1763
  )
1648
1764
  ),
1649
1765
  $.assignment_operator,
1650
1766
  prec.right(choice($._expression, $.include)),
1651
- optional($.when_expression)
1767
+ optional($.when_expression),
1768
+ optional(seq(kw("IN"), $._frame))
1652
1769
  )
1653
1770
  ),
1654
1771
 
@@ -1661,7 +1778,7 @@ module.exports = grammar({
1661
1778
  $.return_type,
1662
1779
  optional($._extent),
1663
1780
  optional(alias($.function_parameters, $.parameters)),
1664
- $._function_option,
1781
+ $._function_option
1665
1782
  ),
1666
1783
 
1667
1784
  _function_option: ($) =>
@@ -1691,6 +1808,7 @@ module.exports = grammar({
1691
1808
  choice(
1692
1809
  $.to_phrase,
1693
1810
  $.repeat_tuning
1811
+ // $.frame_phrase
1694
1812
  ),
1695
1813
 
1696
1814
  return_statement: ($) =>
@@ -1760,7 +1878,7 @@ module.exports = grammar({
1760
1878
  assign_statement: ($) =>
1761
1879
  seq(
1762
1880
  kw("ASSIGN"),
1763
- repeat1($.assignment),
1881
+ repeat1(choice($.assignment, $.preprocessor_directive)),
1764
1882
  optional(kw("NO-ERROR")),
1765
1883
  $._terminator
1766
1884
  ),
@@ -1820,7 +1938,7 @@ module.exports = grammar({
1820
1938
  seq(
1821
1939
  kw("ON"),
1822
1940
  choice(
1823
- // $._on_statement_widget_phrase,
1941
+ $._on_statement_widget_phrase,
1824
1942
  $._on_statement_database_phrase,
1825
1943
  seq(field("label", $.identifier), field("function", $.identifier), $._terminator),
1826
1944
  // seq(alias("\"WEB-NOTIFY\"", $.string_literal), kw("ANYWHERE"), $._statement_body)
@@ -1982,7 +2100,7 @@ module.exports = grammar({
1982
2100
 
1983
2101
  locked_expression: ($) => seq(kw("LOCKED"), $._name),
1984
2102
 
1985
- dataset_expression: ($) => seq(prec.left(kw("DATASET")), $._name),
2103
+ dataset_expression: ($) => prec(-1, seq(token(seq(/[Dd][Aa][Tt][Aa][Ss][Ee][Tt]/, /\s/)), $._name)),
1986
2104
 
1987
2105
  when_expression: ($) => seq(kw("WHEN"), $._expression),
1988
2106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-abl",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "description": "ABL grammar for tree-sitter",
5
5
  "repository": "https://github.com/eglekaz/tree-sitter-abl",
6
6
  "keywords": [
@@ -10,6 +10,7 @@
10
10
  "abl"
11
11
  ],
12
12
  "main": "bindings/node",
13
+
13
14
  "scripts": {
14
15
  "generate": "tree-sitter generate",
15
16
  "build": "tree-sitter generate && node-gyp build",
package/parser.exp CHANGED
Binary file
package/parser.lib CHANGED
Binary file
package/parser.obj CHANGED
Binary file
package/scanner.obj CHANGED
Binary file