| OLD | NEW |
| 1 Editor.Parser = (function() { | 1 Editor.Parser = (function() { |
| 2 function wordRegexp(words) { | 2 function wordRegexp(words) { |
| 3 return new RegExp("^(?:" + words.join("|") + ")$", "i"); | 3 return new RegExp("^(?:" + words.join("|") + ")$", "i"); |
| 4 } | 4 } |
| 5 var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "same
term", "isiri", "isuri", | 5 var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "same
term", "isiri", "isuri", |
| 6 "isblank", "isliteral", "union", "a"]); | 6 "isblank", "isliteral", "union", "a"]); |
| 7 var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced",
"construct", "describe", | 7 var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced",
"construct", "describe", |
| 8 "ask", "from", "named", "where", "order", "limit",
"offset", "filter", "optional", | 8 "ask", "from", "named", "where", "order", "limit",
"offset", "filter", "optional", |
| 9 "graph", "by", "asc", "desc", ]); | 9 "graph", "by", "asc", "desc", ]); |
| 10 var operatorChars = /[*+\-<>=&|]/; | 10 var operatorChars = /[*+\-<>=&|]/; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 if (content != "\n") col += width; | 125 if (content != "\n") col += width; |
| 126 | 126 |
| 127 if (/[\[\{\(]/.test(content)) { | 127 if (/[\[\{\(]/.test(content)) { |
| 128 pushContext(content, width); | 128 pushContext(content, width); |
| 129 } | 129 } |
| 130 else if (/[\]\}\)]/.test(content)) { | 130 else if (/[\]\}\)]/.test(content)) { |
| 131 while (context && context.type == "pattern") | 131 while (context && context.type == "pattern") |
| 132 popContext(); | 132 popContext(); |
| 133 if (context && content == matching[context.type]) | 133 if (context && content == matching[context.type]) |
| 134 popContext(); | 134 popContext(); |
| 135 } | 135 } |
| 136 else if (content == "." && context && context.type == "pattern") { | 136 else if (content == "." && context && context.type == "pattern") { |
| 137 popContext(); | 137 popContext(); |
| 138 } | 138 } |
| 139 else if ((type == "sp-word" || type == "sp-prefixed" || type == "sp-uri"
|| type == "sp-var" || type == "sp-literal") && | 139 else if ((type == "sp-word" || type == "sp-prefixed" || type == "sp-uri"
|| type == "sp-var" || type == "sp-literal") && |
| 140 context && /[\{\[]/.test(context.type)) { | 140 context && /[\{\[]/.test(context.type)) { |
| 141 pushContext("pattern", width); | 141 pushContext("pattern", width); |
| 142 } | 142 } |
| 143 | 143 |
| 144 return token; | 144 return token; |
| 145 }, | 145 }, |
| 146 | 146 |
| 147 copy: function() { | 147 copy: function() { |
| 148 var _context = context, _indent = indent, _col = col, _tokenState = toke
ns.state; | 148 var _context = context, _indent = indent, _col = col, _tokenState = toke
ns.state; |
| 149 return function(source) { | 149 return function(source) { |
| 150 tokens = tokenizeSparql(source, _tokenState); | 150 tokens = tokenizeSparql(source, _tokenState); |
| 151 context = _context; | 151 context = _context; |
| 152 indent = _indent; | 152 indent = _indent; |
| 153 col = _col; | 153 col = _col; |
| 154 return iter; | 154 return iter; |
| 155 }; | 155 }; |
| 156 } | 156 } |
| 157 }; | 157 }; |
| 158 return iter; | 158 return iter; |
| 159 } | 159 } |
| 160 | 160 |
| 161 return {make: parseSparql, electricChars: "}]"}; | 161 return {make: parseSparql, electricChars: "}]"}; |
| 162 })(); | 162 })(); |
| OLD | NEW |