Make ZeroOrMore non-greedy to make it nestable without exponential behavior.

This commit is contained in:
Ian Gulliver
2014-06-29 17:39:24 -07:00
parent 2f03f4d9ff
commit 78cc56dc46
3 changed files with 13 additions and 12 deletions

View File

@@ -8,7 +8,7 @@ QUnit.test('Simple', function(assert) {
var iterable = context.rules['wikidoc'].match(context);
assert.equal(iterable.next().value.nodes[0].innerHTML,
'<h3>Heading</h3>This is a wiki doc.\n' +
'How about some <b>bold and &lt;i&gt;bold italic&lt;/i&gt;</b>.\n' +
"How about some <b>bold and ''bold italic</b>''.\n" +
'I would also love some nowiki &lt;b&gt;foo&lt;/b&gt;');
});
@@ -16,7 +16,8 @@ QUnit.test('Simple', function(assert) {
QUnit.test('ZeroOrMore', function(assert) {
assert.expect(1);
var rules = {
'test': rr.Node('test', rr.ZeroOrMore(rr.MultiLineText()))
'test': rr.Node('test',
rr.Sequence(rr.ZeroOrMore(rr.MultiLineText()), rr.EndOfText()))
};
var context = new rr.Context(rules, 'foobar');
var iterable = context.rules['test'].match(context);