facebookarchive / hack-langspec

The official Hack Language specification.
http://hacklang.org
Other
172 stars 48 forks source link

expression derivation problems in grammar #89

Open ericlippert opened 7 years ago

ericlippert commented 7 years ago

In reading through ch 22 we can see that there is no way to get from "expression" to many of the kinds of expressions. A few oddities:

"conditional-expression" is defined as

conditional-expression: logical-inc-OR-expression logical-inc-OR-expression ? expressionopt : conditional-expression

But this is the only place that "conditional-expression" appears in ch 22, so there is no path from "expression" to "conditional-expression".

In fact there is no path from "expression" to "primary-expression". We have

expression: assignment-expression

assignment-expression: lambda-expression simple-assignment-expression  -- this is what it says on the tin compound-assignment-expression -- as is this

lambda-expression: piped-expression asyncopt lambda-function-signature ==> lambda-body

piped-expression: coalesce-expression piped-expression |> coalesce-expression

But coalesce-expression is not defined in ch 22. It is defined in ch 10 as

coalesce-expression: logical-inc-OR-expression ?? expression

So (1) coalesce-expression definitely needs to be defined in ch 22, and (2) it probably needs to make progress towards primary-expression.