Skip to content

Commit 955b632

Browse files
MiracleBluenwolverson
authored andcommitted
Fixed nested record type definitions in data types, as well as record types in type aliases. Fixes #39
1 parent c590de5 commit 955b632

File tree

2 files changed

+63
-36
lines changed

2 files changed

+63
-36
lines changed

grammars/purescript.cson

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -205,24 +205,7 @@
205205
'name': 'punctuation.separator.pipe.purescript'
206206
}
207207
{
208-
'name': 'meta.declaratyion.type.data.record.block.purescript'
209-
'begin': '\\{'
210-
'beginCaptures':
211-
'0':
212-
'name': 'keyword.operator.record.begin.purescript'
213-
'end': '\\}'
214-
'endCaptures':
215-
'0':
216-
'name': 'keyword.operator.record.end.purescript'
217-
'patterns': [
218-
{
219-
'name': 'punctuation.separator.comma.purescript'
220-
'match': ','
221-
}
222-
{
223-
'include': '#record_field_declaration'
224-
}
225-
]
208+
'include': '#record_types'
226209
}
227210
]
228211
}
@@ -242,9 +225,6 @@
242225
}
243226
]
244227
'patterns': [
245-
{
246-
'include': '#comments'
247-
}
248228
{
249229
'match': '='
250230
'captures':
@@ -254,6 +234,12 @@
254234
{
255235
'include': '#type_signature'
256236
}
237+
{
238+
'include': '#record_types'
239+
}
240+
{
241+
'include': '#comments'
242+
}
257243
]
258244
}
259245
{
@@ -437,6 +423,32 @@
437423
]
438424
}
439425
]
426+
'record_types':
427+
'patterns': [
428+
{
429+
'name': 'meta.type.record.purescript'
430+
'begin': '\\{'
431+
'beginCaptures':
432+
'0':
433+
'name': 'keyword.operator.type.record.begin.purescript'
434+
'end': '\\}'
435+
'endCaptures':
436+
'0':
437+
'name': 'keyword.operator.type.record.end.purescript'
438+
'patterns': [
439+
{
440+
'name': 'punctuation.separator.comma.purescript'
441+
'match': ','
442+
}
443+
{
444+
'include': '#record_field_declaration'
445+
}
446+
{
447+
'include': '#comments'
448+
}
449+
]
450+
}
451+
]
440452
'comments':
441453
'patterns': [
442454
{
@@ -582,6 +594,9 @@
582594
{
583595
'include': '#type_signature'
584596
}
597+
{
598+
'include': '#record_types'
599+
}
585600
]
586601
}
587602
]

src/purescript.coffee

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,7 @@ purescriptGrammar =
199199
captures:
200200
0: name: 'punctuation.separator.pipe'
201201
,
202-
name: 'meta.declaratyion.type.data.record.block'
203-
begin: /\{/
204-
beginCaptures:
205-
0: name: 'keyword.operator.record.begin'
206-
end: /\}/
207-
endCaptures:
208-
0: name: 'keyword.operator.record.end'
209-
patterns: [
210-
name: 'punctuation.separator.comma'
211-
match: /,/
212-
,
213-
include: '#record_field_declaration'
214-
]
202+
include: '#record_types'
215203
]
216204
,
217205
name: 'meta.declaration.type.type'
@@ -224,13 +212,15 @@ purescriptGrammar =
224212
name: 'meta.type-signature'
225213
patterns: [include: '#type_signature']
226214
patterns: [
227-
include: '#comments'
228-
,
229215
match: /=/
230216
captures:
231217
0: name: 'keyword.operator.assignment'
232218
,
233219
include: '#type_signature'
220+
,
221+
include: '#record_types'
222+
,
223+
include: '#comments'
234224
]
235225
,
236226
name: 'keyword.other'
@@ -363,6 +353,26 @@ purescriptGrammar =
363353
include: '#block_comment'
364354
]
365355
]
356+
record_types:
357+
patterns: [
358+
name: 'meta.type.record'
359+
begin: '\\{'
360+
beginCaptures:
361+
0:
362+
name: 'keyword.operator.type.record.begin.purescript'
363+
end: '\\}'
364+
endCaptures:
365+
0:
366+
name: 'keyword.operator.type.record.end.purescript'
367+
patterns: [
368+
name: 'punctuation.separator.comma.purescript'
369+
match: ','
370+
,
371+
include: '#record_field_declaration'
372+
,
373+
include: '#comments'
374+
]
375+
]
366376
comments:
367377
patterns: [
368378
begin: /({maybeBirdTrack}[ \t]+)?(?=--+\s+\|)/
@@ -463,6 +473,8 @@ purescriptGrammar =
463473
2: name: 'keyword.other.double-colon'
464474
patterns: [
465475
include: '#type_signature'
476+
,
477+
include: '#record_types'
466478
]
467479
kind_signature:
468480
patterns: [

0 commit comments

Comments
 (0)