Goldie Parsing System v0.4 Released - Now for D2

Nick Sabalausky a at a.a
Sat Apr 16 15:50:17 PDT 2011


"Nick Sabalausky" <a at a.a> wrote in message 
news:iod6fn$tch$1 at digitalmars.com...
> "Kagamin" <spam at here.lot> wrote in message 
> news:iod552$rbe$1 at 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>.




More information about the Digitalmars-d-announce mailing list