"Nick Sabalausky" <a@a.a> wrote in message news:iod6fn$tch$1...@digitalmars.com... > "Kagamin" <s...@here.lot> wrote in message > news:iod552$rbe$1...@digitalmars.com... >> >> As I understand, <Type> is a type, <Var> is a variable. There should be >> no problem here. > > First of all, the name <Var> up there is misleading. That only refers the > the "name of the variable" in the variable's declaration. When actually > *using* a variable, that's a <Value>, which is defined like this: > > <Value> ::= OctLiteral > | HexLiteral > | DecLiteral > | StringLiteral > | CharLiteral > | FloatLiteral > | Id '(' <Expr> ')' ! Function call > | Id '(' ')' ! Function call > | Id ! Use a variable > | '(' <Expr> ')' > > So we have a situation like this: > > <Type> ::= <Base> > <Base> ::= Id > <Value> ::= Id > > So when the parser encounters an Id, how does it know whether to reduce it > to a <Base> or a <Value>? Since they can both appear in the same place > (Ex: Immediately after a left curly-brace, such as at the start of a > function body), there's no way to tell. > > Worse, suppose it comes across this: > > x*y > > If x is a variable, then that's a multiplication. If x is a type then it's > a pointer declaration. Is it supposed to be multiplication or a > declaration? Could be either. They're both permitted in the same place. >
In other words, we basically have a form of this: <A> ::= <B> | <C> <B> ::= X <C> ::= X Can't be done. No way to tell if X is <B> or <C>.