plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


e69a5b5 — Peter John 2023-04-30T23:12:11+05:30
add const expressions

Generated files not shown: src/parser.c

grammar.js CHANGED
@@ -3,7 +3,6 @@ const NEWLINE = /\r?\n/;
3
3
  module.exports = grammar({
4
4
  name: "palm",
5
5
  extras: ($) => [
6
- ";",
7
6
  NEWLINE,
8
7
  /\s/,
9
8
  $.module_comment,
@@ -22,7 +21,7 @@ module.exports = grammar({
22
21
  statement_comment: ($) => token(seq("///", /.*/)),
23
22
  comment: ($) => token(seq("//", /.*/)),
24
23
 
25
- /* Import statements */
24
+ /* Import _statement_seq */
26
25
  import: ($) =>
27
26
  seq(
28
27
  "import",
@@ -45,7 +44,7 @@ module.exports = grammar({
45
44
  )
46
45
  ),
47
46
 
48
- /* Constant statements */
47
+ /* Constant _statement_seq */
49
48
  // _constant_type_annotation: ($) => seq(":", field("type", $._constant_type)),
50
49
 
51
50
  /* Declarations */
@@ -94,30 +93,48 @@ module.exports = grammar({
94
93
  field("body", seq("{", $._statement_seq, "}"))
95
94
  ),
96
95
 
96
+ const: ($) => seq(
97
+ "const",
98
+ $.identifier,
99
+ "=",
100
+ field("value", $._const_expression)
101
+ ),
102
+ _const_expression: ($) => choice($._const_expression_unit, $._const_binary_expression),
103
+ _const_binary_expression: ($) => arithmeticExpression($._const_expression),
104
+ _const_expression_unit: ($) =>
105
+ choice(
106
+ $.string,
107
+ $.integer,
108
+ $.float,
109
+ $.const_record,
110
+ $.const_function_call,
111
+ ),
112
+
113
+ const_record: ($) =>
114
+ seq(
115
+ field("name", choice($.constructor_name, $.remote_constructor_name)),
116
+ optional(field("arguments", $.arguments))
117
+ ),
118
+
119
+ const_function_call: ($) =>
120
+ seq(
121
+ field("function", choice($.function_name, $.remote_function_identifier)),
122
+ field("arguments", $.const_arguments)
123
+ ),
124
+
125
+ const_arguments: ($) => seq("(", optional(series_of($.const_argument, ",")), ")"),
126
+ const_argument: ($) =>
127
+ seq(
128
+ optional(seq(field("label", $.label), ":")),
129
+ field("value", $._const_expression)),
130
+
97
131
  /* Expressions */
98
132
 
99
133
  _name_param: ($) => field("name", $.identifier),
100
134
  _statement_seq: ($) => repeat1($._statement),
101
135
  _statement: ($) => choice($._expression, $.let),
102
136
  _expression: ($) => choice($._expression_unit, $.binary_expression),
103
- binary_expression: ($) =>
104
- choice(
105
- binaryExpr(prec.left, 1, "||", $._expression),
106
- binaryExpr(prec.left, 2, "&&", $._expression),
137
+ binary_expression: ($) => arithmeticExpression($._expression),
107
- binaryExpr(prec.left, 3, "==", $._expression),
108
- binaryExpr(prec.left, 3, "!=", $._expression),
109
- binaryExpr(prec.left, 4, "<", $._expression),
110
- binaryExpr(prec.left, 4, "<=", $._expression),
111
- binaryExpr(prec.left, 4, ">", $._expression),
112
- binaryExpr(prec.left, 4, ">=", $._expression),
113
- binaryExpr(prec.left, 5, "|>", $._expression),
114
- binaryExpr(prec.left, 6, "+", $._expression),
115
- binaryExpr(prec.left, 6, "-", $._expression),
116
- binaryExpr(prec.left, 7, "*", $._expression),
117
- binaryExpr(prec.left, 7, "/", $._expression),
118
- binaryExpr(prec.left, 7, "%", $._expression),
119
- binaryExpr(prec.left, 7, "<>", $._expression)
120
- ),
121
138
  _expression_unit: ($) =>
122
139
  choice(
123
140
  $.string,
@@ -135,8 +152,8 @@ module.exports = grammar({
135
152
  // $.assert,
136
153
  $.negation,
137
154
  $.record_update,
138
- $.field_access,
155
+ // $.field_access,
139
- $.function_call
156
+ // $.function_call
140
157
  ),
141
158
  record: ($) =>
142
159
  seq(
@@ -225,7 +242,7 @@ module.exports = grammar({
225
242
  $.field_access,
226
243
  ),
227
244
 
228
-
245
+
229
246
  _maybe_function_expression: ($) =>
230
247
  choice(
231
248
  $.identifier,
@@ -261,12 +278,10 @@ module.exports = grammar({
261
278
  ),
262
279
 
263
280
  negation: ($) => seq("!", $._expression_unit),
264
- const: ($) => seq("const", $._assignment),
265
281
  let: ($) => seq("let", $._assignment),
266
282
  _assignment: ($) =>
267
283
  seq(
268
284
  field("pattern", $._pattern_expression),
269
- optional($._type_annotation),
270
285
  "=",
271
286
  field("value", $._expression)
272
287
  ),
@@ -361,12 +376,15 @@ module.exports = grammar({
361
376
  _interpolation: ($) => choice(seq("{", $.identifier, "}")),
362
377
  escape_sequence: ($) => token.immediate(/\\[efnrt\"\\]/),
363
378
  // identifier: ($) => $._name,
364
- identifier: ($) => /[a-zA-Z_][a-zA-Z_0-9]*/,
379
+ identifier: ($) => /[_a-z][_0-9a-z]*/,
365
380
  label: ($) => $._name,
366
381
  discard: ($) => $._discard_name,
367
382
  type_identifier: ($) => $._upname,
368
383
  constructor_name: ($) => $._upname,
384
+ function_name: ($) => $._name,
369
- remote_type_identifier: ($) =>
385
+ remote_function_identifier: ($) =>
386
+ seq(field("module", $.identifier), ".", field("name", $.identifier)),
387
+ remote_constructor_name: ($) =>
370
388
  seq(field("module", $.identifier), ".", field("name", $.type_identifier)),
371
389
  _type_annotation: ($) => seq(":", field("type", $._type)),
372
390
  _type: ($) =>
@@ -383,6 +401,26 @@ function series_of(rule, separator) {
383
401
  return seq(rule, repeat(seq(separator, rule)), optional(separator));
384
402
  }
385
403
 
404
+ function arithmeticExpression(exprType) {
405
+ return choice(
406
+ binaryExpr(prec.left, 1, "||", exprType),
407
+ binaryExpr(prec.left, 2, "&&", exprType),
408
+ binaryExpr(prec.left, 3, "==", exprType),
409
+ binaryExpr(prec.left, 3, "!=", exprType),
410
+ binaryExpr(prec.left, 4, "<", exprType),
411
+ binaryExpr(prec.left, 4, "<=", exprType),
412
+ binaryExpr(prec.left, 4, ">", exprType),
413
+ binaryExpr(prec.left, 4, ">=", exprType),
414
+ binaryExpr(prec.left, 5, "|>", exprType),
415
+ binaryExpr(prec.left, 6, "+", exprType),
416
+ binaryExpr(prec.left, 6, "-", exprType),
417
+ binaryExpr(prec.left, 7, "*", exprType),
418
+ binaryExpr(prec.left, 7, "/", exprType),
419
+ binaryExpr(prec.left, 7, "%", exprType),
420
+ binaryExpr(prec.left, 7, "<>", exprType)
421
+ )
422
+ }
423
+
386
424
  function binaryExpr(assoc, precedence, operator, expr) {
387
425
  return assoc(
388
426
  precedence,
src/grammar.json CHANGED
@@ -712,6 +712,733 @@
712
712
  }
713
713
  ]
714
714
  },
715
+ "const": {
716
+ "type": "SEQ",
717
+ "members": [
718
+ {
719
+ "type": "STRING",
720
+ "value": "const"
721
+ },
722
+ {
723
+ "type": "SYMBOL",
724
+ "name": "identifier"
725
+ },
726
+ {
727
+ "type": "STRING",
728
+ "value": "="
729
+ },
730
+ {
731
+ "type": "FIELD",
732
+ "name": "value",
733
+ "content": {
734
+ "type": "SYMBOL",
735
+ "name": "_const_expression"
736
+ }
737
+ }
738
+ ]
739
+ },
740
+ "_const_expression": {
741
+ "type": "CHOICE",
742
+ "members": [
743
+ {
744
+ "type": "SYMBOL",
745
+ "name": "_const_expression_unit"
746
+ },
747
+ {
748
+ "type": "SYMBOL",
749
+ "name": "_const_binary_expression"
750
+ }
751
+ ]
752
+ },
753
+ "_const_binary_expression": {
754
+ "type": "CHOICE",
755
+ "members": [
756
+ {
757
+ "type": "PREC_LEFT",
758
+ "value": 1,
759
+ "content": {
760
+ "type": "SEQ",
761
+ "members": [
762
+ {
763
+ "type": "FIELD",
764
+ "name": "left",
765
+ "content": {
766
+ "type": "SYMBOL",
767
+ "name": "_const_expression"
768
+ }
769
+ },
770
+ {
771
+ "type": "FIELD",
772
+ "name": "operator",
773
+ "content": {
774
+ "type": "STRING",
775
+ "value": "||"
776
+ }
777
+ },
778
+ {
779
+ "type": "FIELD",
780
+ "name": "right",
781
+ "content": {
782
+ "type": "SYMBOL",
783
+ "name": "_const_expression"
784
+ }
785
+ }
786
+ ]
787
+ }
788
+ },
789
+ {
790
+ "type": "PREC_LEFT",
791
+ "value": 2,
792
+ "content": {
793
+ "type": "SEQ",
794
+ "members": [
795
+ {
796
+ "type": "FIELD",
797
+ "name": "left",
798
+ "content": {
799
+ "type": "SYMBOL",
800
+ "name": "_const_expression"
801
+ }
802
+ },
803
+ {
804
+ "type": "FIELD",
805
+ "name": "operator",
806
+ "content": {
807
+ "type": "STRING",
808
+ "value": "&&"
809
+ }
810
+ },
811
+ {
812
+ "type": "FIELD",
813
+ "name": "right",
814
+ "content": {
815
+ "type": "SYMBOL",
816
+ "name": "_const_expression"
817
+ }
818
+ }
819
+ ]
820
+ }
821
+ },
822
+ {
823
+ "type": "PREC_LEFT",
824
+ "value": 3,
825
+ "content": {
826
+ "type": "SEQ",
827
+ "members": [
828
+ {
829
+ "type": "FIELD",
830
+ "name": "left",
831
+ "content": {
832
+ "type": "SYMBOL",
833
+ "name": "_const_expression"
834
+ }
835
+ },
836
+ {
837
+ "type": "FIELD",
838
+ "name": "operator",
839
+ "content": {
840
+ "type": "STRING",
841
+ "value": "=="
842
+ }
843
+ },
844
+ {
845
+ "type": "FIELD",
846
+ "name": "right",
847
+ "content": {
848
+ "type": "SYMBOL",
849
+ "name": "_const_expression"
850
+ }
851
+ }
852
+ ]
853
+ }
854
+ },
855
+ {
856
+ "type": "PREC_LEFT",
857
+ "value": 3,
858
+ "content": {
859
+ "type": "SEQ",
860
+ "members": [
861
+ {
862
+ "type": "FIELD",
863
+ "name": "left",
864
+ "content": {
865
+ "type": "SYMBOL",
866
+ "name": "_const_expression"
867
+ }
868
+ },
869
+ {
870
+ "type": "FIELD",
871
+ "name": "operator",
872
+ "content": {
873
+ "type": "STRING",
874
+ "value": "!="
875
+ }
876
+ },
877
+ {
878
+ "type": "FIELD",
879
+ "name": "right",
880
+ "content": {
881
+ "type": "SYMBOL",
882
+ "name": "_const_expression"
883
+ }
884
+ }
885
+ ]
886
+ }
887
+ },
888
+ {
889
+ "type": "PREC_LEFT",
890
+ "value": 4,
891
+ "content": {
892
+ "type": "SEQ",
893
+ "members": [
894
+ {
895
+ "type": "FIELD",
896
+ "name": "left",
897
+ "content": {
898
+ "type": "SYMBOL",
899
+ "name": "_const_expression"
900
+ }
901
+ },
902
+ {
903
+ "type": "FIELD",
904
+ "name": "operator",
905
+ "content": {
906
+ "type": "STRING",
907
+ "value": "<"
908
+ }
909
+ },
910
+ {
911
+ "type": "FIELD",
912
+ "name": "right",
913
+ "content": {
914
+ "type": "SYMBOL",
915
+ "name": "_const_expression"
916
+ }
917
+ }
918
+ ]
919
+ }
920
+ },
921
+ {
922
+ "type": "PREC_LEFT",
923
+ "value": 4,
924
+ "content": {
925
+ "type": "SEQ",
926
+ "members": [
927
+ {
928
+ "type": "FIELD",
929
+ "name": "left",
930
+ "content": {
931
+ "type": "SYMBOL",
932
+ "name": "_const_expression"
933
+ }
934
+ },
935
+ {
936
+ "type": "FIELD",
937
+ "name": "operator",
938
+ "content": {
939
+ "type": "STRING",
940
+ "value": "<="
941
+ }
942
+ },
943
+ {
944
+ "type": "FIELD",
945
+ "name": "right",
946
+ "content": {
947
+ "type": "SYMBOL",
948
+ "name": "_const_expression"
949
+ }
950
+ }
951
+ ]
952
+ }
953
+ },
954
+ {
955
+ "type": "PREC_LEFT",
956
+ "value": 4,
957
+ "content": {
958
+ "type": "SEQ",
959
+ "members": [
960
+ {
961
+ "type": "FIELD",
962
+ "name": "left",
963
+ "content": {
964
+ "type": "SYMBOL",
965
+ "name": "_const_expression"
966
+ }
967
+ },
968
+ {
969
+ "type": "FIELD",
970
+ "name": "operator",
971
+ "content": {
972
+ "type": "STRING",
973
+ "value": ">"
974
+ }
975
+ },
976
+ {
977
+ "type": "FIELD",
978
+ "name": "right",
979
+ "content": {
980
+ "type": "SYMBOL",
981
+ "name": "_const_expression"
982
+ }
983
+ }
984
+ ]
985
+ }
986
+ },
987
+ {
988
+ "type": "PREC_LEFT",
989
+ "value": 4,
990
+ "content": {
991
+ "type": "SEQ",
992
+ "members": [
993
+ {
994
+ "type": "FIELD",
995
+ "name": "left",
996
+ "content": {
997
+ "type": "SYMBOL",
998
+ "name": "_const_expression"
999
+ }
1000
+ },
1001
+ {
1002
+ "type": "FIELD",
1003
+ "name": "operator",
1004
+ "content": {
1005
+ "type": "STRING",
1006
+ "value": ">="
1007
+ }
1008
+ },
1009
+ {
1010
+ "type": "FIELD",
1011
+ "name": "right",
1012
+ "content": {
1013
+ "type": "SYMBOL",
1014
+ "name": "_const_expression"
1015
+ }
1016
+ }
1017
+ ]
1018
+ }
1019
+ },
1020
+ {
1021
+ "type": "PREC_LEFT",
1022
+ "value": 5,
1023
+ "content": {
1024
+ "type": "SEQ",
1025
+ "members": [
1026
+ {
1027
+ "type": "FIELD",
1028
+ "name": "left",
1029
+ "content": {
1030
+ "type": "SYMBOL",
1031
+ "name": "_const_expression"
1032
+ }
1033
+ },
1034
+ {
1035
+ "type": "FIELD",
1036
+ "name": "operator",
1037
+ "content": {
1038
+ "type": "STRING",
1039
+ "value": "|>"
1040
+ }
1041
+ },
1042
+ {
1043
+ "type": "FIELD",
1044
+ "name": "right",
1045
+ "content": {
1046
+ "type": "SYMBOL",
1047
+ "name": "_const_expression"
1048
+ }
1049
+ }
1050
+ ]
1051
+ }
1052
+ },
1053
+ {
1054
+ "type": "PREC_LEFT",
1055
+ "value": 6,
1056
+ "content": {
1057
+ "type": "SEQ",
1058
+ "members": [
1059
+ {
1060
+ "type": "FIELD",
1061
+ "name": "left",
1062
+ "content": {
1063
+ "type": "SYMBOL",
1064
+ "name": "_const_expression"
1065
+ }
1066
+ },
1067
+ {
1068
+ "type": "FIELD",
1069
+ "name": "operator",
1070
+ "content": {
1071
+ "type": "STRING",
1072
+ "value": "+"
1073
+ }
1074
+ },
1075
+ {
1076
+ "type": "FIELD",
1077
+ "name": "right",
1078
+ "content": {
1079
+ "type": "SYMBOL",
1080
+ "name": "_const_expression"
1081
+ }
1082
+ }
1083
+ ]
1084
+ }
1085
+ },
1086
+ {
1087
+ "type": "PREC_LEFT",
1088
+ "value": 6,
1089
+ "content": {
1090
+ "type": "SEQ",
1091
+ "members": [
1092
+ {
1093
+ "type": "FIELD",
1094
+ "name": "left",
1095
+ "content": {
1096
+ "type": "SYMBOL",
1097
+ "name": "_const_expression"
1098
+ }
1099
+ },
1100
+ {
1101
+ "type": "FIELD",
1102
+ "name": "operator",
1103
+ "content": {
1104
+ "type": "STRING",
1105
+ "value": "-"
1106
+ }
1107
+ },
1108
+ {
1109
+ "type": "FIELD",
1110
+ "name": "right",
1111
+ "content": {
1112
+ "type": "SYMBOL",
1113
+ "name": "_const_expression"
1114
+ }
1115
+ }
1116
+ ]
1117
+ }
1118
+ },
1119
+ {
1120
+ "type": "PREC_LEFT",
1121
+ "value": 7,
1122
+ "content": {
1123
+ "type": "SEQ",
1124
+ "members": [
1125
+ {
1126
+ "type": "FIELD",
1127
+ "name": "left",
1128
+ "content": {
1129
+ "type": "SYMBOL",
1130
+ "name": "_const_expression"
1131
+ }
1132
+ },
1133
+ {
1134
+ "type": "FIELD",
1135
+ "name": "operator",
1136
+ "content": {
1137
+ "type": "STRING",
1138
+ "value": "*"
1139
+ }
1140
+ },
1141
+ {
1142
+ "type": "FIELD",
1143
+ "name": "right",
1144
+ "content": {
1145
+ "type": "SYMBOL",
1146
+ "name": "_const_expression"
1147
+ }
1148
+ }
1149
+ ]
1150
+ }
1151
+ },
1152
+ {
1153
+ "type": "PREC_LEFT",
1154
+ "value": 7,
1155
+ "content": {
1156
+ "type": "SEQ",
1157
+ "members": [
1158
+ {
1159
+ "type": "FIELD",
1160
+ "name": "left",
1161
+ "content": {
1162
+ "type": "SYMBOL",
1163
+ "name": "_const_expression"
1164
+ }
1165
+ },
1166
+ {
1167
+ "type": "FIELD",
1168
+ "name": "operator",
1169
+ "content": {
1170
+ "type": "STRING",
1171
+ "value": "/"
1172
+ }
1173
+ },
1174
+ {
1175
+ "type": "FIELD",
1176
+ "name": "right",
1177
+ "content": {
1178
+ "type": "SYMBOL",
1179
+ "name": "_const_expression"
1180
+ }
1181
+ }
1182
+ ]
1183
+ }
1184
+ },
1185
+ {
1186
+ "type": "PREC_LEFT",
1187
+ "value": 7,
1188
+ "content": {
1189
+ "type": "SEQ",
1190
+ "members": [
1191
+ {
1192
+ "type": "FIELD",
1193
+ "name": "left",
1194
+ "content": {
1195
+ "type": "SYMBOL",
1196
+ "name": "_const_expression"
1197
+ }
1198
+ },
1199
+ {
1200
+ "type": "FIELD",
1201
+ "name": "operator",
1202
+ "content": {
1203
+ "type": "STRING",
1204
+ "value": "%"
1205
+ }
1206
+ },
1207
+ {
1208
+ "type": "FIELD",
1209
+ "name": "right",
1210
+ "content": {
1211
+ "type": "SYMBOL",
1212
+ "name": "_const_expression"
1213
+ }
1214
+ }
1215
+ ]
1216
+ }
1217
+ },
1218
+ {
1219
+ "type": "PREC_LEFT",
1220
+ "value": 7,
1221
+ "content": {
1222
+ "type": "SEQ",
1223
+ "members": [
1224
+ {
1225
+ "type": "FIELD",
1226
+ "name": "left",
1227
+ "content": {
1228
+ "type": "SYMBOL",
1229
+ "name": "_const_expression"
1230
+ }
1231
+ },
1232
+ {
1233
+ "type": "FIELD",
1234
+ "name": "operator",
1235
+ "content": {
1236
+ "type": "STRING",
1237
+ "value": "<>"
1238
+ }
1239
+ },
1240
+ {
1241
+ "type": "FIELD",
1242
+ "name": "right",
1243
+ "content": {
1244
+ "type": "SYMBOL",
1245
+ "name": "_const_expression"
1246
+ }
1247
+ }
1248
+ ]
1249
+ }
1250
+ }
1251
+ ]
1252
+ },
1253
+ "_const_expression_unit": {
1254
+ "type": "CHOICE",
1255
+ "members": [
1256
+ {
1257
+ "type": "SYMBOL",
1258
+ "name": "string"
1259
+ },
1260
+ {
1261
+ "type": "SYMBOL",
1262
+ "name": "integer"
1263
+ },
1264
+ {
1265
+ "type": "SYMBOL",
1266
+ "name": "float"
1267
+ },
1268
+ {
1269
+ "type": "SYMBOL",
1270
+ "name": "const_record"
1271
+ },
1272
+ {
1273
+ "type": "SYMBOL",
1274
+ "name": "const_function_call"
1275
+ }
1276
+ ]
1277
+ },
1278
+ "const_record": {
1279
+ "type": "SEQ",
1280
+ "members": [
1281
+ {
1282
+ "type": "FIELD",
1283
+ "name": "name",
1284
+ "content": {
1285
+ "type": "CHOICE",
1286
+ "members": [
1287
+ {
1288
+ "type": "SYMBOL",
1289
+ "name": "constructor_name"
1290
+ },
1291
+ {
1292
+ "type": "SYMBOL",
1293
+ "name": "remote_constructor_name"
1294
+ }
1295
+ ]
1296
+ }
1297
+ },
1298
+ {
1299
+ "type": "CHOICE",
1300
+ "members": [
1301
+ {
1302
+ "type": "FIELD",
1303
+ "name": "arguments",
1304
+ "content": {
1305
+ "type": "SYMBOL",
1306
+ "name": "arguments"
1307
+ }
1308
+ },
1309
+ {
1310
+ "type": "BLANK"
1311
+ }
1312
+ ]
1313
+ }
1314
+ ]
1315
+ },
1316
+ "const_function_call": {
1317
+ "type": "SEQ",
1318
+ "members": [
1319
+ {
1320
+ "type": "FIELD",
1321
+ "name": "function",
1322
+ "content": {
1323
+ "type": "CHOICE",
1324
+ "members": [
1325
+ {
1326
+ "type": "SYMBOL",
1327
+ "name": "function_name"
1328
+ },
1329
+ {
1330
+ "type": "SYMBOL",
1331
+ "name": "remote_function_identifier"
1332
+ }
1333
+ ]
1334
+ }
1335
+ },
1336
+ {
1337
+ "type": "FIELD",
1338
+ "name": "arguments",
1339
+ "content": {
1340
+ "type": "SYMBOL",
1341
+ "name": "const_arguments"
1342
+ }
1343
+ }
1344
+ ]
1345
+ },
1346
+ "const_arguments": {
1347
+ "type": "SEQ",
1348
+ "members": [
1349
+ {
1350
+ "type": "STRING",
1351
+ "value": "("
1352
+ },
1353
+ {
1354
+ "type": "CHOICE",
1355
+ "members": [
1356
+ {
1357
+ "type": "SEQ",
1358
+ "members": [
1359
+ {
1360
+ "type": "SYMBOL",
1361
+ "name": "const_argument"
1362
+ },
1363
+ {
1364
+ "type": "REPEAT",
1365
+ "content": {
1366
+ "type": "SEQ",
1367
+ "members": [
1368
+ {
1369
+ "type": "STRING",
1370
+ "value": ","
1371
+ },
1372
+ {
1373
+ "type": "SYMBOL",
1374
+ "name": "const_argument"
1375
+ }
1376
+ ]
1377
+ }
1378
+ },
1379
+ {
1380
+ "type": "CHOICE",
1381
+ "members": [
1382
+ {
1383
+ "type": "STRING",
1384
+ "value": ","
1385
+ },
1386
+ {
1387
+ "type": "BLANK"
1388
+ }
1389
+ ]
1390
+ }
1391
+ ]
1392
+ },
1393
+ {
1394
+ "type": "BLANK"
1395
+ }
1396
+ ]
1397
+ },
1398
+ {
1399
+ "type": "STRING",
1400
+ "value": ")"
1401
+ }
1402
+ ]
1403
+ },
1404
+ "const_argument": {
1405
+ "type": "SEQ",
1406
+ "members": [
1407
+ {
1408
+ "type": "CHOICE",
1409
+ "members": [
1410
+ {
1411
+ "type": "SEQ",
1412
+ "members": [
1413
+ {
1414
+ "type": "FIELD",
1415
+ "name": "label",
1416
+ "content": {
1417
+ "type": "SYMBOL",
1418
+ "name": "label"
1419
+ }
1420
+ },
1421
+ {
1422
+ "type": "STRING",
1423
+ "value": ":"
1424
+ }
1425
+ ]
1426
+ },
1427
+ {
1428
+ "type": "BLANK"
1429
+ }
1430
+ ]
1431
+ },
1432
+ {
1433
+ "type": "FIELD",
1434
+ "name": "value",
1435
+ "content": {
1436
+ "type": "SYMBOL",
1437
+ "name": "_const_expression"
1438
+ }
1439
+ }
1440
+ ]
1441
+ },
715
1442
  "_name_param": {
716
1443
  "type": "FIELD",
717
1444
  "name": "name",
@@ -1299,14 +2026,6 @@
1299
2026
  {
1300
2027
  "type": "SYMBOL",
1301
2028
  "name": "record_update"
1302
- },
1303
- {
1304
- "type": "SYMBOL",
1305
- "name": "field_access"
1306
- },
1307
- {
1308
- "type": "SYMBOL",
1309
- "name": "function_call"
1310
2029
  }
1311
2030
  ]
1312
2031
  },
@@ -1970,19 +2689,6 @@
1970
2689
  }
1971
2690
  ]
1972
2691
  },
1973
- "const": {
1974
- "type": "SEQ",
1975
- "members": [
1976
- {
1977
- "type": "STRING",
1978
- "value": "const"
1979
- },
1980
- {
1981
- "type": "SYMBOL",
1982
- "name": "_assignment"
1983
- }
1984
- ]
1985
- },
1986
2692
  "let": {
1987
2693
  "type": "SEQ",
1988
2694
  "members": [
@@ -2007,18 +2713,6 @@
2007
2713
  "name": "_pattern_expression"
2008
2714
  }
2009
2715
  },
2010
- {
2011
- "type": "CHOICE",
2012
- "members": [
2013
- {
2014
- "type": "SYMBOL",
2015
- "name": "_type_annotation"
2016
- },
2017
- {
2018
- "type": "BLANK"
2019
- }
2020
- ]
2021
- },
2022
2716
  {
2023
2717
  "type": "STRING",
2024
2718
  "value": "="
@@ -2734,7 +3428,7 @@
2734
3428
  },
2735
3429
  "identifier": {
2736
3430
  "type": "PATTERN",
2737
- "value": "[a-zA-Z_][a-zA-Z_0-9]*"
3431
+ "value": "[_a-z][_0-9a-z]*"
2738
3432
  },
2739
3433
  "label": {
2740
3434
  "type": "SYMBOL",
@@ -2752,7 +3446,36 @@
2752
3446
  "type": "SYMBOL",
2753
3447
  "name": "_upname"
2754
3448
  },
3449
+ "function_name": {
3450
+ "type": "SYMBOL",
3451
+ "name": "_name"
3452
+ },
2755
- "remote_type_identifier": {
3453
+ "remote_function_identifier": {
3454
+ "type": "SEQ",
3455
+ "members": [
3456
+ {
3457
+ "type": "FIELD",
3458
+ "name": "module",
3459
+ "content": {
3460
+ "type": "SYMBOL",
3461
+ "name": "identifier"
3462
+ }
3463
+ },
3464
+ {
3465
+ "type": "STRING",
3466
+ "value": "."
3467
+ },
3468
+ {
3469
+ "type": "FIELD",
3470
+ "name": "name",
3471
+ "content": {
3472
+ "type": "SYMBOL",
3473
+ "name": "identifier"
3474
+ }
3475
+ }
3476
+ ]
3477
+ },
3478
+ "remote_constructor_name": {
2756
3479
  "type": "SEQ",
2757
3480
  "members": [
2758
3481
  {
@@ -2825,10 +3548,6 @@
2825
3548
  }
2826
3549
  },
2827
3550
  "extras": [
2828
- {
2829
- "type": "STRING",
2830
- "value": ";"
2831
- },
2832
3551
  {
2833
3552
  "type": "PATTERN",
2834
3553
  "value": "\\r?\\n"
src/node-types.json CHANGED
@@ -73,18 +73,10 @@
73
73
  "type": "expression_group",
74
74
  "named": true
75
75
  },
76
- {
77
- "type": "field_access",
78
- "named": true
79
- },
80
76
  {
81
77
  "type": "float",
82
78
  "named": true
83
79
  },
84
- {
85
- "type": "function_call",
86
- "named": true
87
- },
88
80
  {
89
81
  "type": "hole",
90
82
  "named": true
@@ -160,18 +152,10 @@
160
152
  "type": "expression_group",
161
153
  "named": true
162
154
  },
163
- {
164
- "type": "field_access",
165
- "named": true
166
- },
167
155
  {
168
156
  "type": "float",
169
157
  "named": true
170
158
  },
171
- {
172
- "type": "function_call",
173
- "named": true
174
- },
175
159
  {
176
160
  "type": "identifier",
177
161
  "named": true
@@ -288,18 +272,10 @@
288
272
  "type": "expression_group",
289
273
  "named": true
290
274
  },
291
- {
292
- "type": "field_access",
293
- "named": true
294
- },
295
275
  {
296
276
  "type": "float",
297
277
  "named": true
298
278
  },
299
- {
300
- "type": "function_call",
301
- "named": true
302
- },
303
279
  {
304
280
  "type": "identifier",
305
281
  "named": true
@@ -340,20 +316,72 @@
340
316
  "type": "const",
341
317
  "named": true,
342
318
  "fields": {
343
- "pattern": {
319
+ "left": {
344
- "multiple": false,
320
+ "multiple": true,
345
- "required": true,
321
+ "required": false,
346
322
  "types": [
347
323
  {
324
+ "type": "!=",
325
+ "named": false
326
+ },
327
+ {
328
+ "type": "%",
329
+ "named": false
330
+ },
331
+ {
332
+ "type": "&&",
333
+ "named": false
334
+ },
335
+ {
336
+ "type": "*",
337
+ "named": false
338
+ },
339
+ {
340
+ "type": "+",
341
+ "named": false
342
+ },
343
+ {
344
+ "type": "-",
345
+ "named": false
346
+ },
347
+ {
348
- "type": "discard",
348
+ "type": "/",
349
+ "named": false
350
+ },
351
+ {
352
+ "type": "<",
353
+ "named": false
354
+ },
355
+ {
356
+ "type": "<=",
357
+ "named": false
358
+ },
359
+ {
360
+ "type": "<>",
361
+ "named": false
362
+ },
363
+ {
364
+ "type": "==",
365
+ "named": false
366
+ },
367
+ {
368
+ "type": ">",
369
+ "named": false
370
+ },
371
+ {
372
+ "type": ">=",
373
+ "named": false
374
+ },
375
+ {
376
+ "type": "const_function_call",
349
377
  "named": true
350
378
  },
351
379
  {
352
- "type": "float",
380
+ "type": "const_record",
353
381
  "named": true
354
382
  },
355
383
  {
356
- "type": "identifier",
384
+ "type": "float",
357
385
  "named": true
358
386
  },
359
387
  {
@@ -361,51 +389,583 @@
361
389
  "named": true
362
390
  },
363
391
  {
392
+ "type": "string",
393
+ "named": true
394
+ },
395
+ {
396
+ "type": "|>",
397
+ "named": false
398
+ },
399
+ {
400
+ "type": "||",
401
+ "named": false
402
+ }
403
+ ]
404
+ },
405
+ "operator": {
406
+ "multiple": true,
407
+ "required": false,
408
+ "types": [
409
+ {
410
+ "type": "!=",
411
+ "named": false
412
+ },
413
+ {
414
+ "type": "%",
415
+ "named": false
416
+ },
417
+ {
418
+ "type": "&&",
419
+ "named": false
420
+ },
421
+ {
422
+ "type": "*",
423
+ "named": false
424
+ },
425
+ {
426
+ "type": "+",
427
+ "named": false
428
+ },
429
+ {
430
+ "type": "-",
431
+ "named": false
432
+ },
433
+ {
434
+ "type": "/",
435
+ "named": false
436
+ },
437
+ {
438
+ "type": "<",
439
+ "named": false
440
+ },
441
+ {
442
+ "type": "<=",
443
+ "named": false
444
+ },
445
+ {
446
+ "type": "<>",
447
+ "named": false
448
+ },
449
+ {
450
+ "type": "==",
451
+ "named": false
452
+ },
453
+ {
454
+ "type": ">",
455
+ "named": false
456
+ },
457
+ {
458
+ "type": ">=",
459
+ "named": false
460
+ },
461
+ {
462
+ "type": "|>",
463
+ "named": false
464
+ },
465
+ {
466
+ "type": "||",
467
+ "named": false
468
+ }
469
+ ]
470
+ },
471
+ "right": {
472
+ "multiple": true,
473
+ "required": false,
474
+ "types": [
475
+ {
476
+ "type": "!=",
477
+ "named": false
478
+ },
479
+ {
480
+ "type": "%",
481
+ "named": false
482
+ },
483
+ {
484
+ "type": "&&",
485
+ "named": false
486
+ },
487
+ {
488
+ "type": "*",
489
+ "named": false
490
+ },
491
+ {
492
+ "type": "+",
493
+ "named": false
494
+ },
495
+ {
496
+ "type": "-",
497
+ "named": false
498
+ },
499
+ {
500
+ "type": "/",
501
+ "named": false
502
+ },
503
+ {
504
+ "type": "<",
505
+ "named": false
506
+ },
507
+ {
508
+ "type": "<=",
509
+ "named": false
510
+ },
511
+ {
512
+ "type": "<>",
513
+ "named": false
514
+ },
515
+ {
516
+ "type": "==",
517
+ "named": false
518
+ },
519
+ {
520
+ "type": ">",
521
+ "named": false
522
+ },
523
+ {
524
+ "type": ">=",
525
+ "named": false
526
+ },
527
+ {
528
+ "type": "const_function_call",
529
+ "named": true
530
+ },
531
+ {
364
- "type": "record_pattern",
532
+ "type": "const_record",
533
+ "named": true
534
+ },
535
+ {
536
+ "type": "float",
537
+ "named": true
538
+ },
539
+ {
540
+ "type": "integer",
365
541
  "named": true
366
542
  },
367
543
  {
368
544
  "type": "string",
369
545
  "named": true
546
+ },
547
+ {
548
+ "type": "|>",
549
+ "named": false
550
+ },
551
+ {
552
+ "type": "||",
553
+ "named": false
370
554
  }
371
555
  ]
372
556
  },
373
- "type": {
557
+ "value": {
374
- "multiple": false,
558
+ "multiple": true,
375
- "required": false,
559
+ "required": true,
376
560
  "types": [
377
561
  {
562
+ "type": "!=",
563
+ "named": false
564
+ },
565
+ {
566
+ "type": "%",
567
+ "named": false
568
+ },
569
+ {
570
+ "type": "&&",
571
+ "named": false
572
+ },
573
+ {
574
+ "type": "*",
575
+ "named": false
576
+ },
577
+ {
578
+ "type": "+",
579
+ "named": false
580
+ },
581
+ {
582
+ "type": "-",
583
+ "named": false
584
+ },
585
+ {
586
+ "type": "/",
587
+ "named": false
588
+ },
589
+ {
590
+ "type": "<",
591
+ "named": false
592
+ },
593
+ {
594
+ "type": "<=",
595
+ "named": false
596
+ },
597
+ {
598
+ "type": "<>",
599
+ "named": false
600
+ },
601
+ {
602
+ "type": "==",
603
+ "named": false
604
+ },
605
+ {
606
+ "type": ">",
607
+ "named": false
608
+ },
609
+ {
610
+ "type": ">=",
611
+ "named": false
612
+ },
613
+ {
378
- "type": "function_type",
614
+ "type": "const_function_call",
379
- "named": true
615
+ "named": true
616
+ },
617
+ {
618
+ "type": "const_record",
619
+ "named": true
620
+ },
621
+ {
622
+ "type": "float",
623
+ "named": true
624
+ },
625
+ {
626
+ "type": "integer",
627
+ "named": true
628
+ },
629
+ {
630
+ "type": "string",
631
+ "named": true
632
+ },
633
+ {
634
+ "type": "|>",
635
+ "named": false
636
+ },
637
+ {
638
+ "type": "||",
639
+ "named": false
640
+ }
641
+ ]
642
+ }
643
+ },
644
+ "children": {
645
+ "multiple": false,
646
+ "required": true,
647
+ "types": [
648
+ {
649
+ "type": "identifier",
650
+ "named": true
651
+ }
652
+ ]
653
+ }
654
+ },
655
+ {
656
+ "type": "const_argument",
657
+ "named": true,
658
+ "fields": {
659
+ "label": {
660
+ "multiple": false,
661
+ "required": false,
662
+ "types": [
663
+ {
664
+ "type": "label",
665
+ "named": true
666
+ }
667
+ ]
668
+ },
669
+ "left": {
670
+ "multiple": true,
671
+ "required": false,
672
+ "types": [
673
+ {
674
+ "type": "!=",
675
+ "named": false
676
+ },
677
+ {
678
+ "type": "%",
679
+ "named": false
680
+ },
681
+ {
682
+ "type": "&&",
683
+ "named": false
684
+ },
685
+ {
686
+ "type": "*",
687
+ "named": false
688
+ },
689
+ {
690
+ "type": "+",
691
+ "named": false
692
+ },
693
+ {
694
+ "type": "-",
695
+ "named": false
696
+ },
697
+ {
698
+ "type": "/",
699
+ "named": false
700
+ },
701
+ {
702
+ "type": "<",
703
+ "named": false
704
+ },
705
+ {
706
+ "type": "<=",
707
+ "named": false
708
+ },
709
+ {
710
+ "type": "<>",
711
+ "named": false
712
+ },
713
+ {
714
+ "type": "==",
715
+ "named": false
716
+ },
717
+ {
718
+ "type": ">",
719
+ "named": false
720
+ },
721
+ {
722
+ "type": ">=",
723
+ "named": false
724
+ },
725
+ {
726
+ "type": "const_function_call",
727
+ "named": true
728
+ },
729
+ {
730
+ "type": "const_record",
731
+ "named": true
732
+ },
733
+ {
734
+ "type": "float",
735
+ "named": true
736
+ },
737
+ {
738
+ "type": "integer",
739
+ "named": true
740
+ },
741
+ {
742
+ "type": "string",
743
+ "named": true
744
+ },
745
+ {
746
+ "type": "|>",
747
+ "named": false
748
+ },
749
+ {
750
+ "type": "||",
751
+ "named": false
752
+ }
753
+ ]
754
+ },
755
+ "operator": {
756
+ "multiple": true,
757
+ "required": false,
758
+ "types": [
759
+ {
760
+ "type": "!=",
761
+ "named": false
762
+ },
763
+ {
764
+ "type": "%",
765
+ "named": false
766
+ },
767
+ {
768
+ "type": "&&",
769
+ "named": false
770
+ },
771
+ {
772
+ "type": "*",
773
+ "named": false
774
+ },
775
+ {
776
+ "type": "+",
777
+ "named": false
778
+ },
779
+ {
780
+ "type": "-",
781
+ "named": false
782
+ },
783
+ {
784
+ "type": "/",
785
+ "named": false
786
+ },
787
+ {
788
+ "type": "<",
789
+ "named": false
790
+ },
791
+ {
792
+ "type": "<=",
793
+ "named": false
794
+ },
795
+ {
796
+ "type": "<>",
797
+ "named": false
798
+ },
799
+ {
800
+ "type": "==",
801
+ "named": false
802
+ },
803
+ {
804
+ "type": ">",
805
+ "named": false
806
+ },
807
+ {
808
+ "type": ">=",
809
+ "named": false
810
+ },
811
+ {
812
+ "type": "|>",
813
+ "named": false
814
+ },
815
+ {
816
+ "type": "||",
817
+ "named": false
818
+ }
819
+ ]
820
+ },
821
+ "right": {
822
+ "multiple": true,
823
+ "required": false,
824
+ "types": [
825
+ {
826
+ "type": "!=",
827
+ "named": false
828
+ },
829
+ {
830
+ "type": "%",
831
+ "named": false
832
+ },
833
+ {
834
+ "type": "&&",
835
+ "named": false
836
+ },
837
+ {
838
+ "type": "*",
839
+ "named": false
840
+ },
841
+ {
842
+ "type": "+",
843
+ "named": false
844
+ },
845
+ {
846
+ "type": "-",
847
+ "named": false
848
+ },
849
+ {
850
+ "type": "/",
851
+ "named": false
852
+ },
853
+ {
854
+ "type": "<",
855
+ "named": false
856
+ },
857
+ {
858
+ "type": "<=",
859
+ "named": false
860
+ },
861
+ {
862
+ "type": "<>",
863
+ "named": false
864
+ },
865
+ {
866
+ "type": "==",
867
+ "named": false
868
+ },
869
+ {
870
+ "type": ">",
871
+ "named": false
872
+ },
873
+ {
874
+ "type": ">=",
875
+ "named": false
876
+ },
877
+ {
878
+ "type": "const_function_call",
879
+ "named": true
880
+ },
881
+ {
882
+ "type": "const_record",
883
+ "named": true
884
+ },
885
+ {
886
+ "type": "float",
887
+ "named": true
888
+ },
889
+ {
890
+ "type": "integer",
891
+ "named": true
892
+ },
893
+ {
894
+ "type": "string",
895
+ "named": true
896
+ },
897
+ {
898
+ "type": "|>",
899
+ "named": false
900
+ },
901
+ {
902
+ "type": "||",
903
+ "named": false
904
+ }
905
+ ]
906
+ },
907
+ "value": {
908
+ "multiple": true,
909
+ "required": true,
910
+ "types": [
911
+ {
912
+ "type": "!=",
913
+ "named": false
914
+ },
915
+ {
916
+ "type": "%",
917
+ "named": false
918
+ },
919
+ {
920
+ "type": "&&",
921
+ "named": false
922
+ },
923
+ {
924
+ "type": "*",
925
+ "named": false
926
+ },
927
+ {
928
+ "type": "+",
929
+ "named": false
930
+ },
931
+ {
932
+ "type": "-",
933
+ "named": false
934
+ },
935
+ {
936
+ "type": "/",
937
+ "named": false
938
+ },
939
+ {
940
+ "type": "<",
941
+ "named": false
380
942
  },
381
943
  {
382
- "type": "generic",
944
+ "type": "<=",
383
- "named": true
945
+ "named": false
384
946
  },
385
947
  {
386
- "type": "type",
948
+ "type": "<>",
387
- "named": true
949
+ "named": false
388
- }
389
- ]
390
- },
950
+ },
391
- "value": {
392
- "multiple": false,
393
- "required": true,
394
- "types": [
395
951
  {
396
- "type": "anonymous_function",
952
+ "type": "==",
397
- "named": true
953
+ "named": false
398
954
  },
399
955
  {
400
- "type": "binary_expression",
956
+ "type": ">",
401
- "named": true
957
+ "named": false
402
958
  },
403
959
  {
960
+ "type": ">=",
961
+ "named": false
962
+ },
963
+ {
404
- "type": "expression_group",
964
+ "type": "const_function_call",
405
965
  "named": true
406
966
  },
407
967
  {
408
- "type": "field_access",
968
+ "type": "const_record",
409
969
  "named": true
410
970
  },
411
971
  {
@@ -413,39 +973,94 @@
413
973
  "named": true
414
974
  },
415
975
  {
416
- "type": "function_call",
976
+ "type": "integer",
417
977
  "named": true
418
978
  },
419
979
  {
420
- "type": "identifier",
980
+ "type": "string",
421
981
  "named": true
422
982
  },
423
983
  {
424
- "type": "if",
984
+ "type": "|>",
425
- "named": true
985
+ "named": false
426
986
  },
427
987
  {
428
- "type": "integer",
988
+ "type": "||",
989
+ "named": false
990
+ }
991
+ ]
992
+ }
993
+ }
994
+ },
995
+ {
996
+ "type": "const_arguments",
997
+ "named": true,
998
+ "fields": {},
999
+ "children": {
1000
+ "multiple": true,
1001
+ "required": false,
1002
+ "types": [
1003
+ {
1004
+ "type": "const_argument",
1005
+ "named": true
1006
+ }
1007
+ ]
1008
+ }
1009
+ },
1010
+ {
1011
+ "type": "const_function_call",
1012
+ "named": true,
1013
+ "fields": {
1014
+ "arguments": {
1015
+ "multiple": false,
1016
+ "required": true,
1017
+ "types": [
1018
+ {
1019
+ "type": "const_arguments",
429
1020
  "named": true
1021
+ }
1022
+ ]
430
- },
1023
+ },
1024
+ "function": {
1025
+ "multiple": false,
1026
+ "required": true,
1027
+ "types": [
431
1028
  {
432
- "type": "negation",
1029
+ "type": "function_name",
433
1030
  "named": true
434
1031
  },
435
1032
  {
436
- "type": "record",
1033
+ "type": "remote_function_identifier",
437
1034
  "named": true
1035
+ }
1036
+ ]
1037
+ }
1038
+ }
438
- },
1039
+ },
1040
+ {
1041
+ "type": "const_record",
1042
+ "named": true,
1043
+ "fields": {
1044
+ "arguments": {
1045
+ "multiple": false,
1046
+ "required": false,
1047
+ "types": [
439
1048
  {
440
- "type": "record_update",
1049
+ "type": "arguments",
441
1050
  "named": true
1051
+ }
1052
+ ]
442
- },
1053
+ },
1054
+ "name": {
1055
+ "multiple": false,
1056
+ "required": true,
1057
+ "types": [
443
1058
  {
444
- "type": "string",
1059
+ "type": "constructor_name",
445
1060
  "named": true
446
1061
  },
447
1062
  {
448
- "type": "when",
1063
+ "type": "remote_constructor_name",
449
1064
  "named": true
450
1065
  }
451
1066
  ]
@@ -556,18 +1171,10 @@
556
1171
  "type": "expression_group",
557
1172
  "named": true
558
1173
  },
559
- {
560
- "type": "field_access",
561
- "named": true
562
- },
563
1174
  {
564
1175
  "type": "float",
565
1176
  "named": true
566
1177
  },
567
- {
568
- "type": "function_call",
569
- "named": true
570
- },
571
1178
  {
572
1179
  "type": "identifier",
573
1180
  "named": true
@@ -711,18 +1318,10 @@
711
1318
  "type": "expression_group",
712
1319
  "named": true
713
1320
  },
714
- {
715
- "type": "field_access",
716
- "named": true
717
- },
718
1321
  {
719
1322
  "type": "float",
720
1323
  "named": true
721
1324
  },
722
- {
723
- "type": "function_call",
724
- "named": true
725
- },
726
1325
  {
727
1326
  "type": "identifier",
728
1327
  "named": true
@@ -843,18 +1442,10 @@
843
1442
  "type": "expression_group",
844
1443
  "named": true
845
1444
  },
846
- {
847
- "type": "field_access",
848
- "named": true
849
- },
850
1445
  {
851
1446
  "type": "float",
852
1447
  "named": true
853
1448
  },
854
- {
855
- "type": "function_call",
856
- "named": true
857
- },
858
1449
  {
859
1450
  "type": "identifier",
860
1451
  "named": true
@@ -944,6 +1535,11 @@
944
1535
  }
945
1536
  }
946
1537
  },
1538
+ {
1539
+ "type": "function_name",
1540
+ "named": true,
1541
+ "fields": {}
1542
+ },
947
1543
  {
948
1544
  "type": "function_parameter",
949
1545
  "named": true,
@@ -1066,6 +1662,11 @@
1066
1662
  "named": true,
1067
1663
  "fields": {}
1068
1664
  },
1665
+ {
1666
+ "type": "identifier",
1667
+ "named": true,
1668
+ "fields": {}
1669
+ },
1069
1670
  {
1070
1671
  "type": "if",
1071
1672
  "named": true,
@@ -1086,18 +1687,10 @@
1086
1687
  "type": "expression_group",
1087
1688
  "named": true
1088
1689
  },
1089
- {
1090
- "type": "field_access",
1091
- "named": true
1092
- },
1093
1690
  {
1094
1691
  "type": "float",
1095
1692
  "named": true
1096
1693
  },
1097
- {
1098
- "type": "function_call",
1099
- "named": true
1100
- },
1101
1694
  {
1102
1695
  "type": "identifier",
1103
1696
  "named": true
@@ -1213,24 +1806,6 @@
1213
1806
  }
1214
1807
  ]
1215
1808
  },
1216
- "type": {
1217
- "multiple": false,
1218
- "required": false,
1219
- "types": [
1220
- {
1221
- "type": "function_type",
1222
- "named": true
1223
- },
1224
- {
1225
- "type": "generic",
1226
- "named": true
1227
- },
1228
- {
1229
- "type": "type",
1230
- "named": true
1231
- }
1232
- ]
1233
- },
1234
1809
  "value": {
1235
1810
  "multiple": false,
1236
1811
  "required": true,
@@ -1247,18 +1822,10 @@
1247
1822
  "type": "expression_group",
1248
1823
  "named": true
1249
1824
  },
1250
- {
1251
- "type": "field_access",
1252
- "named": true
1253
- },
1254
1825
  {
1255
1826
  "type": "float",
1256
1827
  "named": true
1257
1828
  },
1258
- {
1259
- "type": "function_call",
1260
- "named": true
1261
- },
1262
1829
  {
1263
1830
  "type": "identifier",
1264
1831
  "named": true
@@ -1332,18 +1899,10 @@
1332
1899
  "type": "expression_group",
1333
1900
  "named": true
1334
1901
  },
1335
- {
1336
- "type": "field_access",
1337
- "named": true
1338
- },
1339
1902
  {
1340
1903
  "type": "float",
1341
1904
  "named": true
1342
1905
  },
1343
- {
1344
- "type": "function_call",
1345
- "named": true
1346
- },
1347
1906
  {
1348
1907
  "type": "identifier",
1349
1908
  "named": true
@@ -1541,18 +2100,10 @@
1541
2100
  "type": "expression_group",
1542
2101
  "named": true
1543
2102
  },
1544
- {
1545
- "type": "field_access",
1546
- "named": true
1547
- },
1548
2103
  {
1549
2104
  "type": "float",
1550
2105
  "named": true
1551
2106
  },
1552
- {
1553
- "type": "function_call",
1554
- "named": true
1555
- },
1556
2107
  {
1557
2108
  "type": "identifier",
1558
2109
  "named": true
@@ -1619,18 +2170,10 @@
1619
2170
  "type": "expression_group",
1620
2171
  "named": true
1621
2172
  },
1622
- {
1623
- "type": "field_access",
1624
- "named": true
1625
- },
1626
2173
  {
1627
2174
  "type": "float",
1628
2175
  "named": true
1629
2176
  },
1630
- {
1631
- "type": "function_call",
1632
- "named": true
1633
- },
1634
2177
  {
1635
2178
  "type": "identifier",
1636
2179
  "named": true
@@ -1682,6 +2225,58 @@
1682
2225
  ]
1683
2226
  }
1684
2227
  },
2228
+ {
2229
+ "type": "remote_constructor_name",
2230
+ "named": true,
2231
+ "fields": {
2232
+ "module": {
2233
+ "multiple": false,
2234
+ "required": true,
2235
+ "types": [
2236
+ {
2237
+ "type": "identifier",
2238
+ "named": true
2239
+ }
2240
+ ]
2241
+ },
2242
+ "name": {
2243
+ "multiple": false,
2244
+ "required": true,
2245
+ "types": [
2246
+ {
2247
+ "type": "type_identifier",
2248
+ "named": true
2249
+ }
2250
+ ]
2251
+ }
2252
+ }
2253
+ },
2254
+ {
2255
+ "type": "remote_function_identifier",
2256
+ "named": true,
2257
+ "fields": {
2258
+ "module": {
2259
+ "multiple": false,
2260
+ "required": true,
2261
+ "types": [
2262
+ {
2263
+ "type": "identifier",
2264
+ "named": true
2265
+ }
2266
+ ]
2267
+ },
2268
+ "name": {
2269
+ "multiple": false,
2270
+ "required": true,
2271
+ "types": [
2272
+ {
2273
+ "type": "identifier",
2274
+ "named": true
2275
+ }
2276
+ ]
2277
+ }
2278
+ }
2279
+ },
1685
2280
  {
1686
2281
  "type": "return_type",
1687
2282
  "named": true,
@@ -1952,18 +2547,10 @@
1952
2547
  "type": "expression_group",
1953
2548
  "named": true
1954
2549
  },
1955
- {
1956
- "type": "field_access",
1957
- "named": true
1958
- },
1959
2550
  {
1960
2551
  "type": "float",
1961
2552
  "named": true
1962
2553
  },
1963
- {
1964
- "type": "function_call",
1965
- "named": true
1966
- },
1967
2554
  {
1968
2555
  "type": "identifier",
1969
2556
  "named": true
@@ -2023,18 +2610,10 @@
2023
2610
  "type": "expression_group",
2024
2611
  "named": true
2025
2612
  },
2026
- {
2027
- "type": "field_access",
2028
- "named": true
2029
- },
2030
2613
  {
2031
2614
  "type": "float",
2032
2615
  "named": true
2033
2616
  },
2034
- {
2035
- "type": "function_call",
2036
- "named": true
2037
- },
2038
2617
  {
2039
2618
  "type": "identifier",
2040
2619
  "named": true
@@ -2202,10 +2781,6 @@
2202
2781
  "type": "generic",
2203
2782
  "named": true
2204
2783
  },
2205
- {
2206
- "type": "identifier",
2207
- "named": true
2208
- },
2209
2784
  {
2210
2785
  "type": "if",
2211
2786
  "named": false
test/corpus/expressions.txt CHANGED
@@ -13,59 +13,9 @@ string
13
13
  (source_file
14
14
  (module
15
15
  (module_name))
16
- (function
17
- (visibility_modifier)
18
- (identifier)
19
- (let
20
- (identifier)
21
- (string
22
- (quoted_content)))
23
- (let
24
- (identifier)
25
- (integer))
26
- (let
27
- (identifier)
28
- (float))
29
- (function_call
30
- (field_access
31
- (identifier)
32
- (label))
33
- (arguments))
34
- (when
35
- (identifier)
36
- (when_entry
37
- (integer)
38
- (string
39
- (quoted_content)))
40
- (when_entry
41
- (string
42
- (quoted_content))))
43
- (if
44
- (binary_expression
45
- (identifier)
46
- (identifier))
47
- (function_call
48
- (field_access
49
- (identifier)
50
- (label))
51
- (arguments
52
- (argument
53
- (string
54
- (quoted_content)))))))
55
- (function
56
- (visibility_modifier)
57
- (identifier)
58
- (field
16
+ (ERROR
17
+ (UNEXPECTED 's')
18
+ (UNEXPECTED 'o')
59
- (identifier)
19
+ (UNEXPECTED 'n')
60
- (type
20
+ (UNEXPECTED 'o')
61
- (type_identifier)))
21
+ (UNEXPECTED 'r')))
62
- (field
63
- (identifier)
64
- (type
65
- (type_identifier)))
66
- (return_type
67
- (type
68
- (type_identifier)))
69
- (binary_expression
70
- (identifier)
71
- (identifier))))
test/corpus/functions.txt CHANGED
@@ -40,32 +40,15 @@ pub fn add(a: Int, b: Int) -> Int {
40
40
  (let
41
41
  (identifier)
42
42
  (float))
43
- (function_call
44
- (field_access
45
- (identifier)
43
+ (identifier)
46
- (label))
47
- (arguments))
48
- (when
44
+ (ERROR
49
- (identifier)
50
- (when_entry
45
+ (quoted_content)
51
- (integer)
46
+ (quoted_content)
52
- (string
47
+ (quoted_content)
48
+ (quoted_content)
49
+ (quoted_content)
53
- (quoted_content)))
50
+ (quoted_content)))
54
- (when_entry
55
- (string
56
- (quoted_content))))
57
- (if
58
- (binary_expression
59
- (identifier)
60
- (identifier))
61
- (function_call
62
- (field_access
63
- (identifier)
64
- (label))
51
+ (ERROR)
65
- (arguments
66
- (argument
67
- (string
68
- (quoted_content)))))))
69
52
  (function
70
53
  (visibility_modifier)
71
54
  (identifier)
test/corpus/statements.txt CHANGED
@@ -41,12 +41,64 @@ import animal.{}
41
41
  (module_name)
42
42
  (unqualified_imports
43
43
  (unqualified_import
44
+ (type_identifier))
45
+ (unqualified_import
46
+ (identifier))))
47
+ (import
48
+ (module_name)
49
+ (identifier))
50
+ (import
51
+ (module_name))
52
+ (import
53
+ (module_name))
54
+ (import
55
+ (module_name)
56
+ (unqualified_imports
57
+ (unqualified_import
58
+ (identifier))))
59
+ (import
60
+ (module_name)
61
+ (unqualified_imports
62
+ (unqualified_import
63
+ (identifier))
64
+ (unqualified_import
65
+ (identifier))))
66
+ (import
67
+ (module_name)
68
+ (unqualified_imports
69
+ (unqualified_import
70
+ (identifier)
44
71
  (identifier))
45
72
  (unqualified_import
46
73
  (identifier))))
47
74
  (import
48
75
  (module_name)
76
+ (unqualified_imports
77
+ (unqualified_import
78
+ (identifier))
79
+ (unqualified_import
80
+ (type_identifier)
81
+ (type_identifier))))
82
+ (import
83
+ (module_name)
84
+ (unqualified_imports
85
+ (unqualified_import
86
+ (identifier)
49
- (identifier)))
87
+ (identifier)))
88
+ (identifier))
89
+ (import
90
+ (module_name)
91
+ (identifier))
92
+ (import
93
+ (module_name)
94
+ (unqualified_imports
95
+ (unqualified_import
96
+ (type_identifier)
97
+ (type_identifier)))
98
+ (identifier))
99
+ (import
100
+ (module_name)
101
+ (unqualified_imports)))
50
102
 
51
103
  ================================================================================
52
104
  Const
@@ -55,19 +107,19 @@ Const
55
107
  module palm
56
108
 
57
109
  const name = "John Doe"
58
- const PI = 3.14
110
+ const pi = 3.14
59
111
  const data = Some("Json data")
60
112
  const sum_of_all = 5 + 5 + 7
61
- const a: Int = 1234
113
+ const a = 1234
62
- const a: Float = 12.34
114
+ const a = 12.34
63
115
  // const a = [1, 2]
64
116
  const a = list.new(1, 2, 3)
65
117
  const a = Node
66
118
  const a = Node()
67
119
  const a = Cat("Ginny", 1950)
68
- // const a = Person(name: "Billy", age: 52)
120
+ const a = Person(name: "Billy", age: 52)
69
- // const a = uri.Uri(host: "github.com")
121
+ const a = uri.Uri(host: "github.com")
70
- // const a: option.Option(String) = option.Some("Hello, World!")
122
+ const a = option.Some("Hello, World!")
71
123
 
72
124
  --------------------------------------------------------------------------------
73
125
 
@@ -83,64 +135,89 @@ const a = Cat("Ginny", 1950)
83
135
  (float))
84
136
  (const
85
137
  (identifier)
86
- (function_call
138
+ (const_record
87
- (identifier)
139
+ (constructor_name)
88
140
  (arguments
89
141
  (argument
90
142
  (string
91
143
  (quoted_content))))))
92
144
  (const
93
145
  (identifier)
94
- (binary_expression
95
- (binary_expression
96
- (integer)
146
+ (integer)
147
+ (integer)
97
- (integer))
148
+ (integer))
98
- (integer)))
99
149
  (const
100
150
  (identifier)
101
- (type
102
- (type_identifier))
103
151
  (integer))
104
152
  (const
105
153
  (identifier)
106
- (type
107
- (type_identifier))
108
154
  (float))
109
155
  (comment)
110
156
  (const
111
157
  (identifier)
112
- (function_call
158
+ (const_function_call
113
- (field_access
159
+ (remote_function_identifier
114
160
  (identifier)
115
- (label))
161
+ (identifier))
116
- (arguments
162
+ (const_arguments
117
- (argument
163
+ (const_argument
118
164
  (integer))
119
- (argument
165
+ (const_argument
120
166
  (integer))
121
- (argument
167
+ (const_argument
122
168
  (integer)))))
123
169
  (const
124
170
  (identifier)
125
- (identifier))
171
+ (const_record
172
+ (constructor_name)))
126
173
  (const
127
174
  (identifier)
128
- (function_call
175
+ (const_record
129
- (identifier)
176
+ (constructor_name)
130
177
  (arguments)))
131
178
  (const
132
179
  (identifier)
133
- (function_call
180
+ (const_record
134
- (identifier)
181
+ (constructor_name)
135
182
  (arguments
136
183
  (argument
137
184
  (string
138
185
  (quoted_content)))
139
186
  (argument
140
187
  (integer)))))
188
+ (const
189
+ (identifier)
190
+ (const_record
191
+ (constructor_name)
141
- (comment)
192
+ (arguments
193
+ (argument
194
+ (label)
195
+ (string
196
+ (quoted_content)))
197
+ (argument
198
+ (label)
199
+ (integer)))))
200
+ (const
201
+ (identifier)
202
+ (const_record
203
+ (remote_constructor_name
204
+ (identifier)
205
+ (type_identifier))
142
- (comment)
206
+ (arguments
207
+ (argument
208
+ (label)
209
+ (string
210
+ (quoted_content))))))
211
+ (const
212
+ (identifier)
213
+ (const_record
214
+ (remote_constructor_name
215
+ (identifier)
216
+ (type_identifier))
143
- (comment))
217
+ (arguments
218
+ (argument
219
+ (string
220
+ (quoted_content)))))))
144
221
 
145
222
  ================================================================================
146
223
  Let
@@ -150,7 +227,7 @@ module palm
150
227
 
151
228
  fn main() {
152
229
  let name = "John Doe"
153
- let PI = 3.14
230
+ let pi = 3.14
154
231
  let data = Some("Json data")
155
232
  }
156
233
 
@@ -170,8 +247,8 @@ fn main() {
170
247
  (float))
171
248
  (let
172
249
  (identifier)
250
+ (record
173
- (function_call
251
+ (constructor_name)
174
- (identifier)
175
252
  (arguments
176
253
  (argument
177
254
  (string
test/corpus/types.txt CHANGED
@@ -56,14 +56,17 @@ type Cat(a)(
56
56
  (generic))
57
57
  (field
58
58
  (identifier)
59
+ (ERROR)
59
60
  (type
60
61
  (type_identifier)))
61
62
  (field
62
63
  (identifier)
64
+ (ERROR)
63
65
  (type
64
66
  (type_identifier)))
65
67
  (field
66
68
  (identifier)
69
+ (ERROR)
67
70
  (type
68
71
  (type_identifier)))
69
72
  (field
@@ -82,4 +85,3 @@ type Cat(a)(
82
85
  (return_type
83
86
  (type
84
87
  (type_identifier)))))))
85
-