Related articles |
---|
what are parsing generators? Drum.Sefex@btinternet.com (Paul Drummond) (2000-10-31) |
Re: what are parsing generators? ollanes@pobox.com (Orlando Llanes) (2000-11-01) |
Re: what are parsing generators? Drum.Sefex@btinternet.com (Paul Drummond) (2000-11-05) |
From: | "Paul Drummond" <Drum.Sefex@btinternet.com> |
Newsgroups: | comp.compilers |
Date: | 5 Nov 2000 20:54:50 -0500 |
Organization: | BT Internet |
References: | 00-10-240 00-11-008 |
Keywords: | parse |
"Orlando Llanes" <ollanes@pobox.com> wrote:
<<SNIP>>
>
> The following could be a way to accomplish your goal:
>
> A) Open source code file for input
>
> B) Open temporary file for output
>
> C) Read a line of text from input
>
> D) Scan and parse the line of text
>
> Ea) If the line starts with #define it's a macro Eb) If the line starts
> with "typedef" it's a user type declaration then process it and make
> note of its type name
>
> Fa) If the line starts with the keyword "class" then write comments to
> the temporary file Fb) If the line starts with a user defined type or
> "int", "char", "void",
> "struct"(?), etc and if the line contains "(" it's a function then write
> comments to the temporary file Fc) If the line starts with a user
> defined type or "int", "char", "void",
> "struct", etc then it's a variable, write comments to the temporary file
>
> G) Write the line to the temporary file
>
> H) Repeat C through G until the input file reaches EOF (End Of File)
>
> I) Close and delete the input file
>
> J) Close and rename the temporary file to the input file's name
>
Yeah, I have already made a very simple "Comment Insertion" tool that
more or less followed those rules. However, at step D you say "do
scan and parse". I didn't do any parsing as such. I just read a
line, scanned it to produce tokens then used the other rules you state
above. I didn't use a parse tree, etc. Your rules from E to F can be
done without a parse tree can't they? Also, in order to parse you
need a grammar (I think!), so what grammar would you use for the
above?
Return to the
comp.compilers page.
Search the
comp.compilers archives again.