Questions re keywords
[email protected] (Rex Jaeschke)
| Newsgroups | php.standards |
|---|---|
| Message-ID | <A8BBDA435C3D034A80AA96D62A7478C437001D36@PRN-MBX02-2.TheFacebook.com> |
As part of my work at Facebook in updating the formal spec for V7, I was working on the new intrinsic, assert, which led me to the following questions: 1. Should `assert` be added to the list of keywords? 2. If so, which other intrinsic names should be listed as keywords? (Right now, only `echo`, `list`, and `print` are listed.) Stas pointed me to https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L100 where I see %token T_ARRAY "array (T_ARRAY)" %token T_ECHO "echo (T_ECHO)" %token T_EMPTY "empty (T_EMPTY)" %token T_EVAL "eval (T_EVAL)" %token T_EXIT "exit (T_EXIT)" %token T_ISSET "isset (T_ISSET)" %token T_LIST "list (T_LIST)" %token T_PRINT "print (T_PRINT)" %token T_UNSET "unset (T_UNSET)" From that it seems to me they should all be listed as keywords. 3. If `exit` is a keyword, shouldn't `die` also be one? 4. Based on the following extract from the Zend parser grammar file, %token T_YIELD_FROM "yield from (T_YIELD_FROM)", it seems to me that `yield from` is treated as a keyword containing whitespace, correct? While unusual, this not new to me. (When I produced the Ecma spec for "C++ with extensions for .NET", we added a number of such names in order to avoid reserving new keywords.) In that spec we wrote such keywords as xxxx$xxxx, where $ was actually some odd Unicode character that in Word rendered as ░. Then we said, "The symbol ░ is used in the grammar to signify that white-space appears within the keyword. Any white space that appears in the program text after translation phase 1 is permitted in the position signified by the ░ symbol. It is unspecified whether white space generated by comments, documentation comments, and macro invocations is permitted in the position signified by the ░ symbol. Following translation phase 4, a keyword with ░ will be a single token." It seems to me that we need to say just what kind of whitespace can separate the two parts, and whether /*...*/ is allowed as a separator. Rex