From: Stefan S. <se...@sy...> - 2004-07-26 23:03:16
|
Shigeru Chiba wrote: > No, my point is not an issue of OO design. It is of parsing algorithm. > > Since the parser of OpenC++ is LL(k) --- a backtracking parser ---, > the token analyzer allows the parser to look up several tokens in > advance. The parser can read several tokens and rewind back to > several tokens before. If the rewinding happens, maybe TypeResolver > must also discard some recorded type names to distinguish duplicated > type declarations from revisited type declarations. Therefore, > TypeResolver must work with not only Parser but also TokenAnalyzer. I thought that new types would only be registered to the TypeResolver when the parser can confirm that what it is looking at is indeed a type, and not an expression. That would mean that while arbitrary 'look ahead' is required, tokens wouldn't be consumed until all ambiguities are resolved for the current token sequence, and thus, all type instantiations are final. By the way: what is a TokenAnalyzer ? How is it related to Lexer and Parser ? > I'm now remembering my desing decision. GCC used a LR(1) parser, > i.e. bison parser (I don't know whether or not gcc3 still uses bison). no, gcc 3.4 has a completely (manually) rewritten parser for C++. Regards, Stefan |