On Mon, Mar 31, 2008 at 2:43 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > Chas. Owens wrote: > > > > 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 snip
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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/