Commit Graph

5 Commits

Author SHA1 Message Date
Nikita Popov
7a3dcc3e33 Treat namespaced names as single token
Namespace names are now lexed as single tokens of type
T_NAME_QUALIFIED, T_NAME_FULLY_QUALIFIED or T_NAME_RELATIVE.

RFC: https://wiki.php.net/rfc/namespaced_names_as_token

Closes GH-5827.
2020-07-22 12:36:05 +02:00
Rowan Tommins
55a15f32ce Improve output of tokens in Parse Errors
Currently, unexpected tokens in the parser are shown as the text
found, plus the internal token name, including the notorious
"unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)".

This commit replaces that with a more user-friendly format, with
two main types of token:

* Tokens which always represent the same text are shown like
  'unexpected token "::"' and 'expected "::"'
* Tokens which have variable text are given a user-friendly
  name, and show like 'unexpected identifier "foo"', and
  'expected identifer'.

A few tokens have special cases:

* unexpected token """ -> unexpected double-quote mark
* unexpected quoted string "'foo'" -> unexpected single-quoted
  string "foo"
* unexpected quoted string ""foo"" -> unexpected double-quoted
  string "foo"
* unexpected illegal character "_" -> unexpected character 0xNN
  (where _ is almost certainly a control character, and NN is the
   hexadecimal value of the byte)

The \ token has a special case in the implementation just to stop
bison making a mess of escaping it and it coming out as \\
2020-07-13 11:07:40 +02:00
Pierre Joye
860232e90e - MFB: make it less(er) sensible to bison version 2009-03-17 16:03:25 +00:00
Stanislav Malyshev
636b2c9a6f MF5: Merge namespaces changes 2008-12-04 20:12:30 +00:00
Dmitry Stogov
31f6f1583e Fixed bug #43344 (Wrong error message for undefined namespace constant) 2007-12-07 17:12:22 +00:00