mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
put add terminal token inside tokenize method (will pull it out again for streaming interface)
This commit is contained in:
parent
6103646ec8
commit
8fbf36e63e
Notes:
Gabriel Wicke
2012-02-27 16:40:01 +00:00
|
@ -8,7 +8,6 @@
|
|||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
$ = require('jquery'),
|
||||
PegTokenizer = require('./mediawiki.tokenizer.peg.js').PegTokenizer,
|
||||
TokenTransformDispatcher = require('./mediawiki.TokenTransformDispatcher.js').TokenTransformDispatcher,
|
||||
DOMPostProcessor = require('./mediawiki.DOMPostProcessor.js').DOMPostProcessor,
|
||||
|
|
|
@ -32,6 +32,12 @@ PegTokenizer.prototype.tokenize = function( text ) {
|
|||
err = e;
|
||||
console.trace();
|
||||
} finally {
|
||||
|
||||
// Append the end (for obvious reasons this should not
|
||||
// be part of a stream, only when tokenizing complete
|
||||
// texts)
|
||||
out.push({type: 'END'});
|
||||
|
||||
return {tokens: out, err: err};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,12 @@
|
|||
* @param {String} text
|
||||
*/
|
||||
function getOutput( parser, input ) {
|
||||
var res = parser.wikiTokenizer.tokenize(input + "\n");
|
||||
var res = parser.wikiTokenizer.tokenize(input);
|
||||
if (res.err) {
|
||||
console.log('PARSE FAIL', res.err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Append the end
|
||||
res.tokens.push({type: 'END'});
|
||||
|
||||
parser.tokenDispatcher.transformTokens( res.tokens );
|
||||
|
||||
return parser.getWikiDom();
|
||||
|
|
|
@ -399,9 +399,6 @@ ParserTests.prototype.processTest = function (item, pThingy) {
|
|||
// TokenTransformDispatcher calls buildTree() and checkResult() with the
|
||||
// transformed tokens.
|
||||
|
||||
// Append the end
|
||||
res.tokens.push({type: 'END'});
|
||||
|
||||
//console.log(JSON.stringify(res.tokens, null, 2));
|
||||
|
||||
pThingy.tokenDispatcher.transformTokens( res.tokens );
|
||||
|
|
Loading…
Reference in a new issue