Skip to content

Commit 7bfc87d

Browse files
authored
Lambda attributes + record trailing semicolons (#231)
1 parent ad8e698 commit 7bfc87d

File tree

6 files changed

+487750
-405607
lines changed

6 files changed

+487750
-405607
lines changed

corpus/attributes.txt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,32 @@ void A() { }
333333
(void_keyword)
334334
(identifier)
335335
(parameter_list)
336-
(block))))
336+
(block))))
337+
338+
=======================================
339+
Lambda with attribute
340+
=======================================
341+
342+
var greeting = [Hello] () => Console.WriteLine("hello");
343+
344+
---
345+
346+
(compilation_unit
347+
(global_statement
348+
(local_declaration_statement
349+
(variable_declaration
350+
(implicit_type)
351+
(variable_declarator
352+
(identifier)
353+
(equals_value_clause
354+
(lambda_expression
355+
(attribute_list (attribute (identifier)))
356+
(parameter_list)
357+
(invocation_expression
358+
(member_access_expression
359+
(identifier)
360+
(identifier))
361+
(argument_list
362+
(argument
363+
(string_literal)))))))))))
364+

corpus/records.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,31 @@ record Teacher(string FirstName, string LastName, string Subject) : Person(First
209209
(identifier)
210210
(identifier))))
211211

212+
=====================================
213+
Record types can end with a semicolon
214+
=====================================
215+
216+
public record Person { };
217+
218+
public record struct Person2 { };
219+
220+
---
221+
222+
(compilation_unit
223+
(record_declaration
224+
(modifier)
225+
(identifier)
226+
(declaration_list))
227+
(record_struct_declaration
228+
(modifier)
229+
(identifier)
230+
(declaration_list)))
231+
212232
=====================================
213233
Record types can seal ToString()
214234
=====================================
215235

216-
record A{
236+
record A {
217237
public sealed override string ToString(){
218238
return "";
219239
}

grammar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ module.exports = grammar({
604604
field('bases', optional(alias($.record_base, $.base_list))),
605605
repeat($.type_parameter_constraints_clause),
606606
field('body', $._record_body),
607+
optional(';')
607608
),
608609

609610
record_struct_declaration: $ => seq(
@@ -617,6 +618,7 @@ module.exports = grammar({
617618
field('bases', optional(alias($.record_base, $.base_list))),
618619
repeat($.type_parameter_constraints_clause),
619620
field('body', $._record_body),
621+
optional(';')
620622
),
621623

622624
record_base: $ => choice(
@@ -1087,6 +1089,7 @@ module.exports = grammar({
10871089
),
10881090

10891091
lambda_expression: $ => prec(-1, seq(
1092+
repeat($.attribute_list),
10901093
optional(alias(choice('async', 'static', seq('async', 'static'), seq('static', 'async')), $.modifier)),
10911094
choice(field('parameters', $.parameter_list), $.identifier),
10921095
'=>',

0 commit comments

Comments
 (0)