Skip to content

Commit

Permalink
Merge pull request #1 from felixge/master
Browse files Browse the repository at this point in the history
CommonJS support / npm module
  • Loading branch information
pvdz committed Oct 25, 2011
2 parents ce6fe97 + 235db85 commit 64706e3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.un~
9 changes: 7 additions & 2 deletions Tokenizer.js
@@ -1,3 +1,8 @@
if (typeof exports !== 'undefined') {
var window = {Unicode: require('./unicodecategories').Unicode};
exports.Tokenizer = Tokenizer;
}

/*!
* Tokenizer for JavaScript / ECMAScript 5
* (c) Peter van der Zee, qfox.nl
Expand All @@ -6,7 +11,7 @@
/**
* @param {Object} inp
*/
window.Tokenizer = function(inp){
function Tokenizer(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...
// 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'},
QuantifierRequiresClosingCurly: {msg:'Quantifier curly requires to be closed'},
MissingOpeningCurly: {msg:'Encountered closing quantifier curly without seeing an opening curly'}
};
};
7 changes: 6 additions & 1 deletion ZeParser.js
@@ -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.
* Some optimizations have been applied :)
Expand All @@ -6,7 +11,7 @@
* @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 :)
*/
window.ZeParser = function(inp, tok, stack, simple){
function ZeParser(inp, tok, stack, simple){
this.input = inp;
this.tokenizer = tok;
this.stack = stack;
Expand Down
1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
exports.ZeParser = require('./ZeParser').ZeParser;
17 changes: 17 additions & 0 deletions package.json
@@ -0,0 +1,17 @@
{
"author": "Peter van der Zee (http://qfox.nl/)",
"name": "zeparser",
"description": "My JavaScript parser",
"version": "0.0.1",
"homepage": "https://github.com/qfox/ZeParser/",
"repository": {
"type": "git",
"url": "git://github.com/qfox/ZeParser.git"
},
"main": "./index",
"engines": {
"node": "*"
},
"dependencies": {},
"devDependencies": {}
}
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 64706e3

Please sign in to comment.