Skip to content

Commit a8409e0

Browse files
committed
feat: add SPARQL* support
1 parent c80f05f commit a8409e0

4 files changed

Lines changed: 66 additions & 8 deletions

File tree

src/color-schemes/macaron-dark.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ module.exports = {
9393
background: 'hsla(280, 70%, 10%, 0.2)',
9494
},
9595

96+
// nested reified statement
97+
{
98+
scope: 'meta.triple.reified-nested',
99+
background: 'hsla(280, 70%, 10%, 0.4)',
100+
},
101+
96102

97103
// shared regex scopes
98104
...a_regex_scopes,

src/color-schemes/macaron-light.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ module.exports = {
8989
foreground_adjust: 'saturation(55%)',
9090
},
9191

92+
// nested reified statement
93+
{
94+
scope: 'meta.triple.reified-nested',
95+
background: 'hsla(140, 80%, 70%, 0.4)',
96+
foreground_adjust: 'saturation(55%)',
97+
},
98+
99+
92100
// shared regex scopes
93101
...a_regex_scopes,
94102
],

src/syntax/sparql.syntax-source

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ contexts:
696696

697697
bind_AFTER_BIND:
698698
- open.paren: section.bind
699-
set: [bind_AFTER_EXPRESSION, expression]
699+
set: [bind_AFTER_EXPRESSION, expressionOrEmbTP]
700700

701701
bind_AFTER_EXPRESSION:
702702
- word: as
@@ -850,11 +850,48 @@ contexts:
850850
set: constructTriples_OPTIONAL
851851
- bail
852852

853+
###################################
854+
# < SPARQL* >
855+
###################################
856+
embeddedTriplePattern:
857+
- match: '<<'
858+
scope: punctuation.definition.triple-x.begin.SYNTAX meta.triple.reified.SYNTAX
859+
mask: meta.triple.reified.SYNTAX
860+
set: [embeddedTriplePattern_TERMINATE, embeddedTriplePattern_THING, verb, embeddedTriplePattern_THING]
861+
862+
embeddedTriplePatternNested:
863+
- goto: embeddedTriplePattern
864+
mask: meta.triple.reified-nested.SYNTAX
865+
866+
embeddedTriplePattern_THING:
867+
- switch:
868+
- embeddedTriplePatternNested
869+
- varOrTerm
870+
871+
embeddedTriplePattern_TERMINATE:
872+
- match: '>>'
873+
scope: punctuation.definition.triple-x.end.SYNTAX meta.triple.reified.SYNTAX
874+
pop: true
875+
876+
varOrTermOrEmbTP:
877+
- switch:
878+
- embeddedTriplePattern
879+
- include: varOrTerm
880+
881+
expressionOrEmbTP:
882+
- switch:
883+
- embeddedTriplePattern
884+
- include: expression
885+
886+
###################################
887+
# </ SPARQL* >
888+
###################################
889+
853890
triplesSameSubject:
854891
- switch:
855892
- hollowAnonymousBlankNode: [propertyListNotEmpty, hollowAnonymousBlankNode]
856893
- anonymousBlankNode: anonymousBlankNode_LATENT_PL_PLNE
857-
- varOrTerm: [propertyListNotEmpty_REQUIRED, varOrTerm]
894+
- varOrTermOrEmbTP: [propertyListNotEmpty_REQUIRED, varOrTermOrEmbTP]
858895
- triplesNode: [propertyList, triplesNode]
859896

860897
anonymousBlankNode_LATENT:
@@ -934,7 +971,7 @@ contexts:
934971
- switch:
935972
- hollowAnonymousBlankNode: [propertyListPathNotEmpty, hollowAnonymousBlankNode]
936973
- anonymousBlankNode: anonymousBlankNode_LATENT_PLP_PLPNE
937-
- varOrTerm: [propertyListPathNotEmpty, varOrTerm]
974+
- varOrTermOrEmbTP: [propertyListPathNotEmpty, varOrTermOrEmbTP]
938975
- triplesNode: [propertyListPath, triplesNodePath]
939976

940977
anonymousBlankNode_LATENT_PLP_PLPNE:
@@ -1105,14 +1142,14 @@ contexts:
11051142
- switch:
11061143
- hollowAnonymousBlankNode
11071144
- anonymousBlankNode: anonymousBlankNode_LATENT
1108-
- varOrTerm
1145+
- varOrTermOrEmbTP
11091146
- triplesNode
11101147

11111148
graphNodePath:
11121149
- switch:
11131150
- hollowAnonymousBlankNode
11141151
- anonymousBlankNode: anonymousBlankNodePath_LATENT
1115-
- varOrTerm
1152+
- varOrTermOrEmbTP
11161153
- triplesNodePath
11171154

11181155
varOrTerm:

src/syntax/terse.syntax-source

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ contexts:
130130
- switch:
131131
- collection
132132
- labeledBlankNode
133+
- tripleX
133134
- namedNode
134135
mask: meta.term.role.object.SYNTAX
135136
- goto: literal
@@ -138,7 +139,9 @@ contexts:
138139
literal:
139140
- switch:
140141
- stringLiteral: rdfLiteral
141-
- words: ['true', 'false']
142+
- words:
143+
- 'true'
144+
- 'false'
142145
scope: constant.language.boolean.WORD.SYNTAX
143146
pop: true
144147
- include: numericLiteral
@@ -347,9 +350,13 @@ contexts:
347350
mask: meta.triple.reified.SYNTAX
348351
set: [tripleX_TERMINATE, tripleX_AFTER_BEGIN]
349352

353+
tripleXNested:
354+
- goto: tripleX
355+
mask: meta.triple.reified-nested.SYNTAX
356+
350357
tripleX_AFTER_BEGIN:
351358
- switch:
352-
- tripleX: [predicateObjectListX^, tripleX]
359+
- tripleX: [predicateObjectListX^, tripleXNested]
353360
- hollowAnonymousBlankNode: [predicateObjectListX^, hollowAnonymousBlankNode]
354361
- anonymousBlankNode: [predicateObjectListX?, blankNodePropertyList]
355362
- collection: [predicateObjectListX^, collection]
@@ -363,7 +370,7 @@ contexts:
363370

364371
objectX:
365372
- switch:
366-
- tripleX
373+
- tripleXNested
367374
- goto: object
368375

369376
tripleX_TERMINATE:

0 commit comments

Comments
 (0)