加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lexor_keyword.gperf 15.57 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* 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
%language=C++
%define class-name Lkwd
%{
/* Command-line: gperf -o -i 7 -C -k '1-4,6,9,$' -H keyword_hash -N check_identifier -t ./lexor_keyword.gperf */
#include <cstdarg>
#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; };
%%
above, GN_KEYWORDS_VAMS_2_3, K_above
abs, GN_KEYWORDS_VAMS_2_3, K_abs
absdelay, GN_KEYWORDS_VAMS_2_3, K_absdelay
abstol, GN_KEYWORDS_VAMS_2_3, K_abstol
accept_on, GN_KEYWORDS_1800_2009, K_accept_on
access, GN_KEYWORDS_VAMS_2_3, K_access
acos, GN_KEYWORDS_VAMS_2_3, K_acos
acosh, GN_KEYWORDS_VAMS_2_3, K_acosh
ac_stim, GN_KEYWORDS_VAMS_2_3, K_ac_stim
alias, GN_KEYWORDS_1800_2005, K_alias
aliasparam, GN_KEYWORDS_VAMS_2_3, K_aliasparam
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
analysis, GN_KEYWORDS_VAMS_2_3, K_analysis
and, GN_KEYWORDS_1364_1995, K_and
asin, GN_KEYWORDS_VAMS_2_3, K_asin
asinh, GN_KEYWORDS_VAMS_2_3, K_asinh
# This is defined by both SystemVerilog 1800-2005 and Verilog-AMS 2.3
assert, GN_KEYWORDS_1800_2005|GN_KEYWORDS_VAMS_2_3, K_assert
assign, GN_KEYWORDS_1364_1995, K_assign
assume, GN_KEYWORDS_1800_2005, K_assume
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
before, GN_KEYWORDS_1800_2005, K_before
begin, GN_KEYWORDS_1364_1995, K_begin
bind, GN_KEYWORDS_1800_2005, K_bind
bins, GN_KEYWORDS_1800_2005, K_bins
binsof, GN_KEYWORDS_1800_2005, K_binsof
bit, GN_KEYWORDS_1800_2005, K_bit
branch, GN_KEYWORDS_VAMS_2_3, K_branch
break, GN_KEYWORDS_1800_2005, K_break
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
byte, GN_KEYWORDS_1800_2005, K_byte
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
chandle, GN_KEYWORDS_1800_2005, K_chandle
checker, GN_KEYWORDS_1800_2009, K_checker
class, GN_KEYWORDS_1800_2005, K_class
clocking, GN_KEYWORDS_1800_2005, K_clocking
cmos, GN_KEYWORDS_1364_1995, K_cmos
config, GN_KEYWORDS_1364_2001_CONFIG, K_config
connect, GN_KEYWORDS_VAMS_2_3, K_connect
connectmodule, GN_KEYWORDS_VAMS_2_3, K_connectmodule
connectrules, GN_KEYWORDS_VAMS_2_3, K_connectrules
const, GN_KEYWORDS_1800_2005, K_const
constraint, GN_KEYWORDS_1800_2005, K_constraint
context, GN_KEYWORDS_1800_2005, K_context
continue, GN_KEYWORDS_1800_2005, K_continue
continuous, GN_KEYWORDS_VAMS_2_3, K_continuous
cos, GN_KEYWORDS_VAMS_2_3, K_cos
cosh, GN_KEYWORDS_VAMS_2_3, K_cosh
cover, GN_KEYWORDS_1800_2005, K_cover
covergroup, GN_KEYWORDS_1800_2005, K_covergroup
coverpoint, GN_KEYWORDS_1800_2005, K_coverpoint
cross, GN_KEYWORDS_1800_2005, K_cross
ddt, GN_KEYWORDS_VAMS_2_3, K_ddt
ddt_nature, GN_KEYWORDS_VAMS_2_3, K_ddt_nature
ddx, GN_KEYWORDS_VAMS_2_3, K_ddx
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
dist, GN_KEYWORDS_1800_2005, K_dist
do, GN_KEYWORDS_1800_2005, K_do
domain, GN_KEYWORDS_VAMS_2_3, K_domain
driver_update, GN_KEYWORDS_VAMS_2_3, K_driver_update
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
endchecker, GN_KEYWORDS_1800_2009, K_endchecker
endconfig, GN_KEYWORDS_1364_2001_CONFIG, K_endconfig
endclass, GN_KEYWORDS_1800_2005, K_endclass
endclocking, GN_KEYWORDS_1800_2005, K_endclocking
endconnectrules, GN_KEYWORDS_VAMS_2_3, K_endconnectrules
enddiscipline, GN_KEYWORDS_VAMS_2_3, K_enddiscipline
endfunction, GN_KEYWORDS_1364_1995, K_endfunction
endgenerate, GN_KEYWORDS_1364_2001, K_endgenerate
endgroup, GN_KEYWORDS_1800_2005, K_endgroup
endinterface, GN_KEYWORDS_1800_2005, K_endinterface
endmodule, GN_KEYWORDS_1364_1995, K_endmodule
endnature, GN_KEYWORDS_VAMS_2_3, K_endnature
endpackage, GN_KEYWORDS_1800_2005, K_endpackage
endparamset, GN_KEYWORDS_VAMS_2_3, K_endparamset
endprimitive, GN_KEYWORDS_1364_1995, K_endprimitive
endprogram, GN_KEYWORDS_1800_2005, K_endprogram
endproperty, GN_KEYWORDS_1800_2005, K_endproperty
endspecify, GN_KEYWORDS_1364_1995, K_endspecify
endsequence, GN_KEYWORDS_1800_2005, K_endsequence
endtable, GN_KEYWORDS_1364_1995, K_endtable
endtask, GN_KEYWORDS_1364_1995, K_endtask
enum, GN_KEYWORDS_1800_2005, K_enum
event, GN_KEYWORDS_1364_1995, K_event
eventually, GN_KEYWORDS_1800_2009, K_eventually
exclude, GN_KEYWORDS_VAMS_2_3, K_exclude
exp, GN_KEYWORDS_VAMS_2_3, K_exp
expect, GN_KEYWORDS_1800_2005, K_expect
export, GN_KEYWORDS_1800_2005, K_export
extends, GN_KEYWORDS_1800_2005, K_extends
extern, GN_KEYWORDS_1800_2005, K_extern
final, GN_KEYWORDS_1800_2005, K_final
final_step, GN_KEYWORDS_VAMS_2_3, K_final_step
first_match, GN_KEYWORDS_1800_2005, K_first_match
flicker_noise, GN_KEYWORDS_VAMS_2_3, K_flicker_noise
floor, GN_KEYWORDS_VAMS_2_3, K_floor
flow, GN_KEYWORDS_VAMS_2_3, K_flow
for, GN_KEYWORDS_1364_1995, K_for
foreach, GN_KEYWORDS_1800_2005, K_foreach
force, GN_KEYWORDS_1364_1995, K_force
forever, GN_KEYWORDS_1364_1995, K_forever
fork, GN_KEYWORDS_1364_1995, K_fork
forkjoin, GN_KEYWORDS_1800_2005, K_forkjoin
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
global, GN_KEYWORDS_1800_2009, K_global
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, GN_KEYWORDS_VAMS_2_3, K_idt
idtmod, GN_KEYWORDS_VAMS_2_3, K_idtmod
idt_nature, GN_KEYWORDS_VAMS_2_3, K_idt_nature
if, GN_KEYWORDS_1364_1995, K_if
iff, GN_KEYWORDS_1800_2005, K_iff
ifnone, GN_KEYWORDS_1364_1995, K_ifnone
ignore_bins, GN_KEYWORDS_1800_2005, K_ignore_bins
illegal_bins, GN_KEYWORDS_1800_2005, K_illegal_bins
implies, GN_KEYWORDS_1800_2009, K_implies
implements, GN_KEYWORDS_1800_2012, K_implements
import, GN_KEYWORDS_1800_2005, K_import
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
initial_step, GN_KEYWORDS_VAMS_2_3, K_initial_step
inout, GN_KEYWORDS_1364_1995, K_inout
input, GN_KEYWORDS_1364_1995, K_input
inside, GN_KEYWORDS_1800_2005, K_inside
instance, GN_KEYWORDS_1364_2001_CONFIG, K_instance
int, GN_KEYWORDS_1800_2005, K_int
integer, GN_KEYWORDS_1364_1995, K_integer
interconnect, GN_KEYWORDS_1800_2012, K_interconnect
interface, GN_KEYWORDS_1800_2005, K_interface
intersect, GN_KEYWORDS_1800_2005, K_intersect
join, GN_KEYWORDS_1364_1995, K_join
join_any, GN_KEYWORDS_1800_2005, K_join_any
join_none, GN_KEYWORDS_1800_2005, K_join_none
laplace_nd, GN_KEYWORDS_VAMS_2_3, K_laplace_nd
laplace_np, GN_KEYWORDS_VAMS_2_3, K_laplace_np
laplace_zd, GN_KEYWORDS_VAMS_2_3, K_laplace_zd
laplace_zp, GN_KEYWORDS_VAMS_2_3, K_laplace_zp
large, GN_KEYWORDS_1364_1995, K_large
last_crossing, GN_KEYWORDS_VAMS_2_3, K_last_crossing
let, GN_KEYWORDS_1800_2009, K_let
liblist, GN_KEYWORDS_1364_2001_CONFIG, K_liblist
library, GN_KEYWORDS_1364_2001_CONFIG, K_library
limexp, GN_KEYWORDS_VAMS_2_3, K_limexp
ln, GN_KEYWORDS_VAMS_2_3, K_ln
local, GN_KEYWORDS_1800_2005, K_local
localparam, GN_KEYWORDS_1364_2001, K_localparam
log, GN_KEYWORDS_VAMS_2_3, K_log
# This is defined by SystemVerilog 1800-2005 and as an Icarus extension.
logic, GN_KEYWORDS_1800_2005|GN_KEYWORDS_ICARUS, K_logic
longint, GN_KEYWORDS_1800_2005, K_longint
macromodule, GN_KEYWORDS_1364_1995, K_macromodule
matches, GN_KEYWORDS_1800_2005, K_matches
max, GN_KEYWORDS_VAMS_2_3, K_max
medium, GN_KEYWORDS_1364_1995, K_medium
merged, GN_KEYWORDS_VAMS_2_3, K_merged
min, GN_KEYWORDS_VAMS_2_3, K_min
modport, GN_KEYWORDS_1800_2005, K_modport
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
net_resolution, GN_KEYWORDS_VAMS_2_3, K_net_resolution
nettype, GN_KEYWORDS_1800_2012, K_nettype
new, GN_KEYWORDS_1800_2005, K_new
nexttime, GN_KEYWORDS_1800_2009, K_nexttime
nmos, GN_KEYWORDS_1364_1995, K_nmos
noise_table, GN_KEYWORDS_VAMS_2_3, K_noise_table
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
null, GN_KEYWORDS_1800_2005, K_null
or, GN_KEYWORDS_1364_1995, K_or
output, GN_KEYWORDS_1364_1995, K_output
package, GN_KEYWORDS_1800_2005, K_package
packed, GN_KEYWORDS_1800_2005, K_packed
parameter, GN_KEYWORDS_1364_1995, K_parameter
paramset, GN_KEYWORDS_VAMS_2_3, K_paramset
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
priority, GN_KEYWORDS_1800_2005, K_priority
program, GN_KEYWORDS_1800_2005, K_program
property, GN_KEYWORDS_1800_2005, K_property
protected, GN_KEYWORDS_1800_2005, K_protected
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
pure, GN_KEYWORDS_1800_2005, K_pure
rand, GN_KEYWORDS_1800_2005, K_rand
randc, GN_KEYWORDS_1800_2005, K_randc
randcase, GN_KEYWORDS_1800_2005, K_randcase
randsequence, GN_KEYWORDS_1800_2005, K_randsequence
rcmos, GN_KEYWORDS_1364_1995, K_rcmos
real, GN_KEYWORDS_1364_1995, K_real
realtime, GN_KEYWORDS_1364_1995, K_realtime
ref, GN_KEYWORDS_1800_2005, K_ref
reg, GN_KEYWORDS_1364_1995, K_reg
reject_on, GN_KEYWORDS_1800_2009, K_reject_on
release, GN_KEYWORDS_1364_1995, K_release
repeat, GN_KEYWORDS_1364_1995, K_repeat
resolveto, GN_KEYWORDS_VAMS_2_3, K_resolveto
restrict, GN_KEYWORDS_1800_2009, K_restrict
return, GN_KEYWORDS_1800_2005, K_return
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
s_always, GN_KEYWORDS_1800_2009, K_s_always
s_eventually, GN_KEYWORDS_1800_2009, K_s_eventually
s_nexttime, GN_KEYWORDS_1800_2009, K_s_nexttime
s_until, GN_KEYWORDS_1800_2009, K_s_until
s_until_with, GN_KEYWORDS_1800_2009, K_s_until_with
scalared, GN_KEYWORDS_1364_1995, K_scalared
sequence, GN_KEYWORDS_1800_2005, K_sequence
shortint, GN_KEYWORDS_1800_2005, K_shortint
shortreal, GN_KEYWORDS_1800_2005, K_shortreal
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
slew, GN_KEYWORDS_VAMS_2_3, K_slew
small, GN_KEYWORDS_1364_1995, K_small
soft, GN_KEYWORDS_1800_2012, K_soft
solve, GN_KEYWORDS_1800_2005, K_solve
specify, GN_KEYWORDS_1364_1995, K_specify
specparam, GN_KEYWORDS_1364_1995, K_specparam
split, GN_KEYWORDS_VAMS_2_3, K_split
sqrt, GN_KEYWORDS_VAMS_2_3, K_sqrt
static, GN_KEYWORDS_1800_2005, K_static
# This is defined by both SystemVerilog 1800-2005 and Verilog-AMS 2.3
string, GN_KEYWORDS_1800_2005|GN_KEYWORDS_VAMS_2_3, K_string
strong, GN_KEYWORDS_1800_2009, K_strong
strong0, GN_KEYWORDS_1364_1995, K_strong0
strong1, GN_KEYWORDS_1364_1995, K_strong1
struct, GN_KEYWORDS_1800_2005, K_struct
super, GN_KEYWORDS_1800_2005, K_super
supply0, GN_KEYWORDS_1364_1995, K_supply0
supply1, GN_KEYWORDS_1364_1995, K_supply1
sync_accept_on, GN_KEYWORDS_1800_2009, K_sync_accept_on
sync_reject_on, GN_KEYWORDS_1800_2009, K_sync_reject_on
table, GN_KEYWORDS_1364_1995, K_table
tagged, GN_KEYWORDS_1800_2005, K_tagged
tan, GN_KEYWORDS_VAMS_2_3, K_tan
tanh, GN_KEYWORDS_VAMS_2_3, K_tanh
task, GN_KEYWORDS_1364_1995, K_task
this, GN_KEYWORDS_1800_2005, K_this
throughout, GN_KEYWORDS_1800_2005, K_throughout
time, GN_KEYWORDS_1364_1995, K_time
timeprecision, GN_KEYWORDS_1800_2005, K_timeprecision
timer, GN_KEYWORDS_VAMS_2_3, K_timer
timeunit, GN_KEYWORDS_1800_2005, K_timeunit
tran, GN_KEYWORDS_1364_1995, K_tran
tranif0, GN_KEYWORDS_1364_1995, K_tranif0
tranif1, GN_KEYWORDS_1364_1995, K_tranif1
transition, GN_KEYWORDS_VAMS_2_3, K_transition
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
type, GN_KEYWORDS_1800_2005, K_type
typedef, GN_KEYWORDS_1800_2005, K_typedef
union, GN_KEYWORDS_1800_2005, K_union
unique, GN_KEYWORDS_1800_2005, K_unique
unique0, GN_KEYWORDS_1800_2009, K_unique0
units, GN_KEYWORDS_VAMS_2_3, K_units
# Reserved for future use!
unsigned, GN_KEYWORDS_1364_2001, K_unsigned
until, GN_KEYWORDS_1800_2009, K_until
until_with, GN_KEYWORDS_1800_2009, K_until_with
untyped, GN_KEYWORDS_1800_2009, K_untyped
use, GN_KEYWORDS_1364_2001_CONFIG, K_use
uwire, GN_KEYWORDS_1364_2005, K_uwire
var, GN_KEYWORDS_1800_2005, K_var
vectored, GN_KEYWORDS_1364_1995, K_vectored
virtual, GN_KEYWORDS_1800_2005, K_virtual
void, GN_KEYWORDS_1800_2005, K_void
wait, GN_KEYWORDS_1364_1995, K_wait
wait_order, GN_KEYWORDS_1800_2005, K_wait_order
wand, GN_KEYWORDS_1364_1995, K_wand
weak, GN_KEYWORDS_1800_2009, K_weak
weak0, GN_KEYWORDS_1364_1995, K_weak0
weak1, GN_KEYWORDS_1364_1995, K_weak1
while, GN_KEYWORDS_1364_1995, K_while
white_noise, GN_KEYWORDS_VAMS_2_3, K_white_noise
wildcard, GN_KEYWORDS_1800_2005, K_wildcard
wire, GN_KEYWORDS_1364_1995, K_wire
with, GN_KEYWORDS_1800_2005, K_with
within, GN_KEYWORDS_1800_2005, K_within
# 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
# This is defined by Verilog-AMS 2.3 and as an Icarus extension.
wreal, GN_KEYWORDS_VAMS_2_3|GN_KEYWORDS_ICARUS, K_wreal
xnor, GN_KEYWORDS_1364_1995, K_xnor
xor, GN_KEYWORDS_1364_1995, K_xor
zi_nd, GN_KEYWORDS_VAMS_2_3, K_zi_nd
zi_np, GN_KEYWORDS_VAMS_2_3, K_zi_np
zi_zd, GN_KEYWORDS_VAMS_2_3, K_zi_zd
zi_zp, GN_KEYWORDS_VAMS_2_3, K_zi_zp
%%
int lexor_keyword_mask = 0;
int lexor_keyword_code(const char*str, unsigned nstr)
{
const struct lexor_keyword*rc = Lkwd::check_identifier(str, nstr);
if (rc == 0)
return IDENTIFIER;
else if ((rc->mask & lexor_keyword_mask) == 0)
return IDENTIFIER;
else
return rc->tokenType;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化