Tim Matthews wrote: > Ellery Newcomer wrote: > >> >> To restate my question, if I'm a parser and I see >> >> Identifier ( Identifier ) ; >> >> which do I interpret it as? >> >> Type ( NewSymbol ) ; >> FunctionName ( Argument ) ; >> > > > After some incremental parsing iterations you should be able to > gradually resolve dependencies for each expression. If it's not > ambiguous on what the source is trying to describe and all its > dependencies are resolved then you add the new types that it may be > declaring to a collection of parsed types. Repeat until everything can > be passed and eventually you should know exactly what the first ID is > (type, func etc). IIRC opCall can not be declared static.
Remember back in D1 land when we didn't have struct constructors? > > Sorry if I am completely missing the point but this doesn't seem complex > (in a problem solving sense but the code writing may be tedious) Yeah, you're missing the point. The point is the D Language is billed as one whose lexer is completely independent of its parser, which is completely independent of its semantic analysis. The parser must be able to decide all of these without any help from semantic. Anything less is either failure or just plain wrong. If you'll have another gander at my original example, you'll see that's exactly what DMD does. The compiler decides that T(t) is an expression and t(i[])(i[]) is a declaration, and if they don't resolve, then by golly that's just too bad. It's an error. Game over. It's mildly restrictive from the user's perspective, but from the compiler writer's perspective, it is infinitely better than mixing semantic and syntactic analysis. And anyways, T(t) can be rewritten the normal way, and t(i[])(i[]) can be surrounded with parentheses to force it to be an expression. But question remains: how does the compiler decide this? I'm hoping for some simple rule like if it is a C-style declaration, then it must have a suffix or prefix for each level. It seems to be behaving something like this. You are right, though, none of this is complex, just tedious. Reading the compiler's source code especially, though it sounds like I'm not going to get answers any other way.
