[antlr-interest] Parsing problem...
Hill, Robert
rhill03 at eds.com
Mon Jun 27 02:57:37 PDT 2005
I have a text file that contains headings, under some headings there are
wordy declarations with parameter , but under one header there is
program code which could conceivably contain the definitions thus:
Heading One
------------------
Some decl: and a parameter
Another decl with more words : 5565 & some txt
Decl2 : "blah blah"
Heading two
-----------------
#include <stdio.h>
int main()
{
return 0;
}
Heading three with a bit more text in the heading
----------------------------------------------------------------------
Some decl: and a parameter
Another decl with more words : 5565 & some txt
Decl2 : "blah blah"
... etc ..etc
One saving grace is the declarations are followed by a colon, but how do
I collect all the code with one rule?
The next heading will always be "Heading three", so I need a rule which
goes something like
Match "heading" "two" "-------" code:get_everything_until_heading_three
Is this a task for manual look-ahead with predicates, again, I haven't
been able to find any examples, and they're still a bit confusing to me!
I've read in the manual that multiple Lexer/parser streams are suitable
for this kind of script-within-document kind of file, but I'd rather not
over complicate things just yet.
I'd like to split out the code so I can pass that onto a separate parse
phase later, as the embedded code isn't really part of the overall
document structure, it's a report that's collected into one file really.
Any ideas?
Cheers!
/2ob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050627/795a1681/attachment-0001.html
More information about the antlr-interest
mailing list