Skip to content

Commit

Permalink
Add CommonJS support
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Oct 25, 2011
1 parent ce6fe97 commit 45a1c90
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Tokenizer.js
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,8 @@
if (typeof exports !== 'undefined') {
var window = {Unicode: require('./unicodecategories').Unicode};
exports.Tokenizer = Tokenizer;
}

/*! /*!
* Tokenizer for JavaScript / ECMAScript 5 * Tokenizer for JavaScript / ECMAScript 5
* (c) Peter van der Zee, qfox.nl * (c) Peter van der Zee, qfox.nl
Expand All @@ -6,7 +11,7 @@
/** /**
* @param {Object} inp * @param {Object} inp
*/ */
window.Tokenizer = function(inp){ function Tokenizer(inp){
this.inp = inp||''; this.inp = inp||'';
// replace all other line terminators with \n (leave \r\n in tact though). we should probably remove the shadowInp when finished... // replace all other line terminators with \n (leave \r\n in tact though). we should probably remove the shadowInp when finished...
// only replace \r if it is not followed by a \n else \r\n would become \n\n causing a double newline where it is just a single // only replace \r if it is not followed by a \n else \r\n would become \n\n causing a double newline where it is just a single
Expand Down Expand Up @@ -1052,4 +1057,4 @@ Tokenizer.Error = {
QuantifierRequiresNumber: {msg:'Quantifier curly requires at least one digit before the comma'}, QuantifierRequiresNumber: {msg:'Quantifier curly requires at least one digit before the comma'},
QuantifierRequiresClosingCurly: {msg:'Quantifier curly requires to be closed'}, QuantifierRequiresClosingCurly: {msg:'Quantifier curly requires to be closed'},
MissingOpeningCurly: {msg:'Encountered closing quantifier curly without seeing an opening curly'} MissingOpeningCurly: {msg:'Encountered closing quantifier curly without seeing an opening curly'}
}; };
7 changes: 6 additions & 1 deletion ZeParser.js
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,8 @@
if (typeof exports !== 'undefined') {
var Tokenizer = require('./tokenizer').Tokenizer;
exports.ZeParser = ZeParser;
}

/** /**
* This is my js Parser: Ze. It's actually the post-dev pre-cleanup version. Clearly. * This is my js Parser: Ze. It's actually the post-dev pre-cleanup version. Clearly.
* Some optimizations have been applied :) * Some optimizations have been applied :)
Expand All @@ -6,7 +11,7 @@
* @param {Tokenizer} tok * @param {Tokenizer} tok
* @param {Array} stack The tokens will be put in this array. If you're looking for the AST, this would be it :) * @param {Array} stack The tokens will be put in this array. If you're looking for the AST, this would be it :)
*/ */
window.ZeParser = function(inp, tok, stack, simple){ function ZeParser(inp, tok, stack, simple){
this.input = inp; this.input = inp;
this.tokenizer = tok; this.tokenizer = tok;
this.stack = stack; this.stack = stack;
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
exports.ZeParser = require('./ZeParser').ZeParser;
6 changes: 4 additions & 2 deletions unicodecategories.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 45a1c90

Please sign in to comment.