Browse Source

rewriting the tokenizer without regular expressions

pull/21/head
Wesley Kerfoot 11 years ago
parent
commit
9a19210c85
  1. 21
      tokenize.js

21
tokenize.js

@ -0,0 +1,21 @@
#! /usr/bin/node
// Tokenization, with no regular expressions, ala Rob Pike :)
var TokenStream = {
lookahead :
function(n) {
return this.tokstream.slice(0,n);
}
}
function MakeTokStream(tokens) {
this.tokstream = tokens;
}
MakeTokStream.prototype = TokenStream;
var input = process.argv.slice(2).reduce(function(acc, x) {return acc + " " + x}, "");
var test = new MakeTokStream(input);
console.log(test.lookahead(8));
Loading…
Cancel
Save