quakejs-files
Advanced tools
Comparing version 0.0.2 to 0.0.3
var Tokenizer = function (src) { | ||
// Strip out comments | ||
src = src.replace(/\/\/.*$/mg, ''); // C++ style (//...) | ||
src = src.replace(/\/\*[^*\/]*\*\//mg, ''); // C style (/*...*/) (Do the shaders even use these?) | ||
// strip out comments | ||
src = src.replace(/\/\/.*$/mg, ''); // strip single line comments | ||
src = src.replace(/\/\*[\s\S]*?\*\//mg, ''); // strip multi-line comments | ||
// Split everything by whitespace, grouping quoted | ||
// sections together. | ||
// split everything by whitespace, grouping quoted sections together | ||
this.tokens = []; | ||
@@ -20,8 +19,13 @@ | ||
Tokenizer.prototype.EOF = function() { | ||
if (this.tokens === null) { return true; } | ||
if (this.tokens === null) { | ||
return true; | ||
} | ||
var token = this.tokens[this.offset]; | ||
while(token === '' && this.offset < this.tokens.length) { | ||
while (token === '' && this.offset < this.tokens.length) { | ||
this.offset++; | ||
token = this.tokens[this.offset]; | ||
} | ||
return this.offset >= this.tokens.length; | ||
@@ -31,7 +35,12 @@ }; | ||
Tokenizer.prototype.next = function() { | ||
if (this.tokens === null) { return; } | ||
if (this.tokens === null) { | ||
return; | ||
} | ||
var token = ''; | ||
while(token === '' && this.offset < this.tokens.length) { | ||
while (token === '' && this.offset < this.tokens.length) { | ||
token = this.tokens[this.offset++]; | ||
} | ||
return token; | ||
@@ -41,10 +50,15 @@ }; | ||
Tokenizer.prototype.prev = function() { | ||
if (this.tokens === null) { return; } | ||
if (this.tokens === null) { | ||
return; | ||
} | ||
var token = ''; | ||
while(token === '' && this.offset >= 0) { | ||
while (token === '' && this.offset >= 0) { | ||
token = this.tokens[this.offset--]; | ||
} | ||
return token; | ||
}; | ||
module.exports = Tokenizer; | ||
module.exports = Tokenizer; |
{ | ||
"name": "quakejs-files", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Parse quake3 `.bsp`, `.md3`, `.shader` and `.skin` files into JavaScript friendly objects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47829
1275