Permalink
Browse files

merged rewriter into lexer

  • Loading branch information...
1 parent 84e732b commit 34e0c12bbcbeddf694adf5b1c542bf4fa70decf8 @satyr committed Aug 29, 2011
Showing with 728 additions and 746 deletions.
  1. +2 −3 Cokefile
  2. +8 −7 lib/coco.js
  3. +432 −7 lib/lexer.js
  4. +0 −433 lib/rewriter.js
  5. +10 −7 src/coco.co
  6. +1 −1 src/index.html
  7. +275 −14 src/lexer.co
  8. +0 −274 src/rewriter.co
View
@@ -81,7 +81,7 @@ task \build:browser 'build extras/' ->
slobber \extras/mode-coco.raw.js js
slobber \extras/mode-coco.js minify js
co = ''
- for name of <[ rewriter lexer ast coco ]>
+ for name of <[ lexer ast coco ]>
code = slurp("src/#name.co")replace /\n/g '\n '
co += "let exports = require'./#name' = {}\n#code\n"
slobber \extras/coco.raw.js js = """
@@ -106,8 +106,7 @@ task \build:browser 'build extras/' ->
invoke \test:browser
-coreSources = ->
- "src/#src.co" for src of <[ coco grammar lexer ast rewriter ]>
+coreSources = -> "src/#src.co" for src of <[ coco grammar lexer ast ]>
task \bench 'quick benchmark of compilation time' ->
Coco = require \./lib/coco
View
@@ -1,9 +1,9 @@
-var lex, parser, __import = function(obj, src){
+var lexer, parser, __import = function(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}, __importAll = function(obj, src){ for (var key in src) obj[key] = src[key]; return obj };
-lex = require('./lexer').lex;
+lexer = require('./lexer');
parser = require('./parser').parser;
parser.yy = require('./ast');
parser.lexer = {
@@ -20,11 +20,11 @@ parser.lexer = {
return '';
}
};
-exports.VERSION = '0.6.2';
+exports.VERSION = '0.6.3b';
exports.compile = function(code, options){
var that;
try {
- return parser.parse(lex(code)).compileRoot(options);
+ return parser.parse(lexer.lex(code)).compileRoot(options);
} catch (e) {
if (that = options != null ? options.filename : void 8) {
e.message += "\nat " + that;
@@ -33,18 +33,19 @@ exports.compile = function(code, options){
}
};
exports.ast = function(it){
- return parser.parse(typeof it === 'string' ? lex(it) : it);
+ return parser.parse(typeof it === 'string' ? lexer.lex(it) : it);
};
-exports.tokens = lex;
+exports.tokens = lexer.lex;
exports.lex = function(it){
- return lex(it, {
+ return lexer.lex(it, {
raw: true
});
};
exports.run = function(code, options){
var _ref;
return Function(exports.compile(code, (_ref = {}, __import(_ref, options), _ref.bare = true, _ref)))();
};
+exports.tokens.rewrite = lexer.rewrite;
__importAll(exports.ast, parser.yy);
if (require.extensions) {
require('./node')(exports);
Oops, something went wrong.

0 comments on commit 34e0c12

Please sign in to comment.