<br><br><div class="gmail_quote">2009/11/9 Ivanyi Peter <span dir="ltr"><<a href="mailto:pivanyi@freemail.hu">pivanyi@freemail.hu</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
> But I recently made a simple quick-and-dirty text parser tool:<br>
> <a href="http://planet.plt-scheme.org/package-source/orseau/lazy-doc.plt" target="_blank">http://planet.plt-scheme.org/package-source/orseau/lazy-doc.plt</a><br>
> /1/6/planet-docs/manual/simple-parser.html<br>
<br>
</div>Thanks, this seems to work.<br>
Now I do not understand one thing. Maybe this is not Scheme<br>
related, but from the following code I would expect:<br>
"\nsomething\n{#[#aa,#bb#]\n}\n"<br>
but I get:<br>
"\nsomething\n{\n#[\n#aa,#bb\n#]\n}\n"<br>
<br>
I thought the start-keyword would match zero or many new-line<br>
AND one or many spaces. What do I do wrong?<br></blockquote><div><br>This is my bad.<br>For some reason, I had chosen to cut the text into lines (so that reading files line by line would have the same behavior as reading it by chunks) and to separate the end-of-lines from the rest of the text, so in fact:<br>
"<br>something<br>{<br> [<br> aa, bb<br> ]<br>}<br>"<br>is turned into :<br>'("\n" "something" "\n" "{" "\n" "[" "\n" " aa, bb" "\n" "]" "\n" "}" "\n")<br>
which is parsed chunk by chunk.<br><br>This also addresses a speed issue, because with big parsers, multiple regexps in parallel can be quite greedy, especially on long text files if the text is not split into lines.<br>
<br>
I should at least document that.<br><br>Let me know if this makes things difficult for you, I'll try to find a workaround. Though for my own purposes, this behavior has not been much of a problem.<br><br>Laurent<br> </div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Thanks,<br>
<br>
Peter Ivanyi<br>
<br>
----------------------------------------------------------<br>
#lang scheme<br>
<br>
(require (planet orseau/lazy-doc:1:6/simple-parser))<br>
<br>
(define start-keyword "\n* +")<br>
<br>
(let ([block-parser (new-parser #:phase 'block-keywords)])<br>
(add-items<br>
block-parser<br>
('block-keywords (start-keyword "#"))<br>
)<br>
(parse-text block-parser "<br>
something<br>
{<br>
[<br>
aa, bb<br>
]<br>
}<br>
")<br>
)<br>
<br>
</blockquote></div><br>