WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 388b53f

Browse files
authored
Merge pull request #36 from alaviss/fix-starcolon
split * and : into two tokens
2 parents 9f59660 + c3486fb commit 388b53f

File tree

6 files changed

+903576
-898650
lines changed

6 files changed

+903576
-898650
lines changed

corpus/declarations.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ var z, w: float
239239
var (c, d) = (2, 3)
240240
var (x, ) = (1, )
241241

242+
var x*:int
243+
var y *: float
244+
242245
--------------------------------------------------------------------------------
243246

244247
(source_file
@@ -305,7 +308,23 @@ var (x, ) = (1, )
305308
(symbol_declaration
306309
name: (identifier))))
307310
value: (tuple_construction
308-
(integer_literal)))))
311+
(integer_literal))))
312+
(var_section
313+
(variable_declaration
314+
(symbol_declaration_list
315+
(symbol_declaration
316+
name: (exported_symbol
317+
(identifier))))
318+
type: (type_expression
319+
(identifier))))
320+
(var_section
321+
(variable_declaration
322+
(symbol_declaration_list
323+
(symbol_declaration
324+
name: (exported_symbol
325+
(identifier))))
326+
type: (type_expression
327+
(identifier)))))
309328

310329
================================================================================
311330
Type aliases

corpus/expressions.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ not a.c
5353

5454
echo $a
5555

56+
*:bar
57+
5658
--------------------------------------------------------------------------------
5759

5860
(source_file
@@ -97,7 +99,11 @@ echo $a
9799
(argument_list
98100
(prefix_expression
99101
operator: (operator)
100-
(identifier)))))
102+
(identifier))))
103+
(prefix_expression
104+
operator: (operator)
105+
(ERROR)
106+
(identifier)))
101107

102108
================================================================================
103109
Infix expressions

grammar.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ const InfixOperators = {
131131
L9: token(
132132
seq(
133133
choice(
134-
"*",
135134
"%",
136135
"\\",
137136
"/"
@@ -152,6 +151,7 @@ const InfixOperators = {
152151
repeat(choice(...Operators))
153152
)
154153
),
154+
L9Star: token(seq("*", repeat(choice(...Operators.filter(x => x != ":"))))),
155155
L8: token(
156156
seq(
157157
choice(
@@ -208,6 +208,7 @@ module.exports = grammar({
208208
$._invalid_layout,
209209
$._sigil_operator,
210210
$._prefix_operator,
211+
$._symbol_export_marker,
211212
$._case_of,
212213
],
213214

@@ -1042,6 +1043,7 @@ module.exports = grammar({
10421043
[$._infix_operator_10r, "binary_10", prec.right],
10431044
[$._infix_operator_10l, "binary_10", prec.left],
10441045
[$._infix_operator_9, "binary_9", prec.left],
1046+
[$._infix_operator_9_star, "binary_9", prec.left],
10451047
[
10461048
choice(...WordOperators[9].map(x => keyword(x))),
10471049
"binary_9",
@@ -1087,6 +1089,7 @@ module.exports = grammar({
10871089
_infix_operator_10r: $ => alias(InfixOperators.R10, $.operator),
10881090
_infix_operator_10l: $ => alias(InfixOperators.L10, $.operator),
10891091
_infix_operator_9: $ => alias(InfixOperators.L9, $.operator),
1092+
_infix_operator_9_star: $ => alias(InfixOperators.L9Star, $.operator),
10901093
_infix_operator_8: $ => alias(InfixOperators.L8, $.operator),
10911094
_infix_operator_7: $ => alias(InfixOperators.L7, $.operator),
10921095
_infix_operator_6: $ => alias(InfixOperators.L6, $.operator),
@@ -1310,7 +1313,8 @@ module.exports = grammar({
13101313
field("name", choice($._symbol, $.exported_symbol)),
13111314
optional($.pragma_list)
13121315
),
1313-
exported_symbol: $ => seq($._symbol, "*"),
1316+
exported_symbol: $ => seq($._symbol, alias($._symbol_export_marker, "*")),
1317+
_symbol_export_marker: () => "*",
13141318

13151319
/* Literals */
13161320
_literal: $ =>

0 commit comments

Comments
 (0)