Skip to content

Commit

Permalink
solved #163
Browse files Browse the repository at this point in the history
  • Loading branch information
mistermboy committed Aug 10, 2020
1 parent 27ebec4 commit 53f3a13
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
29 changes: 20 additions & 9 deletions dist/yashe.bundled.min.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ YASHE.defaults = $.extend(true, {}, YASHE.defaults, {
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
:User {
schema:name <wtf> ;
}
:Person [ schema:Person
`,

Expand Down
23 changes: 18 additions & 5 deletions src/utils/syntaxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var checkSyntax = function(yashe) {
let closedBracketsCounter = 0;
let openParenthesisCounter = 0;
let closedParenthesisCounter = 0;
let openSquareBracketsCounter = 0;
let closedSquareBracketsCounter = 0;
for (var l = 0; l < yashe.lineCount(); ++l) {

var precise = false;
Expand Down Expand Up @@ -76,23 +78,28 @@ var checkSyntax = function(yashe) {
let lineTokens = yashe.getLineTokens(l);
for(let t in lineTokens){
let token = lineTokens[t];
// This is only necessary to verify the if the last '}' is missing
// (See #104 https://github.com/weso/YASHE/issues/104)

if(token.string=='{'){
openBracketsCounter++;
}
if(token.string=='}'){
closedBracketsCounter++;
}

//This is only necessary to verify the if the last ')' is missing (See #104)
// (See #150 https://github.com/weso/YASHE/issues/150)
if(token.string=='('){
openParenthesisCounter++;
}
if(token.string==')'){
closedParenthesisCounter++;
}

if(token.string=='['){
openSquareBracketsCounter++;
}
if(token.string==']'){
closedSquareBracketsCounter++;
}

}

updateShapesAndPrefixes(yashe,l);
Expand All @@ -112,6 +119,13 @@ var checkSyntax = function(yashe) {
return false;
}

//Is last ']' missing? (See #163 https://github.com/weso/YASHE/issues/163)
if(openSquareBracketsCounter != closedSquareBracketsCounter){
setError(yashe.lastLine(),"This line is invalid. Expected: ']'",yashe)
yashe.queryValid = false;
return false;
}



if(!checkPrefixes(yashe))return false;
Expand Down Expand Up @@ -185,7 +199,6 @@ var checkSyntax = function(yashe) {

}



/**
* Check if the ShapeRefs are defined
Expand Down

0 comments on commit 53f3a13

Please sign in to comment.