From: Shigeru C. <ch...@is...> - 2004-07-27 12:26:42
|
From: Gabriel Dos Reis <gd...@in...> Subject: Re: [Opencxx-users] parse error on valid code Date: 27 Jul 2004 13:20:13 +0200 > | So my solution when I wrote OpenC++ was to write a LL(k) parser, which > | is a LL parser that may perform backtracking. Then, since LL(k) > | parser is really powerful, a LL(k) parser does not need to maintain a > | type-name table for parsing the C++ grammar at that time. That's why > | the OpenC++ parser does not maintain a type-name table. > > Pardon my ignorance, but: Did you really handle full C++ (at the > time), or a specific subset. The reason I'm asking is that if you do > not know which names are type-names, e.g. > > f(a); > > ? The answer depends on what a parser should do. :) The OpenC++ parser accepts the statement above as a correct program but never gives the semantics of that statement since it does not know whether or not f is a type name. ClassWalker traverses on a syntax tree to maintain a type-name table and give the semantics to statements. So maybe I should say the OpenC++ parser is not a complete parser. It accepts not only correct C++ programs but also some wrong ones and produces a syntax tree. Error messages for the wrong programs are reported by ClassWalker etc (at the next stage). The grammar dealt with by the OpenC++ parser is a bit looser than the correct(?) one. But I think the border between syntax and semantics is ambiguous at least from the implementation viewpoint. Chiba |