Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add existdb parser #48

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib/parsers/ExistParser.js
lib/parsers/XQueryParser.js
lib/parsers/JSONiqParser.js
lib/lexers/XQueryTokenizer.js
Expand Down
8 changes: 7 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ module.exports = function(grunt) {
destination: 'lib/parsers/JSONiqParser.js',
command: '-ll 2 -backtrack -tree -javascript -a xqlint',
tz: '-60',
}
},
{
source: 'lib/parsers/ExistParser.ebnf',
destination: 'lib/parsers/ExistParser.js',
command: '-ll 3 -tree -javascript -a xqlint',
tz: '-60',
}
]
},
lexers: {
Expand Down
3 changes: 2 additions & 1 deletion lib/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ lintCmd.option(
return value === 'yes';
}
)
.option('-e, --existdb', 'Support existdb syntax')
.description('Check queries')
.action(function(p) {
var files = getFiles(p);
Expand All @@ -119,7 +120,7 @@ lintCmd.option(
};
files.forEach(function(file){
var source = fs.readFileSync(file, 'utf-8').replace(/^\uFEFF/, '');
var linter = new XQLint(source, { fileName: file, styleCheck: lintCmd.styleCheck });
var linter = new XQLint(source, { fileName: file, styleCheck: lintCmd.styleCheck === true, existdb: lintCmd.existdb === true });
var markers = linter.getMarkers().sort(function(a, b){ return a.sl - b.sl; });
var lines = source.split('\n');
if(markers.length !== 0) {
Expand Down
3 changes: 2 additions & 1 deletion lib/compiler/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ exports.Translator = function(rootStcx, ast){

this.FunctionCall = function(node){
this.visitOnly(node, ['ArgumentList']);
var name = translator.getFirstChild(node, 'EQName');
//existdb hack
var name = translator.getFirstChild(node, 'EQName') || translator.getFirstChild(node, 'FunctionEQName');
var eqname = TreeOps.flatten(name);
var arity = get(node, ['ArgumentList', 'Argument']).length;
translator.apply(function(){
Expand Down
12 changes: 7 additions & 5 deletions lib/lexers/JSONiqTokenizer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// This file was generated on Sun Jul 5, 2015 13:37 (UTC+01) by REx v5.34 which is Copyright (c) 1979-2015 by Gunther Rademacher <grd@gmx.net>
// REx command line: JSONiqTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint

// line 2 "JSONiqTokenizer.ebnf"
Expand Down Expand Up @@ -1426,9 +1426,8 @@
{
if (e0 != b1)
{
b0 = e0;
eventHandler.whitespace(e0, b1);
e0 = b1;
eventHandler.whitespace(b0, e0);
}
}

Expand Down Expand Up @@ -1471,7 +1470,7 @@
throw new self.ParseException(b, e, s, l, t);
}

var lk, b0, e0;
var b0, e0;
var l1, b1, e1;
var eventHandler;

Expand Down Expand Up @@ -1566,7 +1565,7 @@
JSONiqTokenizer.getTokenSet = function(tokenSetId)
{
var set = [];
var s = tokenSetId < 0 ? - tokenSetId : INITIAL[tokenSetId] & 4095;
var s = tokenSetId < 0 ? - tokenSetId : JSONiqTokenizer.INITIAL[tokenSetId] & 4095;
for (var i = 0; i < 279; i += 32)
{
var j = i;
Expand Down Expand Up @@ -4201,4 +4200,7 @@ JSONiqTokenizer.TOKEN =
"'}}'"
];

// line 520 "JSONiqTokenizer.ebnf"

// line 4206 "JSONiqTokenizer.js"
// End
12 changes: 7 additions & 5 deletions lib/lexers/XQueryTokenizer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// This file was generated on Sun Jul 5, 2015 13:37 (UTC+01) by REx v5.34 which is Copyright (c) 1979-2015 by Gunther Rademacher <grd@gmx.net>
// REx command line: XQueryTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint

// line 2 "XQueryTokenizer.ebnf"
Expand Down Expand Up @@ -1426,9 +1426,8 @@
{
if (e0 != b1)
{
b0 = e0;
eventHandler.whitespace(e0, b1);
e0 = b1;
eventHandler.whitespace(b0, e0);
}
}

Expand Down Expand Up @@ -1471,7 +1470,7 @@
throw new self.ParseException(b, e, s, l, t);
}

var lk, b0, e0;
var b0, e0;
var l1, b1, e1;
var eventHandler;

Expand Down Expand Up @@ -1566,7 +1565,7 @@
XQueryTokenizer.getTokenSet = function(tokenSetId)
{
var set = [];
var s = tokenSetId < 0 ? - tokenSetId : INITIAL[tokenSetId] & 4095;
var s = tokenSetId < 0 ? - tokenSetId : XQueryTokenizer.INITIAL[tokenSetId] & 4095;
for (var i = 0; i < 276; i += 32)
{
var j = i;
Expand Down Expand Up @@ -4168,4 +4167,7 @@ XQueryTokenizer.TOKEN =
"'}}'"
];

// line 510 "XQueryTokenizer.ebnf"

// line 4173 "XQueryTokenizer.js"
// End
Loading