tree-sitter-abl 0.0.51 → 0.1.1

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
@@ -28,7 +28,8 @@ module.exports = grammar({
28
28
  $._def_keyword,
29
29
  $._var_keyword,
30
30
  $._index_keyword,
31
- $._field_keyword
31
+ $._field_keyword,
32
+ $._return_keyword
32
33
  ],
33
34
  extras: ($) => [$.comment, /[\s\f\uFEFF\u2060\u200B]|\\\r?\n/],
34
35
  word: ($) => $.identifier,
@@ -43,10 +44,11 @@ module.exports = grammar({
43
44
  [$.size_phrase, $.frame_definition],
44
45
  [$.dataset_expression, $.object_access],
45
46
  [$.in_frame_phrase, $._expression],
47
+ [$.in_frame_phrase, $._message_statement_expression],
46
48
  [$.include, $.constant],
47
49
  [$.include_argument],
48
50
  [$.include_argument, $._constant_value],
49
- [$._literal, $._expression]
51
+ [$._literal, $._expression],
50
52
  ],
51
53
 
52
54
  rules: {
@@ -55,7 +57,7 @@ module.exports = grammar({
55
57
 
56
58
  body: ($) => seq(":", repeat(choice($._statement, $._definition, $.do_block, prec(-1, $.annotation)))),
57
59
 
58
- _statement_body: ($) => choice($.do_block, prec(2, $._statement)),
60
+ _statement_body: ($) => choice($.do_block, prec(2, $._statement), $.constant),
59
61
 
60
62
  dot_body: ($) => seq(choice(":", "."), repeat(choice($._statement, $._definition))),
61
63
 
@@ -155,11 +157,16 @@ module.exports = grammar({
155
157
 
156
158
  _name: ($) => choice($.identifier, $.qualified_name),
157
159
 
158
- file_name: ($) => /[A-z-_|0-9|\/]+\.[ip]/i,
160
+ file_name: ($) => /[A-z-_|0-9|\/]+\.[ipwr]/i,
159
161
 
160
- // TODO: FIX: Comments inside comments caused memory leak
162
+ // TODO: FIX
161
163
  comment: ($) =>
162
164
  choice(seq("//", /.*/), seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, "/")),
165
+ // Note: This was initial solution for comments inside comments. Does not work
166
+ // choice(
167
+ // seq("//", /.*/),
168
+ // seq("/*", repeat(choice(/[^*]/, /\*+[^/*]/)), /\*+\//)
169
+ // ),
163
170
 
164
171
  annotation: ($) =>
165
172
  seq(
@@ -376,6 +383,106 @@ module.exports = grammar({
376
383
  kw("SUB-TOTAL")
377
384
  ),
378
385
 
386
+ _message_tuning: ($) =>
387
+ choice(
388
+ $.message_color,
389
+ $._message_alert_box,
390
+ $.message_update,
391
+ $.message_pause,
392
+ kw("NO-ERROR")
393
+ ),
394
+
395
+ message_color: ($) =>
396
+ seq(
397
+ kw("COLOR"),
398
+ $.color_phrase
399
+ ),
400
+
401
+ color_phrase: ($) =>
402
+ choice(
403
+ kw("NORMAL"),
404
+ kw("INPUT"),
405
+ kw("MESSAGES"),
406
+ seq(
407
+ optional(
408
+ choice(
409
+ kw("BLINK-"),
410
+ kw("RVV-"),
411
+ kw("UNDERLINE-"),
412
+ kw("BRIGHT-")
413
+ )
414
+ ),
415
+ choice($.string_literal, $.identifier)
416
+ ),
417
+
418
+ seq(
419
+ kw("VALUE"),
420
+ "(", $._expression,
421
+ ")")
422
+ ),
423
+
424
+ _message_alert_box: ($) =>
425
+ seq(
426
+ kw("VIEW-AS"),
427
+ kw("ALERT-BOX"),
428
+ optional($.alert_box_type),
429
+ optional($.alert_box_buttons),
430
+ optional(seq(kw("TITLE"), choice($.string_literal, $.additive_expression)))
431
+ ),
432
+
433
+ alert_box_type: ($) =>
434
+ choice(
435
+ kw("MESSAGE"),
436
+ kw("INFORMATION"),
437
+ kw("INFO"),
438
+ kw("WARNING"),
439
+ kw("ERROR"),
440
+ kw("QUESTION")
441
+ ),
442
+
443
+ alert_box_buttons: ($) =>
444
+ seq(
445
+ kw("BUTTONS"),
446
+ choice(
447
+ kw("OK"),
448
+ kw("CANCEL"),
449
+ kw("OK-CANCEL"),
450
+ kw("YES-NO"),
451
+ kw("YES-NO-CANCEL"),
452
+ kw("OK-HELP"),
453
+ kw("YES-NO-HELP"),
454
+ $.identifier,
455
+ $.string_literal
456
+ )
457
+ ),
458
+
459
+ message_update: ($) =>
460
+ seq(
461
+ choice(
462
+ kw("UPDATE"),
463
+ kw("SET")
464
+ ),
465
+ $._name,
466
+ repeat(
467
+ choice(
468
+ seq(
469
+ choice(
470
+ kw("AS"),
471
+ kw("LIKE")),
472
+ $._type
473
+ ),
474
+ seq(
475
+ kw("FORMAT"),
476
+ $.string_literal
477
+ ),
478
+ kw("AUTO-RETURN")
479
+ )
480
+ ),
481
+ ),
482
+
483
+ message_pause:($) => kw("PAUSE"),
484
+
485
+
379
486
  // button_tuning: ($) =>
380
487
  // choice(
381
488
  // seq(kw("AUTO-GO"), optional(kw("AUTO-ENDKEY"))),
@@ -470,8 +577,8 @@ module.exports = grammar({
470
577
  seq(kw("MAP"), $.identifier),
471
578
  seq(
472
579
  kw("CONVERT"),
473
- optional(seq(kw("TARGET"), $.string_literal)),
474
- optional(seq(kw("SOURCE"), $.string_literal))
580
+ optional(seq(kw("TARGET"), choice($.identifier, $.string_literal))),
581
+ optional(seq(kw("SOURCE"), choice($.identifier, $.string_literal)))
475
582
  ),
476
583
  ),
477
584
 
@@ -632,7 +739,7 @@ module.exports = grammar({
632
739
  seq($._name, $.generic_expression),
633
740
 
634
741
  return_type: ($) =>
635
- seq(choice(kw("RETURNS"), kw("RETURN")), field("type", $._type)),
742
+ seq(choice(kw("RETURNS"), alias($._return_keyword, "RETURN")), field("type", $._type)),
636
743
 
637
744
  member_modifier: ($) => choice(kw("ABSTRACT"), kw("OVERRIDE"), kw("FINAL")),
638
745
 
@@ -645,7 +752,7 @@ module.exports = grammar({
645
752
  prec.right(
646
753
  1,
647
754
  seq(
648
- field("array", choice($.identifier, $.object_access)),
755
+ field("array", choice($.identifier, $.qualified_name, $.object_access)),
649
756
  $.array_literal,
650
757
  )
651
758
  ),
@@ -672,7 +779,7 @@ module.exports = grammar({
672
779
  choice(
673
780
  $.ternary_expression,
674
781
  seq(
675
- choice($._name, $.object_access),
782
+ choice($._name, $.object_access, $.member_access),
676
783
  optional($.type_tuning)
677
784
  ),
678
785
  seq(
@@ -692,7 +799,8 @@ module.exports = grammar({
692
799
  $.constant,
693
800
  $._binary_expression,
694
801
  $.unary_expression,
695
- $.function_call
802
+ $.function_call,
803
+ $.boolean_literal
696
804
  ),
697
805
  repeat($.parameter_tuning)
698
806
  )
@@ -897,7 +1005,7 @@ module.exports = grammar({
897
1005
  seq(kw("NEXT"), optional(field("label", $.identifier))),
898
1006
  seq(kw("RETRY"), optional(field("label", $.identifier))),
899
1007
  seq(
900
- kw("RETURN"),
1008
+ alias($._return_keyword, "RETURN"),
901
1009
  $._return_action
902
1010
  )
903
1011
  ),
@@ -917,7 +1025,8 @@ module.exports = grammar({
917
1025
  seq(
918
1026
  $.assignment,
919
1027
  kw("TO"),
920
- choice($.function_call, $._integer_literal, $.identifier, $.object_access),
1028
+ optional(choice(kw("BROWSE"), kw("SELECTION-LIST"), kw("LIST-BOX"))),
1029
+ choice($.function_call, $._integer_literal, $._name, $.object_access, $.multiplicative_expression, $.additive_expression),
921
1030
  optional(seq(kw("BY"), choice($._integer_literal, $.unary_expression)))
922
1031
  ),
923
1032
 
@@ -1515,7 +1624,7 @@ module.exports = grammar({
1515
1624
  seq(
1516
1625
  $._define,
1517
1626
  optional(
1518
- choice(alias($._input_keyword, "INPUT"), alias($._output_keyword, "OUTPUT"), kw("INPUT-OUTPUT"), kw("RETURN"))
1627
+ choice(alias($._input_keyword, "INPUT"), alias($._output_keyword, "OUTPUT"), kw("INPUT-OUTPUT"), alias($._return_keyword, "RETURN"))
1519
1628
  ),
1520
1629
  choice(kw("PARAMETER"), kw("PARAM")),
1521
1630
  optional($._parameter_definition_option),
@@ -1665,6 +1774,27 @@ module.exports = grammar({
1665
1774
 
1666
1775
  // STATEMENTS
1667
1776
 
1777
+ message_statement:($) =>
1778
+ seq(
1779
+ kw("MESSAGE"),
1780
+ repeat1(
1781
+ choice(
1782
+ $._message_statement_expression,
1783
+ seq(
1784
+ kw("SKIP"),
1785
+ optional(seq("(", $._integer_literal, ")"))
1786
+ )
1787
+ )
1788
+ ),
1789
+ repeat($._message_tuning),
1790
+ optional(seq(
1791
+ kw("IN"),
1792
+ kw("WINDOW"),
1793
+ $._name
1794
+ )),
1795
+ $._terminator
1796
+ ),
1797
+
1668
1798
  null_statement: ($) => seq($.object_access, $._terminator),
1669
1799
 
1670
1800
  using_statement: ($) =>
@@ -1742,7 +1872,7 @@ module.exports = grammar({
1742
1872
  $._block_terminator
1743
1873
  ),
1744
1874
 
1745
- variable_assignment: ($) => seq($.assignment, $._terminator),
1875
+ variable_assignment: ($) => seq($.assignment, optional(kw("NO-ERROR")), $._terminator),
1746
1876
 
1747
1877
  assignment: ($) =>
1748
1878
  prec.right(
@@ -1799,7 +1929,7 @@ module.exports = grammar({
1799
1929
  repeat($._repeat_phrase),
1800
1930
  optional($.preselect_phrase),
1801
1931
  optional($.while_phrase),
1802
- optional($._on_phrase),
1932
+ repeat($._on_phrase),
1803
1933
  $.body,
1804
1934
  $._block_terminator
1805
1935
  ),
@@ -1812,11 +1942,11 @@ module.exports = grammar({
1812
1942
  ),
1813
1943
 
1814
1944
  return_statement: ($) =>
1815
- seq(
1816
- kw("RETURN"),
1945
+ prec(1, seq(
1946
+ alias($._return_keyword, "RETURN"),
1817
1947
  optional($._return_action),
1818
1948
  $._terminator
1819
- ),
1949
+ )),
1820
1950
 
1821
1951
  input_output_statement: ($) =>
1822
1952
  seq(
@@ -1828,8 +1958,8 @@ module.exports = grammar({
1828
1958
  ),
1829
1959
  ),
1830
1960
  $._input_output_option,
1831
- repeat($.stream_tuning),
1832
1961
  repeat($.stream_flag),
1962
+ repeat($.stream_tuning),
1833
1963
  optional($.constant),
1834
1964
  $._terminator
1835
1965
  ),
@@ -1840,6 +1970,19 @@ module.exports = grammar({
1840
1970
  seq(
1841
1971
  choice(kw("FROM"), kw("TO")),
1842
1972
  choice($.string_literal, $.function_call)
1973
+ ),
1974
+ seq(
1975
+ kw("THROUGH"),
1976
+ choice($.identifier, seq(kw("VALUE"), "(", $._expression, ")")),
1977
+ repeat(
1978
+ choice(
1979
+ $.identifier,
1980
+ $.string_literal,
1981
+ $.number_literal,
1982
+ seq(kw("VALUE"), "(", $._expression, ")")
1983
+ )
1984
+ ),
1985
+ optional(seq(">", $.identifier))
1843
1986
  )
1844
1987
  ),
1845
1988
 
@@ -1848,7 +1991,7 @@ module.exports = grammar({
1848
1991
  optional($.label),
1849
1992
  alias($._for_keyword, "FOR"),
1850
1993
  _list($._for_phrase, ","),
1851
- repeat(choice($._on_phrase, $.frame_phrase)),
1994
+ repeat(choice($._on_phrase, $.frame_phrase, $.while_phrase)),
1852
1995
  $.body,
1853
1996
  $._block_terminator
1854
1997
  ),
@@ -1978,8 +2121,9 @@ module.exports = grammar({
1978
2121
  kw("RUN"),
1979
2122
  field(
1980
2123
  "procedure",
1981
- choice($._name, $.function_call, $.file_name)
2124
+ choice($._name, $.function_call, $.file_name, $.string_literal)
1982
2125
  ),
2126
+ optional($.function_call_argument),
1983
2127
  repeat($.run_tuning),
1984
2128
  optional(alias($.function_arguments, $.arguments)),
1985
2129
  optional(kw("NO-ERROR")),
@@ -2000,7 +2144,7 @@ module.exports = grammar({
2000
2144
  optional($.label),
2001
2145
  kw("DO"),
2002
2146
  repeat($._do_tuning),
2003
- optional($._on_phrase),
2147
+ repeat($._on_phrase),
2004
2148
  optional($.frame_phrase),
2005
2149
  $.body,
2006
2150
  $._block_terminator
@@ -2209,6 +2353,33 @@ module.exports = grammar({
2209
2353
  $._binary_expression
2210
2354
  ),
2211
2355
 
2356
+ _message_statement_expression: ($) =>
2357
+ choice(
2358
+ $.unary_expression,
2359
+ $.null_expression,
2360
+ $.ternary_expression,
2361
+ $.available_expression,
2362
+ $.accumulate_expression,
2363
+ $.parenthesized_expression,
2364
+ $.ambiguous_expression,
2365
+ $.current_changed_expression,
2366
+ $.locked_expression,
2367
+ $.can_find_expression,
2368
+ $.additive_expression,
2369
+ $.multiplicative_expression,
2370
+ $.boolean_literal,
2371
+ $.string_literal,
2372
+ $.date_literal,
2373
+ $.number_literal,
2374
+ $.array_literal,
2375
+ $.object_access,
2376
+ $.member_access,
2377
+ $.array_access,
2378
+ $.function_call,
2379
+ $._name,
2380
+ $.constant
2381
+ ),
2382
+
2212
2383
  // SUPERTYPES
2213
2384
 
2214
2385
  _expression: ($) =>
@@ -2248,6 +2419,7 @@ module.exports = grammar({
2248
2419
  _statement: ($) =>
2249
2420
  choice(
2250
2421
  $.var_statement,
2422
+ $.message_statement,
2251
2423
  $.null_statement,
2252
2424
  $.procedure_statement,
2253
2425
  $.function_statement,
@@ -2266,8 +2438,6 @@ module.exports = grammar({
2266
2438
  $.undo_statement,
2267
2439
  $.error_scope_statement,
2268
2440
  $.using_statement,
2269
- // $.class_statement,
2270
- // $.interface_statement,
2271
2441
  $.on_statement,
2272
2442
  $.prompt_for_statement,
2273
2443
  $.release_statement,
@@ -2275,10 +2445,7 @@ module.exports = grammar({
2275
2445
  $.enum_statement,
2276
2446
  $.abl_statement,
2277
2447
 
2278
- // $._definition,
2279
-
2280
2448
  $.variable_assignment,
2281
- // $.do_block,
2282
2449
  $.preprocessor_directive,
2283
2450
  $.include,
2284
2451
  $.annotation //TODO: Check should it be in supertype
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-abl",
3
- "version": "0.0.51",
3
+ "version": "0.1.1",
4
4
  "description": "ABL grammar for tree-sitter",
5
5
  "repository": "https://github.com/eglekaz/tree-sitter-abl",
6
6
  "keywords": [
package/parser.obj CHANGED
Binary file
package/scanner.obj CHANGED
Binary file