Skip to content

Commit

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

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions lib/grammar/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,14 @@ CodeMirror.defineMode("shex", function(config, parserConfig) {

if(topSymbol=='nodeConstraint'){
if(token!='['){
if(!token.match(grammar.keywords)){
tokenOb.style='constraint';
if(!token.match(grammar.keywords) || token == 'IRI_REF'){ //IRI_REF MATCHES WITH IRI
tokenOb.style='constraint';
}else{
tokenOb.style='constraintKeyword';
}
}
}


if (!ll1_table[topSymbol]) {
// Top symbol is a terminal
if (topSymbol == token) {
Expand Down
11 changes: 6 additions & 5 deletions src/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ YASHE.defaults = $.extend(true, {}, YASHE.defaults, {
/**
* Default shape
*/
value: `PREFIX : <http://example.org/>
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
value: `PREFIX : <http://example.org/>
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
:Product ( schema:name
:User {
schema:name <wtf> ;
}
`,

Expand Down
12 changes: 8 additions & 4 deletions src/utils/syntaxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ 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)
// 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++;
}
Expand All @@ -94,13 +98,14 @@ var checkSyntax = function(yashe) {
updateShapesAndPrefixes(yashe,l);
}

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

//Is last ')' missing? (See #150 https://github.com/weso/YASHE/issues/150)
if(openParenthesisCounter != closedParenthesisCounter){
setError(yashe.lastLine(),"This line is invalid. Expected: ')'",yashe)
yashe.queryValid = false;
Expand Down Expand Up @@ -134,8 +139,7 @@ var checkSyntax = function(yashe) {
let token = lineTokens[t];


if(token.type=='string-2' ||
token.type=='constraint'){
if(token.type=='string-2'|| (token.type=='constraint' && token.string.includes(":"))){
yashe.usedPrefixes.push({
alias:token.string.split(":")[0]+':',
line:l });
Expand Down

0 comments on commit 27ebec4

Please sign in to comment.