Skip to content

Commit

Permalink
solved #150
Browse files Browse the repository at this point in the history
  • Loading branch information
mistermboy committed Aug 10, 2020
1 parent 4ae7dfe commit bf9ca97
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 59 deletions.
55 changes: 25 additions & 30 deletions dist/yashe.bundled.min.js

Large diffs are not rendered by default.

27 changes: 4 additions & 23 deletions src/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,12 @@ YASHE.defaults = $.extend(true, {}, YASHE.defaults, {
/**
* Default shape
*/
value: `PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX : <http://example.org/>
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
start = @<#sequence_assembly>
# Result query SELECT ?item WHERE { ?item wdt:P2576 ?id }
<#sequence_assembly> {
# UCSC Genome Browser assembly ID or GenBank assembly accession
( p:P2576 { ps:P2576 xsd:string } |
p:P4333 { ps:P4333 xsd:string }
) ;
( schema:isRelatedTo @:Product |
schema:isSimilarTo @:Product )
}
:Product
value: `PREFIX : <http://example.org/>
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
:Product ( schema:name
`,

Expand Down
26 changes: 20 additions & 6 deletions src/utils/syntaxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ var checkSyntax = function(yashe) {
resetValues(yashe);

var state = null;
let openTokensCounter = 0;
let closedTokensCounter = 0;
let openBracketsCounter = 0;
let closedBracketsCounter = 0;
let openParenthesisCounter = 0;
let closedParenthesisCounter = 0;
for (var l = 0; l < yashe.lineCount(); ++l) {

var precise = false;
Expand Down Expand Up @@ -76,23 +78,35 @@ var checkSyntax = function(yashe) {
let token = lineTokens[t];
//This is only necessary to verify the if the last '}' is missing (See #104)
if(token.string=='{'){
openTokensCounter++;
openBracketsCounter++;
}
if(token.string=='}'){
closedTokensCounter++;
closedBracketsCounter++;
}
if(token.string=='('){
openParenthesisCounter++;
}
if(token.string==')'){
closedParenthesisCounter++;
}
}

updateShapesAndPrefixes(yashe,l);
}

//Is last '}' missing? (See #104)
if(openTokensCounter != closedTokensCounter){
if(openBracketsCounter != closedBracketsCounter){
setError(yashe.lastLine(),"This line is invalid. Expected: '}'",yashe)
yashe.queryValid = false;
return false;
}

if(openParenthesisCounter != closedParenthesisCounter){
setError(yashe.lastLine(),"This line is invalid. Expected: ')'",yashe)
yashe.queryValid = false;
return false;
}



if(!checkPrefixes(yashe))return false;
Expand Down Expand Up @@ -224,7 +238,7 @@ var checkSyntax = function(yashe) {
var reCheckSyntax = function(yashe){
setTimeout(() => {
checkSyntax(yashe);
}, 380);
}, 400);
}

module.exports = {
Expand Down

0 comments on commit bf9ca97

Please sign in to comment.