Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not parse using stream? #4

Open
siygle opened this issue Jul 11, 2013 · 0 comments
Open

could not parse using stream? #4

siygle opened this issue Jul 11, 2013 · 0 comments

Comments

@siygle
Copy link

siygle commented Jul 11, 2013

I write a simple example to use stream to read the file content then pipe to tokenizer, but it will return could not parse error, did I do it wrong? thanks

error

SyntaxError: could not parse "dkfjdkfjd\ndfkdjf\n\nsdsjkdsjdkjskwww\n\n2ueuwie1212\n\nklekwl<b>rest</b>skdjwk\n"
    at Tokenizer._tokenize (/Users/ferrari/test/node_modules/tokenizer/lib/Tokenizer.js:75:13)
    at /Users/ferrari/test/node_modules/tokenizer/lib/Tokenizer.js:30:12
    at process._tickCallback (node.js:415:13)

main.js

var Tokenizer = require('tokenizer');
var t = new Tokenizer();
var fs = require('fs');

t.on('token', function(token, type) {
  console.log('%s - %s', token, type);
});
t.addRule(/^dk$/, 'test');

fs.createReadStream('./test.txt').pipe(t);

test.txt

dkfjdkfjd
dfkdjf

sdsjkdsjdkjskwww

2ueuwie1212

klekwl<b>rest</b>skdjwk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant