/*
 * We need this to prevent -Wextra (-W) from complaining that the mask and
 * tokenType values are not initialized for the empty table entries.
 */
%define initializer-suffix ,0,0

%{
/* Command-line: gperf -o -i 1 --ignore-case -C -k 1-3,$ -L C -H keyword_hash -N check_identifier -tT lexor_keyword.gperf */

#include "vhdlpp_config.h"
#include <cstring>
#include "compiler.h"
#include "parse_api.h"
#include "parse_wrap.h"

%}
struct lexor_keyword { const char*name; int mask; int tokenType; };
%%
abs,		GN_KEYWORD_2008,	K_abs
access,		GN_KEYWORD_2008,	K_access
after,		GN_KEYWORD_2008,	K_after
alias,		GN_KEYWORD_2008,	K_alias
all,		GN_KEYWORD_2008,	K_all
and,		GN_KEYWORD_2008,	K_and
architecture,	GN_KEYWORD_2008,	K_architecture
array,		GN_KEYWORD_2008,	K_array
assert,		GN_KEYWORD_2008,	K_assert
attribute,	GN_KEYWORD_2008,	K_attribute
begin,		GN_KEYWORD_2008,	K_begin
block,		GN_KEYWORD_2008,	K_block
body,		GN_KEYWORD_2008,	K_body
buffer,		GN_KEYWORD_2008,	K_buffer
bus,		GN_KEYWORD_2008,	K_bus
case,		GN_KEYWORD_2008,	K_case
component,	GN_KEYWORD_2008,	K_component
configuration,	GN_KEYWORD_2008,	K_configuration
constant,	GN_KEYWORD_2008,	K_constant
context,	GN_KEYWORD_2008,	K_context
cover,		GN_KEYWORD_2008,	K_cover
default,	GN_KEYWORD_2008,	K_default
disconnect,	GN_KEYWORD_2008,	K_disconnect
downto,		GN_KEYWORD_2008,	K_downto
else,		GN_KEYWORD_2008,	K_else
elsif,		GN_KEYWORD_2008,	K_elsif
end,		GN_KEYWORD_2008,	K_end
entity,		GN_KEYWORD_2008,	K_entity
exit,		GN_KEYWORD_2008,	K_exit
fairness,	GN_KEYWORD_2008,	K_fairness
file,		GN_KEYWORD_2008,	K_file
for,		GN_KEYWORD_2008,	K_for
force,		GN_KEYWORD_2008,	K_force
function,	GN_KEYWORD_2008,	K_function
generate,	GN_KEYWORD_2008,	K_generate
generic,	GN_KEYWORD_2008,	K_generic
group,		GN_KEYWORD_2008,	K_group
guarded,	GN_KEYWORD_2008,	K_guarded
if,		GN_KEYWORD_2008,	K_if
impure,		GN_KEYWORD_2008,	K_impure
in,		GN_KEYWORD_2008,	K_in
inertial,	GN_KEYWORD_2008,	K_inertial
inout,		GN_KEYWORD_2008,	K_inout
is,		GN_KEYWORD_2008,	K_is
label,		GN_KEYWORD_2008,	K_label
library,	GN_KEYWORD_2008,	K_library
linkage,	GN_KEYWORD_2008,	K_linkage
literal,	GN_KEYWORD_2008,	K_literal
loop,		GN_KEYWORD_2008,	K_loop
map,		GN_KEYWORD_2008,	K_map
mod,		GN_KEYWORD_2008,	K_mod
nand,		GN_KEYWORD_2008,	K_nand
new,		GN_KEYWORD_2008,	K_new
next,		GN_KEYWORD_2008,	K_next
nor,		GN_KEYWORD_2008,	K_nor
not,		GN_KEYWORD_2008,	K_not
null,		GN_KEYWORD_2008,	K_null
of,		GN_KEYWORD_2008,	K_of
on,		GN_KEYWORD_2008,	K_on
open,		GN_KEYWORD_2008,	K_open
or,		GN_KEYWORD_2008,	K_or
others,		GN_KEYWORD_2008,	K_others
out,		GN_KEYWORD_2008,	K_out
package,	GN_KEYWORD_2008,	K_package
port,		GN_KEYWORD_2008,	K_port
postponed,	GN_KEYWORD_2008,	K_postponed
procedure,	GN_KEYWORD_2008,	K_procedure
process,	GN_KEYWORD_2008,	K_process
property,	GN_KEYWORD_2008,	K_property
protected,	GN_KEYWORD_2008,	K_protected
pure,		GN_KEYWORD_2008,	K_pure
range,		GN_KEYWORD_2008,	K_range
record,		GN_KEYWORD_2008,	K_record
register,	GN_KEYWORD_2008,	K_register
reject,		GN_KEYWORD_2008,	K_reject
release,	GN_KEYWORD_2008,	K_release
rem,		GN_KEYWORD_2008,	K_rem
report,		GN_KEYWORD_2008,	K_report
restrict,	GN_KEYWORD_2008,	K_restrict
return,		GN_KEYWORD_2008,	K_return
rol,		GN_KEYWORD_2008,	K_rol
ror,		GN_KEYWORD_2008,	K_ror
select,		GN_KEYWORD_2008,	K_select
sequence,	GN_KEYWORD_2008,	K_sequence
severity,	GN_KEYWORD_2008,	K_severity
signal,		GN_KEYWORD_2008,	K_signal
shared,		GN_KEYWORD_2008,	K_shared
sla,		GN_KEYWORD_2008,	K_sla
sll,		GN_KEYWORD_2008,	K_sll
sra,		GN_KEYWORD_2008,	K_sra
srl,		GN_KEYWORD_2008,	K_srl
strong,		GN_KEYWORD_2008,	K_strong
subtype,	GN_KEYWORD_2008,	K_subtype
then,		GN_KEYWORD_2008,	K_then
to,		GN_KEYWORD_2008,	K_to
transport,	GN_KEYWORD_2008,	K_transport
type,		GN_KEYWORD_2008,	K_type
unaffected,	GN_KEYWORD_2008,	K_unaffected
units,		GN_KEYWORD_2008,	K_units
until,		GN_KEYWORD_2008,	K_until
use,		GN_KEYWORD_2008,	K_use
variable,	GN_KEYWORD_2008,	K_variable
vmode,		GN_KEYWORD_2008,	K_vmode
vprop,		GN_KEYWORD_2008,	K_vprop
vunit,		GN_KEYWORD_2008,	K_vunit
wait,		GN_KEYWORD_2008,	K_wait
when,		GN_KEYWORD_2008,	K_when
while,		GN_KEYWORD_2008,	K_while
with,		GN_KEYWORD_2008,	K_with
xnor,		GN_KEYWORD_2008,	K_xnor
xor,		GN_KEYWORD_2008,	K_xor
%%

int lexor_keyword_mask = GN_KEYWORD_2008;

int lexor_keyword_code(const char*str, unsigned nstr)
{
      const struct lexor_keyword*rc = check_identifier(str, nstr);
      if (rc == 0)
	  return IDENTIFIER;
      else if ((rc->mask & lexor_keyword_mask) == 0)
          return IDENTIFIER;
      else
	  return rc->tokenType;
}
