1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
|
%{
#include "strmake.h"
#define START_VARIABLE 1001
#define START_WORD 2001
#define START_SHARP 3001
#define START_YACC 4001
#define IS_RESERVED_WORD(a) ((a) >= START_WORD)
#define IS_RESERVED_VARIABLE(a) ((a) >= START_VARIABLE && (a) < START_WORD)
#define IS_RESERVED_SHARP(a) ((a) >= START_SHARP && (a) < START_YACC)
#define IS_RESERVED_YACC(a) ((a) >= START_YACC)
#define PHP___CLASS__ 2001
#define PHP___DIR__ 2002
#define PHP___FILE__ 2003
#define PHP___FUNCTION__ 2004
#define PHP___LINE__ 2005
#define PHP___METHOD__ 2006
#define PHP___NAMESPACE__ 2007
#define PHP___TRAIT__ 2008
#define PHP_ABSTRACT 2009
#define PHP_AND 2010
#define PHP_ARRAY 2011
#define PHP_AS 2012
#define PHP_BREAK 2013
#define PHP_CALLABLE 2014
#define PHP_CASE 2015
#define PHP_CATCH 2016
#define PHP_CFUNCTION 2017
#define PHP_CLASS 2018
#define PHP_CLONE 2019
#define PHP_CONST 2020
#define PHP_CONTINUE 2021
#define PHP_DECLARE 2022
#define PHP_DEFAULT 2023
#define PHP_DEFINE 2024
#define PHP_DIE 2025
#define PHP_DO 2026
#define PHP_EACH 2027
#define PHP_ECHO 2028
#define PHP_ELSE 2029
#define PHP_ELSEIF 2030
#define PHP_EMPTY 2031
#define PHP_ENDDECLARE 2032
#define PHP_ENDFOR 2033
#define PHP_ENDFOREACH 2034
#define PHP_ENDIF 2035
#define PHP_ENDSWITCH 2036
#define PHP_ENDWHILE 2037
#define PHP_EVAL 2038
#define PHP_EXIT 2039
#define PHP_EXTENDS 2040
#define PHP_FALSE 2041
#define PHP_FINAL 2042
#define PHP_FINALLY 2043
#define PHP_FOR 2044
#define PHP_FOREACH 2045
#define PHP_FUNCTION 2046
#define PHP_GLOBAL 2047
#define PHP_GOTO 2048
#define PHP_IF 2049
#define PHP_IMPLEMENTS 2050
#define PHP_INCLUDE 2051
#define PHP_INCLUDE_ONCE 2052
#define PHP_INSTANCEOF 2053
#define PHP_INSTEADOF 2054
#define PHP_INTERFACE 2055
#define PHP_ISSET 2056
#define PHP_LIST 2057
#define PHP_NAMESPACE 2058
#define PHP_NEW 2059
#define PHP_OLD_FUNCTION 2060
#define PHP_OR 2061
#define PHP_PRINT 2062
#define PHP_PRIVATE 2063
#define PHP_PROTECTED 2064
#define PHP_PUBLIC 2065
#define PHP_REQUIRE 2066
#define PHP_REQUIRE_ONCE 2067
#define PHP_RETURN 2068
#define PHP_STATIC 2069
#define PHP_SWITCH 2070
#define PHP_THROW 2071
#define PHP_TRAIT 2072
#define PHP_TRY 2073
#define PHP_TRUE 2074
#define PHP_UNSET 2075
#define PHP_USE 2076
#define PHP_VAR 2077
#define PHP_WHILE 2078
#define PHP_XOR 2079
#define PHP_YIELD 2080
#define PHP_GLOBALS 1001
#define PHP_HTTP_COOKIE_VARS 1002
#define PHP_HTTP_ENV_VARS 1003
#define PHP_HTTP_GET_VARS 1004
#define PHP_HTTP_POST_FILES 1005
#define PHP_HTTP_POST_VARS 1006
#define PHP_HTTP_SERVER_VARS 1007
#define PHP_HTTP_SESSION_VARS 1008
#define PHP__COOKIE 1009
#define PHP__ENV 1010
#define PHP__FILES 1011
#define PHP__GET 1012
#define PHP__POST 1013
#define PHP__REQUEST 1014
#define PHP__SERVER 1015
#define PHP__SESSION 1016
%}
struct keyword { char *name; int token; }
%%
__CLASS__, PHP___CLASS__
__DIR__, PHP___DIR__
__FILE__, PHP___FILE__
__FUNCTION__, PHP___FUNCTION__
__LINE__, PHP___LINE__
__METHOD__, PHP___METHOD__
__NAMESPACE__, PHP___NAMESPACE__
__TRAIT__, PHP___TRAIT__
abstract, PHP_ABSTRACT
ABSTRACT, PHP_ABSTRACT
Abstract, PHP_ABSTRACT
and, PHP_AND
AND, PHP_AND
And, PHP_AND
array, PHP_ARRAY
ARRAY, PHP_ARRAY
Array, PHP_ARRAY
as, PHP_AS
AS, PHP_AS
As, PHP_AS
break, PHP_BREAK
BREAK, PHP_BREAK
Break, PHP_BREAK
callable, PHP_CALLABLE
CALLABLE, PHP_CALLABLE
Callable, PHP_CALLABLE
case, PHP_CASE
CASE, PHP_CASE
Case, PHP_CASE
catch, PHP_CATCH
CATCH, PHP_CATCH
Catch, PHP_CATCH
cfunction, PHP_CFUNCTION
CFUNCTION, PHP_CFUNCTION
Cfunction, PHP_CFUNCTION
CFunction, PHP_CFUNCTION
class, PHP_CLASS
CLASS, PHP_CLASS
Class, PHP_CLASS
clone, PHP_CLONE
CLONE, PHP_CLONE
Clone, PHP_CLONE
const, PHP_CONST
CONST, PHP_CONST
Const, PHP_CONST
continue, PHP_CONTINUE
CONTINUE, PHP_CONTINUE
Continue, PHP_CONTINUE
declare, PHP_DECLARE
DECLARE, PHP_DECLARE
Declare, PHP_DECLARE
default, PHP_DEFAULT
DEFAULT, PHP_DEFAULT
Default, PHP_DEFAULT
define, PHP_DEFINE
DEFINE, PHP_DEFINE
Define, PHP_DEFINE
die, PHP_DIE
DIE, PHP_DIE
Die, PHP_DIE
do, PHP_DO
DO, PHP_DO
Do, PHP_DO
each, PHP_EACH
EACH, PHP_EACH
Each, PHP_EACH
echo, PHP_ECHO
ECHO, PHP_ECHO
Echo, PHP_ECHO
else, PHP_ELSE
ELSE, PHP_ELSE
Else, PHP_ELSE
elseif, PHP_ELSEIF
ELSEIF, PHP_ELSEIF
Elseif, PHP_ELSEIF
ElseIf, PHP_ELSEIF
empty, PHP_EMPTY
EMPTY, PHP_EMPTY
Empty, PHP_EMPTY
enddeclare, PHP_ENDDECLARE
ENDDECLARE, PHP_ENDDECLARE
Enddeclare, PHP_ENDDECLARE
EndDeclare, PHP_ENDDECLARE
endfor, PHP_ENDFOR
ENDFOR, PHP_ENDFOR
Endfor, PHP_ENDFOR
EndFor, PHP_ENDFOR
endforeach, PHP_ENDFOREACH
ENDFOREACH, PHP_ENDFOREACH
Endforeach, PHP_ENDFOREACH
EndForeach, PHP_ENDFOREACH
endif, PHP_ENDIF
ENDIF, PHP_ENDIF
Endif, PHP_ENDIF
EndIf, PHP_ENDIF
endswitch, PHP_ENDSWITCH
ENDSWITCH, PHP_ENDSWITCH
Endswitch, PHP_ENDSWITCH
EndSwitch, PHP_ENDSWITCH
endwhile, PHP_ENDWHILE
ENDWHILE, PHP_ENDWHILE
Endwhile, PHP_ENDWHILE
EndWhile, PHP_ENDWHILE
eval, PHP_EVAL
EVAL, PHP_EVAL
Eval, PHP_EVAL
exit, PHP_EXIT
EXIT, PHP_EXIT
Exit, PHP_EXIT
extends, PHP_EXTENDS
EXTENDS, PHP_EXTENDS
Extends, PHP_EXTENDS
false, PHP_FALSE
FALSE, PHP_FALSE
False, PHP_FALSE
final, PHP_FINAL
FINAL, PHP_FINAL
Final, PHP_FINAL
finally, PHP_FINALLY
FINALLY, PHP_FINALLY
Finally, PHP_FINALLY
for, PHP_FOR
FOR, PHP_FOR
For, PHP_FOR
foreach, PHP_FOREACH
FOREACH, PHP_FOREACH
Foreach, PHP_FOREACH
ForEach, PHP_FOREACH
function, PHP_FUNCTION
FUNCTION, PHP_FUNCTION
Function, PHP_FUNCTION
global, PHP_GLOBAL
GLOBAL, PHP_GLOBAL
Global, PHP_GLOBAL
goto, PHP_GOTO
GOTO, PHP_GOTO
Goto, PHP_GOTO
if, PHP_IF
IF, PHP_IF
If, PHP_IF
implements, PHP_IMPLEMENTS
IMPLEMENTS, PHP_IMPLEMENTS
Implements, PHP_IMPLEMENTS
include, PHP_INCLUDE
INCLUDE, PHP_INCLUDE
Include, PHP_INCLUDE
include_once, PHP_INCLUDE_ONCE
INCLUDE_ONCE, PHP_INCLUDE_ONCE
Include_once, PHP_INCLUDE_ONCE
Include_Once, PHP_INCLUDE_ONCE
instanceof, PHP_INSTANCEOF
INSTANCEOF, PHP_INSTANCEOF
Instanceof, PHP_INSTANCEOF
InstanceOf, PHP_INSTANCEOF
insteadof, PHP_INSTEADOF
INSTEADOF, PHP_INSTEADOF
Insteadof, PHP_INSTEADOF
InsteadOf, PHP_INSTEADOF
interface, PHP_INTERFACE
INTERFACE, PHP_INTERFACE
Interface, PHP_INTERFACE
isset, PHP_ISSET
ISSET, PHP_ISSET
Isset, PHP_ISSET
list, PHP_LIST
LIST, PHP_LIST
List, PHP_LIST
namespace, PHP_NAMESPACE
NAMESPACE, PHP_NAMESPACE
Namespace, PHP_NAMESPACE
new, PHP_NEW
NEW, PHP_NEW
New, PHP_NEW
old_function, PHP_OLD_FUNCTION
OLD_FUNCTION, PHP_OLD_FUNCTION
Old_function, PHP_OLD_FUNCTION
Old_Function, PHP_OLD_FUNCTION
or, PHP_OR
OR, PHP_OR
Or, PHP_OR
print, PHP_PRINT
PRINT, PHP_PRINT
Print, PHP_PRINT
private, PHP_PRIVATE
PRIVATE, PHP_PRIVATE
Private, PHP_PRIVATE
protected, PHP_PROTECTED
PROTECTED, PHP_PROTECTED
Protected, PHP_PROTECTED
public, PHP_PUBLIC
PUBLIC, PHP_PUBLIC
Public, PHP_PUBLIC
require, PHP_REQUIRE
REQUIRE, PHP_REQUIRE
Require, PHP_REQUIRE
require_once, PHP_REQUIRE_ONCE
REQUIRE_ONCE, PHP_REQUIRE_ONCE
Require_once, PHP_REQUIRE_ONCE
Require_Once, PHP_REQUIRE_ONCE
return, PHP_RETURN
RETURN, PHP_RETURN
Return, PHP_RETURN
static, PHP_STATIC
STATIC, PHP_STATIC
Static, PHP_STATIC
switch, PHP_SWITCH
SWITCH, PHP_SWITCH
Switch, PHP_SWITCH
throw, PHP_THROW
THROW, PHP_THROW
Throw, PHP_THROW
trait, PHP_TRAIT
TRAIT, PHP_TRAIT
Trait, PHP_TRAIT
try, PHP_TRY
TRY, PHP_TRY
Try, PHP_TRY
true, PHP_TRUE
TRUE, PHP_TRUE
True, PHP_TRUE
unset, PHP_UNSET
UNSET, PHP_UNSET
Unset, PHP_UNSET
use, PHP_USE
USE, PHP_USE
Use, PHP_USE
var, PHP_VAR
VAR, PHP_VAR
Var, PHP_VAR
while, PHP_WHILE
WHILE, PHP_WHILE
While, PHP_WHILE
xor, PHP_XOR
XOR, PHP_XOR
Xor, PHP_XOR
yield, PHP_YIELD
YIELD, PHP_YIELD
Yield, PHP_YIELD
"GLOBALS", PHP_GLOBALS
"HTTP_COOKIE_VARS", PHP_HTTP_COOKIE_VARS
"HTTP_ENV_VARS", PHP_HTTP_ENV_VARS
"HTTP_GET_VARS", PHP_HTTP_GET_VARS
"HTTP_POST_FILES", PHP_HTTP_POST_FILES
"HTTP_POST_VARS", PHP_HTTP_POST_VARS
"HTTP_SERVER_VARS", PHP_HTTP_SERVER_VARS
"HTTP_SESSION_VARS", PHP_HTTP_SESSION_VARS
"_COOKIE", PHP__COOKIE
"_ENV", PHP__ENV
"_FILES", PHP__FILES
"_GET", PHP__GET
"_POST", PHP__POST
"_REQUEST", PHP__REQUEST
"_SERVER", PHP__SERVER
"_SESSION", PHP__SESSION
%%
int
php_reserved_word(const char *str, int len)
{
struct keyword *keyword;
keyword = php_lookup(str, len);
return (keyword && IS_RESERVED_WORD(keyword->token)) ? keyword->token : 0;
}
int
php_reserved_variable(const char *str, int len)
{
struct keyword *keyword;
keyword = php_lookup(str, len);
return (keyword && IS_RESERVED_VARIABLE(keyword->token)) ? keyword->token : 0;
}
|