The token declaration tells us that there's a token type named T_VARIABLE
that is associated with values of type ast
and should be referred to as "variable (T_VARIABLE)" in error messages. It tells us nothing about which characters a T_VARIABLE
token may consist of - nothing in the Bison file will tell us that.
That's because a Bison parser does not interact with characters - it interacts with tokens produced by the lexer/scanner. The parser simply consumes the tokens generated by the scanner. It does not need to know which character sequence are translated to which tokens - that's the scanner's job.
So if you want to see the dollar sign, you need to look into the scanner (zend_language_scanner.l) where you'll find (among others) this:
<ST_IN_SCRIPTING,ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE,ST_VAR_OFFSET>"$"{LABEL} {
RETURN_TOKEN_WITH_STR(T_VARIABLE, 1);
}
This tells us that inside regular PHP sections, double quotes, heredocs, back quotes and brackets (i.e. basically anywhere except outside of the <?php
tags), a dollar followed by a label (which is defined as an arbitrary non-empty sequence of letters, numbers and underscores that doesn't start with a number) produces a T_VARIABLE
token.