Re: parser using perl
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Mon, 31 Mar 2008 15:21:21 -0400
On Mon, Mar 31, 2008 at 2:43 PM, Rob Dixon <rob.dixon@xxxxxxx> wrote:
Chas. Owens wrote:snip
>
> In general, it doesn't matter if you want to work with a small piece
> of a language or the whole language, you still need to implement a
> parser for the whole language. You can get an eighty or ninety
> percent solution without a full parser, but there will always be
> problems.
That's not true at all. A file containing
int i;
is a valid C file. If the input expected by the OP contains a subset of
the C syntax then it can be parsed as such. C is s subset of C++. Does
that mean that everybody suddenly needs a C++ compiler to compile their
C programs? I think not.
Rob
Let me state my position more clearly: If you are dealing with a
subset of the language then you can use the same subset of the
grammar; however, if you are only looking for a subset of the language
(say switch statements) in files that use the full language, then you
need the full grammar to be able to accurately identify the parts you
are looking for. In your example, where the input is expected to be
constrained to just variable declarations, you would only need a
grammar that covered the declaration of variables. Unfortunately, the
expected input is rarely that simple. Even simple C programs use
large portions of the language (and they don't even necessarily use
the same portions of the language).
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
.
- References:
- parser using perl
- From: Sharan Basappa
- Re: parser using perl
- From: Chas. Owens
- Re: parser using perl
- From: Rob Dixon
- parser using perl
- Prev by Date: Re: parser using perl
- Next by Date: Re: Uninitialized value in pattern match
- Previous by thread: Re: parser using perl
- Index(es):
Relevant Pages
|
|