Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved recursiveparser to a new file

  • Loading branch information...
commit cd36e01c4390a22a2261086d098782acf2da8abb 1 parent 8d72c38
@codeboost authored
View
75 bealoader.js
@@ -1,13 +1,13 @@
(function() {
- var BeaLoader, BeaParser, ClassConverter, CodeBlock, MessageLogger, RecursiveParser, beautils, doConvert, fs, mgr, util, _;
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
+ var BeaLoader, BeaParser, ClassConverter, CodeBlock, MessageLogger, beautils, doConvert, fs, mgr, rp, util, _;
+ var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
- };
+ }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
_ = require('underscore');
BeaParser = require('./beaparser').BeaParser;
CodeBlock = require('./codeblock').CodeBlock;
@@ -16,72 +16,7 @@
beautils = require('./beautils');
fs = require('fs');
util = require('util');
- RecursiveParser = (function() {
- function RecursiveParser() {
- this.includes = [];
- }
- RecursiveParser.prototype.parseFile = function(fileName) {
- var contents, parser, ret;
- contents = fs.readFileSync(fileName, "ascii");
- if (!contents) {
- this.error("Cannot read file '" + fileName + "'.");
- return false;
- }
- this.includes.push(fileName);
- parser = new BeaParser(fileName);
- parser.parse(contents);
- ret = this.processIncludes(parser.root);
- return ret;
- };
- RecursiveParser.prototype.error = function(msg) {
- return console.log(msg);
- };
- RecursiveParser.prototype.warn = function(msg, node) {
- var fileName, line, _ref, _ref2;
- fileName = (_ref = (node != null ? node.fileName : void 0)) != null ? _ref : "";
- line = (_ref2 = (node != null ? node.line : void 0)) != null ? _ref2 : 0;
- if (line > 0) {
- line = "(" + line + ")";
- } else {
- line = "";
- }
- return console.log("" + fileName + "(" + line + "): warning: " + msg);
- };
- RecursiveParser.prototype.include = function(node) {
- var fileName, _ref;
- fileName = (_ref = node.text.match(/^@include\s+\"(.+)\"/, "")) != null ? _ref[1] : void 0;
- if (!fileName) {
- return this.warn("Invalid include directive", node);
- }
- fileName = fs.realpathSync(fileName);
- if (_.any(this.includes, function(nf) {
- return nf === fileName;
- })) {
- return this.warn("File " + fileName + " already included!", node);
- }
- console.log('Included file ' + fileName);
- return this.parseFile(fileName);
- };
- RecursiveParser.prototype.processIncludes = function(root) {
- var children, gr;
- children = root.children;
- gr = 0;
- _.each(root.children, __bind(function(node, i) {
- var ret, retc, _ref;
- if (node.type() === '@include') {
- ret = this.include(node);
- retc = (_ref = ret != null ? ret.children : void 0) != null ? _ref : [];
- children = children.slice(0, i + gr).concat(retc, children.slice(i + gr + 1));
- if (retc.length) {
- return gr = gr + retc.length - 1;
- }
- }
- }, this));
- root.children = children;
- return root;
- };
- return RecursiveParser;
- })();
+ rp = require('./recursiveparser');
MessageLogger = (function() {
function MessageLogger() {}
MessageLogger.warnings = 0;
@@ -384,7 +319,7 @@
};
BeaLoader.prototype.load = function(fileName) {
var parser, root;
- parser = new RecursiveParser;
+ parser = new rp.RecursiveParser;
root = parser.parseFile(fileName);
if (!root) {
return false;
View
6 beaparser.js
@@ -65,7 +65,11 @@
BeaParser.prototype.parseLine = function(txt, linenumber) {
var level, node, rawTxt, tmp, _ref;
level = (_ref = txt.match(/(^\s+)/g)) != null ? _ref[0].length : void 0;
- level != null ? level : level = 0;
+ if (level != null) {
+ level;
+ } else {
+ level = 0;
+ };
level++;
rawTxt = txt.replace(/^\s+|\s+$/g, '');
if (!rawTxt.length) {
View
2  classconvert.js
@@ -8,7 +8,7 @@
/*
TODO:
- Warn if class does not define a constructor/insert default constructor
-
+
*/
FnCall = (function() {
function FnCall(retVal, name, argList) {
View
74 recursiveparser.js
@@ -0,0 +1,74 @@
+(function() {
+ var BeaParser, RecursiveParser, fs, _;
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+ fs = require('fs');
+ BeaParser = require('./beaparser').BeaParser;
+ _ = require('underscore');
+ RecursiveParser = (function() {
+ function RecursiveParser() {
+ this.includes = [];
+ }
+ RecursiveParser.prototype.parseFile = function(fileName) {
+ var contents, parser, ret;
+ contents = fs.readFileSync(fileName, "ascii");
+ if (!contents) {
+ this.error("Cannot read file '" + fileName + "'.");
+ return false;
+ }
+ this.includes.push(fileName);
+ parser = new BeaParser(fileName);
+ parser.parse(contents);
+ ret = this.processIncludes(parser.root);
+ return ret;
+ };
+ RecursiveParser.prototype.error = function(msg) {
+ return console.log(msg);
+ };
+ RecursiveParser.prototype.warn = function(msg, node) {
+ var fileName, line, _ref, _ref2;
+ fileName = (_ref = (node != null ? node.fileName : void 0)) != null ? _ref : "";
+ line = (_ref2 = (node != null ? node.line : void 0)) != null ? _ref2 : 0;
+ if (line > 0) {
+ line = "(" + line + ")";
+ } else {
+ line = "";
+ }
+ return console.log("" + fileName + "(" + line + "): warning: " + msg);
+ };
+ RecursiveParser.prototype.include = function(node) {
+ var fileName, _ref;
+ fileName = (_ref = node.text.match(/^@include\s+\"(.+)\"/, "")) != null ? _ref[1] : void 0;
+ if (!fileName) {
+ return this.warn("Invalid include directive", node);
+ }
+ fileName = fs.realpathSync(fileName);
+ if (_.any(this.includes, function(nf) {
+ return nf === fileName;
+ })) {
+ return this.warn("File " + fileName + " already included!", node);
+ }
+ console.log('Included file ' + fileName);
+ return this.parseFile(fileName);
+ };
+ RecursiveParser.prototype.processIncludes = function(root) {
+ var children, gr;
+ children = root.children;
+ gr = 0;
+ _.each(root.children, __bind(function(node, i) {
+ var ret, retc, _ref;
+ if (node.type() === '@include') {
+ ret = this.include(node);
+ retc = (_ref = ret != null ? ret.children : void 0) != null ? _ref : [];
+ children = children.slice(0, i + gr).concat(retc, children.slice(i + gr + 1));
+ if (retc.length) {
+ return gr = gr + retc.length - 1;
+ }
+ }
+ }, this));
+ root.children = children;
+ return root;
+ };
+ return RecursiveParser;
+ })();
+ exports.RecursiveParser = RecursiveParser;
+}).call(this);
View
59 src/bealoader.coffee
@@ -6,63 +6,8 @@ ClassConverter = require('./classconvert').ClassConverter
beautils = require('./beautils')
fs = require 'fs'
util = require 'util'
+rp = require './recursiveparser'
-
-#Bea parser which handles the 'include' directives in the nodes
-#Includes files recursively
-class RecursiveParser
-
- constructor: ->
- @includes = []
-
- parseFile: (fileName) ->
-
- contents = fs.readFileSync(fileName, "ascii")
- if not contents
- @error "Cannot read file '#{fileName}'."
- return false
-
- @includes.push fileName
-
- parser = new BeaParser fileName
- parser.parse contents
-
- ret = @processIncludes parser.root
-
- return ret
-
- error: (msg) ->
- console.log msg
- warn: (msg, node) ->
- fileName = (node?.fileName) ? ""
- line = (node?.line) ? 0
- if line > 0 then line = "(" + line + ")" else line = ""
- console.log "#{fileName}(#{line}): warning: #{msg}"
-
- include: (node) ->
- fileName = node.text.match(/^@include\s+\"(.+)\"/, "")?[1] #"#-- my syntax highlighter gets confused by regular expressions with quotes
- if not fileName then return @warn "Invalid include directive", node
-
- fileName = fs.realpathSync fileName
-
- if _.any(@includes, (nf) -> nf == fileName) then return @warn "File #{fileName} already included!", node
-
- console.log 'Included file ' + fileName
-
- return @parseFile fileName
-
- processIncludes: (root) ->
-
- children = root.children
- gr = 0
- _.each root.children, (node, i) =>
- if node.type() == '@include'
- ret = @include node
- retc = ret?.children ? []
- children = children.slice(0, i + gr).concat(retc, children.slice(i + gr + 1))
- if retc.length then gr = gr + retc.length - 1
- root.children = children
- return root
class MessageLogger
@warnings: 0
@@ -349,7 +294,7 @@ class BeaLoader extends MessageLogger
load: (fileName) ->
- parser = new RecursiveParser
+ parser = new rp.RecursiveParser
root = parser.parseFile fileName
View
0  src/debugit.coffee 100644 → 100755
File mode changed
View
61 src/recursiveparser.coffee
@@ -0,0 +1,61 @@
+fs = require 'fs'
+BeaParser = require('./beaparser').BeaParser
+_ = require 'underscore'
+
+#Bea parser which handles the 'include' directives in the nodes
+#Includes files recursively
+class RecursiveParser
+
+ constructor: ->
+ @includes = []
+
+ parseFile: (fileName) ->
+
+ contents = fs.readFileSync(fileName, "ascii")
+ if not contents
+ @error "Cannot read file '#{fileName}'."
+ return false
+
+ @includes.push fileName
+
+ parser = new BeaParser fileName
+ parser.parse contents
+
+ ret = @processIncludes parser.root
+
+ return ret
+
+ error: (msg) ->
+ console.log msg
+ warn: (msg, node) ->
+ fileName = (node?.fileName) ? ""
+ line = (node?.line) ? 0
+ if line > 0 then line = "(" + line + ")" else line = ""
+ console.log "#{fileName}(#{line}): warning: #{msg}"
+
+ include: (node) ->
+ fileName = node.text.match(/^@include\s+\"(.+)\"/, "")?[1] #"#-- my syntax highlighter gets confused by regular expressions with quotes
+ if not fileName then return @warn "Invalid include directive", node
+
+ fileName = fs.realpathSync fileName
+
+ if _.any(@includes, (nf) -> nf == fileName) then return @warn "File #{fileName} already included!", node
+
+ console.log 'Included file ' + fileName
+
+ return @parseFile fileName
+
+ processIncludes: (root) ->
+
+ children = root.children
+ gr = 0
+ _.each root.children, (node, i) =>
+ if node.type() == '@include'
+ ret = @include node
+ retc = ret?.children ? []
+ children = children.slice(0, i + gr).concat(retc, children.slice(i + gr + 1))
+ if retc.length then gr = gr + retc.length - 1
+ root.children = children
+ return root
+
+exports.RecursiveParser = RecursiveParser
View
19 src/test.coffee 100644 → 100755
@@ -1,18 +1,11 @@
-
util = require 'util'
-_ = require 'underscore'
-debugIt = require('./debugit').debugIt;
-
-a1 = [{one: "1"}, {two: "2"}, {three: "3"}]
-a2 = [{one: "1"}, {two: "2"}, {three: "3"}, {four: "4"}]
+#console.log util.inspect module
-res = _.isEqual a1, a2
-
-
-debugIt ->
-
- fs = require 'fs'
+#_ = require 'underscore'
+debugIt = require('./debugit').debugIt;
-console.log res
+exports.some = 1;
+console.log exports
+console.log module.exports
View
32 test.js
@@ -1,32 +1,8 @@
(function() {
- var a1, a2, debugIt, res, util, _;
+ var debugIt, util;
util = require('util');
- _ = require('underscore');
debugIt = require('./debugit').debugIt;
- a1 = [
- {
- one: "1"
- }, {
- two: "2"
- }, {
- three: "3"
- }
- ];
- a2 = [
- {
- one: "1"
- }, {
- two: "2"
- }, {
- three: "3"
- }, {
- four: "4"
- }
- ];
- res = _.isEqual(a1, a2);
- debugIt(function() {
- var fs;
- return fs = require('fs');
- });
- console.log(res);
+ exports.some = 1;
+ console.log(exports);
+ console.log(module.exports);
}).call(this);
View
2  typetest.js
@@ -71,7 +71,7 @@
'fullType()': 'std::vector<cv::Mat*>'
});
});
- /*
+ /*
inspectType "const Mat&"
inspectType "cv::Mat"
inspectType "cv::Mat", "cv"
Please sign in to comment.
Something went wrong with that request. Please try again.