prec left

This commit is contained in:
Michael Sippel 2025-06-11 07:33:57 +02:00
parent bfcbe2fe2e
commit 7ba7ab1ab3
Signed by: senvas
GPG key ID: F96CF119C34B64A6
3 changed files with 63 additions and 66 deletions

View file

@ -47,7 +47,7 @@ module.exports = grammar({
char: (_) => seq("'", /(.)/, "'"),
univ: ($) =>
prec.right(seq("∀", "(", $.typevar, ":", $.constraint, ")", ".", $.type)),
prec.left(seq("∀", "(", $.typevar, ":", $.constraint, ")", ".", $.type)),
spec: ($) => prec.left(seq("<", repeat($.type), ">")),
func: ($) => prec.right(seq($.type, "-->", $.type)),
morph: ($) => prec.right(seq($.type, "-morph->", $.type)),

2
src/grammar.json generated
View file

@ -131,7 +131,7 @@
]
},
"univ": {
"type": "PREC_RIGHT",
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",

125
src/parser.c generated
View file

@ -1587,14 +1587,8 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_RBRACK,
anon_sym_SEMI,
anon_sym_PIPE,
[848] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
anon_sym_DASHmorph_DASH_GT,
ACTIONS(60), 1,
anon_sym_TILDE,
ACTIONS(80), 15,
[848] = 1,
ACTIONS(80), 18,
ts_builtin_sym_end,
anon_sym_SLASH_STAR,
sym_typeid,
@ -1604,13 +1598,16 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_RPAREN,
anon_sym_LT,
anon_sym_GT,
anon_sym_DASH_DASH_GT,
anon_sym_DASHmorph_DASH_GT,
anon_sym_TILDE,
anon_sym_LBRACE,
anon_sym_RBRACE,
anon_sym_LBRACK,
anon_sym_RBRACK,
anon_sym_SEMI,
anon_sym_PIPE,
[875] = 4,
[869] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
@ -1628,7 +1625,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_LBRACE,
anon_sym_LBRACK,
anon_sym_RBRACK,
[897] = 6,
[891] = 6,
ACTIONS(86), 1,
anon_sym_LT_EQ,
ACTIONS(88), 1,
@ -1644,7 +1641,7 @@ static const uint16_t ts_small_parse_table[] = {
sym_subType,
sym_traitType,
sym_parType,
[919] = 5,
[913] = 5,
ACTIONS(92), 1,
sym_typevar,
ACTIONS(94), 1,
@ -1657,7 +1654,7 @@ static const uint16_t ts_small_parse_table[] = {
STATE(38), 2,
sym_enum_variant,
aux_sym_enum_repeat1,
[937] = 4,
[931] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
@ -1667,7 +1664,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(98), 2,
anon_sym_RBRACE,
anon_sym_PIPE,
[951] = 3,
[945] = 3,
ACTIONS(100), 1,
anon_sym_RBRACE,
ACTIONS(102), 1,
@ -1675,7 +1672,7 @@ static const uint16_t ts_small_parse_table[] = {
STATE(34), 2,
sym_enum_variant,
aux_sym_enum_repeat1,
[962] = 3,
[956] = 3,
ACTIONS(105), 1,
sym_typevar,
ACTIONS(108), 1,
@ -1683,7 +1680,7 @@ static const uint16_t ts_small_parse_table[] = {
STATE(35), 2,
sym_struct_member,
aux_sym_struct_repeat1,
[973] = 3,
[967] = 3,
ACTIONS(92), 1,
sym_typevar,
ACTIONS(110), 1,
@ -1691,7 +1688,7 @@ static const uint16_t ts_small_parse_table[] = {
STATE(35), 2,
sym_struct_member,
aux_sym_struct_repeat1,
[984] = 4,
[978] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
@ -1700,7 +1697,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_TILDE,
ACTIONS(112), 1,
anon_sym_SEMI,
[997] = 3,
[991] = 3,
ACTIONS(96), 1,
anon_sym_PIPE,
ACTIONS(114), 1,
@ -1708,7 +1705,7 @@ static const uint16_t ts_small_parse_table[] = {
STATE(34), 2,
sym_enum_variant,
aux_sym_enum_repeat1,
[1008] = 4,
[1002] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
@ -1717,7 +1714,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_TILDE,
ACTIONS(116), 1,
anon_sym_RPAREN,
[1021] = 4,
[1015] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
@ -1726,7 +1723,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_TILDE,
ACTIONS(118), 1,
ts_builtin_sym_end,
[1034] = 4,
[1028] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
@ -1735,7 +1732,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_TILDE,
ACTIONS(120), 1,
anon_sym_RPAREN,
[1047] = 4,
[1041] = 4,
ACTIONS(56), 1,
anon_sym_DASH_DASH_GT,
ACTIONS(58), 1,
@ -1744,50 +1741,50 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_TILDE,
ACTIONS(122), 1,
anon_sym_RPAREN,
[1060] = 1,
[1054] = 1,
ACTIONS(124), 2,
sym_typevar,
anon_sym_RBRACE,
[1065] = 1,
[1059] = 1,
ACTIONS(126), 1,
anon_sym_COLON,
[1069] = 1,
[1063] = 1,
ACTIONS(128), 1,
ts_builtin_sym_end,
[1073] = 1,
[1067] = 1,
ACTIONS(130), 1,
anon_sym_COLON,
[1077] = 1,
[1071] = 1,
ACTIONS(132), 1,
anon_sym_LPAREN,
[1081] = 1,
[1075] = 1,
ACTIONS(134), 1,
sym_typevar,
[1085] = 1,
[1079] = 1,
ACTIONS(136), 1,
anon_sym_SQUOTE,
[1089] = 1,
[1083] = 1,
ACTIONS(138), 1,
anon_sym_RPAREN,
[1093] = 1,
[1087] = 1,
ACTIONS(140), 1,
anon_sym_STAR_SLASH,
[1097] = 1,
[1091] = 1,
ACTIONS(142), 1,
anon_sym_COLON,
[1101] = 1,
[1095] = 1,
ACTIONS(144), 1,
sym_typevar,
[1105] = 1,
[1099] = 1,
ACTIONS(146), 1,
anon_sym_RPAREN,
[1109] = 1,
[1103] = 1,
ACTIONS(148), 1,
anon_sym_DOT,
[1113] = 1,
[1107] = 1,
ACTIONS(150), 1,
aux_sym_char_token1,
[1117] = 1,
[1111] = 1,
ACTIONS(152), 1,
aux_sym_comment_token1,
};
@ -1821,34 +1818,34 @@ static const uint32_t ts_small_parse_table_map[] = {
[SMALL_STATE(27)] = 806,
[SMALL_STATE(28)] = 827,
[SMALL_STATE(29)] = 848,
[SMALL_STATE(30)] = 875,
[SMALL_STATE(31)] = 897,
[SMALL_STATE(32)] = 919,
[SMALL_STATE(33)] = 937,
[SMALL_STATE(34)] = 951,
[SMALL_STATE(35)] = 962,
[SMALL_STATE(36)] = 973,
[SMALL_STATE(37)] = 984,
[SMALL_STATE(38)] = 997,
[SMALL_STATE(39)] = 1008,
[SMALL_STATE(40)] = 1021,
[SMALL_STATE(41)] = 1034,
[SMALL_STATE(42)] = 1047,
[SMALL_STATE(43)] = 1060,
[SMALL_STATE(44)] = 1065,
[SMALL_STATE(45)] = 1069,
[SMALL_STATE(46)] = 1073,
[SMALL_STATE(47)] = 1077,
[SMALL_STATE(48)] = 1081,
[SMALL_STATE(49)] = 1085,
[SMALL_STATE(50)] = 1089,
[SMALL_STATE(51)] = 1093,
[SMALL_STATE(52)] = 1097,
[SMALL_STATE(53)] = 1101,
[SMALL_STATE(54)] = 1105,
[SMALL_STATE(55)] = 1109,
[SMALL_STATE(56)] = 1113,
[SMALL_STATE(57)] = 1117,
[SMALL_STATE(30)] = 869,
[SMALL_STATE(31)] = 891,
[SMALL_STATE(32)] = 913,
[SMALL_STATE(33)] = 931,
[SMALL_STATE(34)] = 945,
[SMALL_STATE(35)] = 956,
[SMALL_STATE(36)] = 967,
[SMALL_STATE(37)] = 978,
[SMALL_STATE(38)] = 991,
[SMALL_STATE(39)] = 1002,
[SMALL_STATE(40)] = 1015,
[SMALL_STATE(41)] = 1028,
[SMALL_STATE(42)] = 1041,
[SMALL_STATE(43)] = 1054,
[SMALL_STATE(44)] = 1059,
[SMALL_STATE(45)] = 1063,
[SMALL_STATE(46)] = 1067,
[SMALL_STATE(47)] = 1071,
[SMALL_STATE(48)] = 1075,
[SMALL_STATE(49)] = 1079,
[SMALL_STATE(50)] = 1083,
[SMALL_STATE(51)] = 1087,
[SMALL_STATE(52)] = 1091,
[SMALL_STATE(53)] = 1095,
[SMALL_STATE(54)] = 1099,
[SMALL_STATE(55)] = 1103,
[SMALL_STATE(56)] = 1107,
[SMALL_STATE(57)] = 1111,
};
static const TSParseActionEntry ts_parse_actions[] = {