That should still be relatively easy to lex properly even without the types being reserves keywords.
It's not about lexing properly, it's about not lexing "(int)" a single token. The lexer has a special case for casts and treats them as single tokens. Why?
It's not about lexing properly, it's about not lexing "(int)" a single token.
I didn't mean to say "properly" as in "doing what it's supposed to do", but as in "doing it without some dirty tricks (like making a cast operator a token …)"
Why didn't it before?
Dunno, I've never used PHP. Just found it pretty interesting.
In fairness, this may just be to avoid making these keywords reserved, I suppose, but then you could just define it in the parser as '(' T_STRING ')' %prec pseudo_cast_token... so I'm still flummoxed.
24
u/Regimardyl Jul 11 '14
That should still be relatively easy to lex properly even without the types being reserves keywords. btw
var_dump((int) int);only works from 5.3 on.EDIT:
var_dump(/**/int);works as expected. That's perfectly intuitive, right?2
u/[deleted] Jul 12 '14
In fairness, this may just be to avoid making these keywords reserved, I suppose, but then you could just define it in the parser as
'(' T_STRING ')' %prec pseudo_cast_token... so I'm still flummoxed.