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

#include "config.h"
#include "parse_misc.h"
#include "parse.h"
#include <cstring>
#include "lexor_keyword.h"
#include "compiler.h"

%}
struct lexor_keyword { const char*name; int mask; int tokenType; };
%%
abs,			GN_KEYWORDS_VAMS_2_3,		K_abs
abstol,			GN_KEYWORDS_VAMS_2_3,		K_abstol
access,			GN_KEYWORDS_VAMS_2_3,		K_access
acos,			GN_KEYWORDS_VAMS_2_3,		K_acos
acosh,			GN_KEYWORDS_VAMS_2_3,		K_acosh
always,			GN_KEYWORDS_1364_1995,		K_always
always_comb,		GN_KEYWORDS_1800_2005,		K_always_comb
always_ff,		GN_KEYWORDS_1800_2005,		K_always_ff
always_latch,		GN_KEYWORDS_1800_2005,		K_always_latch
analog,			GN_KEYWORDS_VAMS_2_3,		K_analog
and,			GN_KEYWORDS_1364_1995,		K_and
asin,			GN_KEYWORDS_VAMS_2_3,		K_asin
asinh,			GN_KEYWORDS_VAMS_2_3,		K_asinh
assert,			GN_KEYWORDS_1800_2005,		K_assert
assign,			GN_KEYWORDS_1364_1995,		K_assign
atan,			GN_KEYWORDS_VAMS_2_3,		K_atan
atan2,			GN_KEYWORDS_VAMS_2_3,		K_atan2
atanh,			GN_KEYWORDS_VAMS_2_3,		K_atanh
automatic,		GN_KEYWORDS_1364_2001,		K_automatic
begin,			GN_KEYWORDS_1364_1995,		K_begin
bool,			GN_KEYWORDS_ICARUS,		K_bool
buf,			GN_KEYWORDS_1364_1995,		K_buf
bufif0,			GN_KEYWORDS_1364_1995,		K_bufif0
bufif1,			GN_KEYWORDS_1364_1995,		K_bufif1
case,			GN_KEYWORDS_1364_1995,		K_case
casex,			GN_KEYWORDS_1364_1995,		K_casex
casez,			GN_KEYWORDS_1364_1995,		K_casez
ceil,			GN_KEYWORDS_VAMS_2_3,		K_ceil
cell,			GN_KEYWORDS_1364_2001_CONFIG,	K_cell
cmos,			GN_KEYWORDS_1364_1995,		K_cmos
config,			GN_KEYWORDS_1364_2001_CONFIG,	K_config
continuous,		GN_KEYWORDS_VAMS_2_3,		K_continuous
cos,			GN_KEYWORDS_VAMS_2_3,		K_cos
cosh,			GN_KEYWORDS_VAMS_2_3,		K_cosh
ddt_nature,		GN_KEYWORDS_VAMS_2_3,		K_ddt_nature
deassign,		GN_KEYWORDS_1364_1995,		K_deassign
default,		GN_KEYWORDS_1364_1995,		K_default
defparam,		GN_KEYWORDS_1364_1995,		K_defparam
design,			GN_KEYWORDS_1364_2001_CONFIG,	K_design
disable,		GN_KEYWORDS_1364_1995,		K_disable
discipline,		GN_KEYWORDS_VAMS_2_3,		K_discipline
discrete,		GN_KEYWORDS_VAMS_2_3,		K_discrete
domain,			GN_KEYWORDS_VAMS_2_3,		K_domain
edge,			GN_KEYWORDS_1364_1995,		K_edge
else,			GN_KEYWORDS_1364_1995,		K_else
end,			GN_KEYWORDS_1364_1995,		K_end
endcase,		GN_KEYWORDS_1364_1995,		K_endcase
endconfig,		GN_KEYWORDS_1364_2001_CONFIG,	K_endconfig
enddiscipline,		GN_KEYWORDS_VAMS_2_3,		K_enddiscipline
endfunction,		GN_KEYWORDS_1364_1995,		K_endfunction
endgenerate,		GN_KEYWORDS_1364_2001,		K_endgenerate
endmodule,		GN_KEYWORDS_1364_1995,		K_endmodule
endnature,		GN_KEYWORDS_VAMS_2_3,		K_endnature
endprimitive,		GN_KEYWORDS_1364_1995,		K_endprimitive
endspecify,		GN_KEYWORDS_1364_1995,		K_endspecify
endtable,		GN_KEYWORDS_1364_1995,		K_endtable
endtask,		GN_KEYWORDS_1364_1995,		K_endtask
event,			GN_KEYWORDS_1364_1995,		K_event
exclude,		GN_KEYWORDS_VAMS_2_3,		K_exclude
exp,			GN_KEYWORDS_VAMS_2_3,		K_exp
floor,			GN_KEYWORDS_VAMS_2_3,		K_floor
flow,			GN_KEYWORDS_VAMS_2_3,		K_flow
for,			GN_KEYWORDS_1364_1995,		K_for
force,			GN_KEYWORDS_1364_1995,		K_force
forever,		GN_KEYWORDS_1364_1995,		K_forever
fork,			GN_KEYWORDS_1364_1995,		K_fork
from,			GN_KEYWORDS_VAMS_2_3,		K_from
function,		GN_KEYWORDS_1364_1995,		K_function
generate,		GN_KEYWORDS_1364_2001,		K_generate
genvar,			GN_KEYWORDS_1364_2001,		K_genvar
ground,			GN_KEYWORDS_VAMS_2_3,		K_ground
highz0,			GN_KEYWORDS_1364_1995,		K_highz0
highz1,			GN_KEYWORDS_1364_1995,		K_highz1
hypot,			GN_KEYWORDS_VAMS_2_3,		K_hypot
idt_nature,		GN_KEYWORDS_VAMS_2_3,		K_idt_nature
if,			GN_KEYWORDS_1364_1995,		K_if
ifnone,			GN_KEYWORDS_1364_1995,		K_ifnone
incdir,			GN_KEYWORDS_1364_2001_CONFIG,	K_incdir
include,		GN_KEYWORDS_1364_2001_CONFIG,	K_include
inf,			GN_KEYWORDS_VAMS_2_3,		K_inf
initial,		GN_KEYWORDS_1364_1995,		K_initial
inout,			GN_KEYWORDS_1364_1995,		K_inout
input,			GN_KEYWORDS_1364_1995,		K_input
instance,		GN_KEYWORDS_1364_2001_CONFIG,	K_instance
integer,		GN_KEYWORDS_1364_1995,		K_integer
join,			GN_KEYWORDS_1364_1995,		K_join
large,			GN_KEYWORDS_1364_1995,		K_large
liblist,		GN_KEYWORDS_1364_2001_CONFIG,	K_liblist
library,		GN_KEYWORDS_1364_2001_CONFIG,	K_library
ln,			GN_KEYWORDS_VAMS_2_3,		K_ln
localparam,		GN_KEYWORDS_1364_2001,		K_localparam
log,			GN_KEYWORDS_VAMS_2_3,		K_log
logic,			GN_KEYWORDS_ICARUS,		K_logic
macromodule,		GN_KEYWORDS_1364_1995,		K_macromodule
max,			GN_KEYWORDS_VAMS_2_3,		K_max
medium,			GN_KEYWORDS_1364_1995,		K_medium
min,			GN_KEYWORDS_VAMS_2_3,		K_min
module,			GN_KEYWORDS_1364_1995,		K_module
nand,			GN_KEYWORDS_1364_1995,		K_nand
nature,			GN_KEYWORDS_VAMS_2_3,		K_nature
negedge,		GN_KEYWORDS_1364_1995,		K_negedge
nmos,			GN_KEYWORDS_1364_1995,		K_nmos
nor,			GN_KEYWORDS_1364_1995,		K_nor
noshowcancelled,	GN_KEYWORDS_1364_2001,		K_noshowcancelled
not,			GN_KEYWORDS_1364_1995,		K_not
notif0,			GN_KEYWORDS_1364_1995,		K_notif0
notif1,			GN_KEYWORDS_1364_1995,		K_notif1
or,			GN_KEYWORDS_1364_1995,		K_or
output,			GN_KEYWORDS_1364_1995,		K_output
parameter,		GN_KEYWORDS_1364_1995,		K_parameter
pmos,			GN_KEYWORDS_1364_1995,		K_pmos
posedge,		GN_KEYWORDS_1364_1995,		K_posedge
potential,		GN_KEYWORDS_VAMS_2_3,		K_potential
pow,			GN_KEYWORDS_VAMS_2_3,		K_pow
primitive,		GN_KEYWORDS_1364_1995,		K_primitive
pull0,			GN_KEYWORDS_1364_1995,		K_pull0
pull1,			GN_KEYWORDS_1364_1995,		K_pull1
pulldown,		GN_KEYWORDS_1364_1995,		K_pulldown
pullup,			GN_KEYWORDS_1364_1995,		K_pullup
pulsestyle_onevent,	GN_KEYWORDS_1364_2001,		K_pulsestyle_onevent
pulsestyle_ondetect,	GN_KEYWORDS_1364_2001,		K_pulsestyle_ondetect
rcmos,			GN_KEYWORDS_1364_1995,		K_rcmos
real,			GN_KEYWORDS_1364_1995,		K_real
realtime,		GN_KEYWORDS_1364_1995,		K_realtime
reg,			GN_KEYWORDS_1364_1995,		K_reg
release,		GN_KEYWORDS_1364_1995,		K_release
repeat,			GN_KEYWORDS_1364_1995,		K_repeat
rnmos,			GN_KEYWORDS_1364_1995,		K_rnmos
rpmos,			GN_KEYWORDS_1364_1995,		K_rpmos
rtran,			GN_KEYWORDS_1364_1995,		K_rtran
rtranif0,		GN_KEYWORDS_1364_1995,		K_rtranif0
rtranif1,		GN_KEYWORDS_1364_1995,		K_rtranif1
scalared,		GN_KEYWORDS_1364_1995,		K_scalared
showcancelled,		GN_KEYWORDS_1364_2001,		K_showcancelled
signed,			GN_KEYWORDS_1364_2001,		K_signed
sin,			GN_KEYWORDS_VAMS_2_3,		K_sin
sinh,			GN_KEYWORDS_VAMS_2_3,		K_sinh
small,			GN_KEYWORDS_1364_1995,		K_small
specify,		GN_KEYWORDS_1364_1995,		K_specify
specparam,		GN_KEYWORDS_1364_1995,		K_specparam
sqrt,			GN_KEYWORDS_VAMS_2_3,		K_sqrt
string,			GN_KEYWORDS_VAMS_2_3,		K_string
strong0,		GN_KEYWORDS_1364_1995,		K_strong0
strong1,		GN_KEYWORDS_1364_1995,		K_strong1
supply0,		GN_KEYWORDS_1364_1995,		K_supply0
supply1,		GN_KEYWORDS_1364_1995,		K_supply1
table,			GN_KEYWORDS_1364_1995,		K_table
tan,			GN_KEYWORDS_VAMS_2_3,		K_tan
tanh,			GN_KEYWORDS_VAMS_2_3,		K_tanh
task,			GN_KEYWORDS_1364_1995,		K_task
time,			GN_KEYWORDS_1364_1995,		K_time
tran,			GN_KEYWORDS_1364_1995,		K_tran
tranif0,		GN_KEYWORDS_1364_1995,		K_tranif0
tranif1,		GN_KEYWORDS_1364_1995,		K_tranif1
tri,			GN_KEYWORDS_1364_1995,		K_tri
tri0,			GN_KEYWORDS_1364_1995,		K_tri0
tri1,			GN_KEYWORDS_1364_1995,		K_tri1
triand,			GN_KEYWORDS_1364_1995,		K_triand
trior,			GN_KEYWORDS_1364_1995,		K_trior
trireg,			GN_KEYWORDS_1364_1995,		K_trireg
units,			GN_KEYWORDS_VAMS_2_3,		K_units
# Reserved for future use!
unsigned,		GN_KEYWORDS_1364_2001,		K_unsigned
use,			GN_KEYWORDS_1364_2001_CONFIG,	K_use
uwire,			GN_KEYWORDS_1364_2005,		K_uwire
vectored,		GN_KEYWORDS_1364_1995,		K_vectored
wait,			GN_KEYWORDS_1364_1995,		K_wait
wand,			GN_KEYWORDS_1364_1995,		K_wand
weak0,			GN_KEYWORDS_1364_1995,		K_weak0
weak1,			GN_KEYWORDS_1364_1995,		K_weak1
while,			GN_KEYWORDS_1364_1995,		K_while
wire,			GN_KEYWORDS_1364_1995,		K_wire
# This is the name originally proposed for uwire and is deprecated!
wone,			GN_KEYWORDS_1364_2005,		K_wone
wor,			GN_KEYWORDS_1364_1995,		K_wor
xnor,			GN_KEYWORDS_1364_1995,		K_xnor
xor,			GN_KEYWORDS_1364_1995,		K_xor
%%

int lexor_keyword_mask = 0;

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;
}
