mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 480238 - Clean Up Acorn QML Parser
Fixed the AST elements so that they more closely match the format used by acorn (i.e. using 'id' instead of 'identifier' and 'name' instead of 'raw' for the identifier name). Resolved one of the ambiguities dealing with using 'signal', 'property', and 'readonly' as identifiers for properties and QML Objects. Added a bunch of new tests and fixed the old ones to match the new AST. Change-Id: I5a8bbd14b3e6f8531268740dd9e57cb48a0e22b3 Signed-off-by: Matthew Bastien <mbastien@blackberry.com>
This commit is contained in:
parent
5eaf1129a5
commit
19cd53ec10
6 changed files with 2528 additions and 1917 deletions
|
@ -13,12 +13,12 @@
|
|||
// This will only be visible globally if we are in a browser environment
|
||||
var acornQML;
|
||||
|
||||
(function(mod) {
|
||||
(function (mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
return module.exports = mod(require("./inject.js"), require("acorn"));
|
||||
if (typeof define == "function" && define.amd) // AMD
|
||||
return define(["./inject.js", "acorn/dist/acorn"], mod);
|
||||
acornQML = mod(injectQML, acorn); // Plain browser env
|
||||
})(function(injectQML, acorn) {
|
||||
return injectQML(acorn);
|
||||
})(function (injectQML, acorn) {
|
||||
return injectQML(acorn);
|
||||
})
|
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,6 @@
|
|||
"test": "node test/run.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": "^2.4.0"
|
||||
"acorn": "^2.5.2"
|
||||
}
|
||||
}
|
|
@ -75,7 +75,7 @@ outputStats("Total", total);
|
|||
groupEnd();
|
||||
|
||||
if (total.failed && typeof process === "object") {
|
||||
process.stdout.write("", function() {
|
||||
process.stdout.write("", function () {
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -10,67 +10,52 @@
|
|||
*******************************************************************************/
|
||||
'use strict';
|
||||
|
||||
(function(mod) {
|
||||
(function (mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
return mod(require("acorn/walk"));
|
||||
if (typeof define == "function" && define.amd) // AMD
|
||||
return define([ "acorn/dist/walk" ], mod);
|
||||
return define(["acorn/dist/walk"], mod);
|
||||
mod(acorn.walk); // Plain browser env
|
||||
})(function(walk) {
|
||||
function skipThrough(node, st, c) { c(node, st) }
|
||||
function ignore(node, st, c) {}
|
||||
})(function (walk) {
|
||||
function skipThrough(node, st, c) {
|
||||
c(node, st)
|
||||
}
|
||||
|
||||
var base = walk.base;
|
||||
base["Program"] = function(node, st, c) {
|
||||
for (var i = 0; i < node.body.length; i++) {
|
||||
var nodeBody = node.body[i];
|
||||
if (node.body[i].type === "QMLObjectLiteral") {
|
||||
c(node.body[i], st, "QMLRootObject");
|
||||
} else {
|
||||
c(node.body[i], st);
|
||||
}
|
||||
}
|
||||
}
|
||||
base["QMLHeaderStatements"] = function(node, st, c) {
|
||||
for (var i = 0; i < node.statements.length; i++) {
|
||||
c(node.statements[i], st, "QMLHeaderStatement");
|
||||
}
|
||||
}
|
||||
base["QMLHeaderStatement"] = skipThrough;
|
||||
base["QMLImportStatement"] = function(node, st, c) {
|
||||
c(node.module, st);
|
||||
}
|
||||
base["QMLModule"] = ignore;
|
||||
base["QMLPragmaStatement"] = ignore;
|
||||
base["QMLRootObject"] = skipThrough;
|
||||
base["QMLObjectLiteral"] = function(node, st, c) {
|
||||
c(node.block, st);
|
||||
}
|
||||
base["QMLMemberBlock"] = function(node, st, c) {
|
||||
for (var i = 0; i < node.members.length; i++) {
|
||||
c(node.members[i], st, "QMLMember");
|
||||
}
|
||||
}
|
||||
base["QMLMember"] = skipThrough;
|
||||
base["QMLPropertyDeclaration"] = function(node, st, c) {
|
||||
c(node.identifier, st, "Pattern");
|
||||
c(node.binding, st);
|
||||
}
|
||||
base["QMLSignalDefinition"] = ignore;
|
||||
base["QMLProperty"] = function(node, st, c) {
|
||||
// c(node.qualifiedId, st)
|
||||
c(node.binding, st);
|
||||
}
|
||||
base["QMLBinding"] = function(node, st, c) {
|
||||
if (node.block) {
|
||||
c(node.block, st);
|
||||
} else {
|
||||
c(node.expr, st, "Expression");
|
||||
}
|
||||
}
|
||||
base["QMLStatementBlock"] = function(node, st, c) {
|
||||
for (var i = 0; i < node.statements.length; i++) {
|
||||
c(node.statements[i], st, "Statement");
|
||||
}
|
||||
}
|
||||
function ignore(node, st, c) {}
|
||||
|
||||
var base = walk.base;
|
||||
base["Program"] = function (node, st, c) {
|
||||
c(node.headerStatements, st);
|
||||
c(node.rootObject, st, "QMLRootObject");
|
||||
};
|
||||
base["QMLHeaderStatements"] = function (node, st, c) {
|
||||
for (var i = 0; i < node.statements.length; i++) {
|
||||
c(node.statements[i], st, "QMLHeaderStatement");
|
||||
}
|
||||
};
|
||||
base["QMLHeaderStatement"] = skipThrough;
|
||||
base["QMLImportStatement"] = ignore;
|
||||
base["QMLPragmaStatement"] = ignore;
|
||||
base["QMLRootObject"] = skipThrough;
|
||||
base["QMLObjectLiteral"] = function (node, st, c) {
|
||||
c(node.block, st);
|
||||
};
|
||||
base["QMLMemberBlock"] = function (node, st, c) {
|
||||
for (var i = 0; i < node.members.length; i++) {
|
||||
c(node.members[i], st, "QMLMember");
|
||||
}
|
||||
};
|
||||
base["QMLMember"] = skipThrough;
|
||||
base["QMLPropertyDeclaration"] = function (node, st, c) {
|
||||
c(node.binding, st);
|
||||
};
|
||||
base["QMLSignalDefinition"] = ignore;
|
||||
base["QMLPropertyBinding"] = function (node, st, c) {
|
||||
c(node.binding, st);
|
||||
};
|
||||
base["QMLStatementBlock"] = function (node, st, c) {
|
||||
for (var i = 0; i < node.statements.length; i++) {
|
||||
c(node.statements[i], st, "Statement");
|
||||
}
|
||||
};
|
||||
})
|
Loading…
Add table
Reference in a new issue