%{
#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;
}
