Skip to content

Commit 7c0f8d9

Browse files
committed
Support IEEE 1800-2023 language keywords. (No other 2023 support yet.)
1 parent 7091deb commit 7c0f8d9

File tree

8 files changed

+45
-33
lines changed

8 files changed

+45
-33
lines changed

Changes

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ indicates the contributor was also the author of the fix; Thanks!
66

77
* Verilog-Perl 3.481 devel
88

9+
*** Support IEEE 1800-2023 language keywords. (No other 2023 support yet.)
10+
911
**** Fix t/03_spaces.t test for Debian (#1675). [Gregor Herrmann]
1012

1113
**** Fix GCC 11 false free-nonheap-obj warning.

Language.pm

+12-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ General functions will be added as needed.
3535
Return true if the given symbol string is a Verilog reserved keyword.
3636
Value indicates the language standard as per the `begin_keywords macro,
3737
'1364-1995', '1364-2001', '1364-2005', '1800-2005', '1800-2009',
38-
'1800-2012', '1800-2017' or 'VAMS'.
38+
'1800-2012', '1800-2017', '1800-2023', or 'VAMS'.
3939
4040
=item Verilog::Language::is_compdirect($symbol_string)
4141
@@ -56,12 +56,12 @@ value of the hash is the standard in which it was defined.
5656
Sets the language standard to indicate what are keywords. If undef, all
5757
standards apply. The year is indicates the language standard as per the
5858
`begin_keywords macro, '1364-1995', '1364-2001', '1364-2005', '1800-2005'
59-
'1800-2009', '1800-2012' or '1800-2017'.
59+
'1800-2009', '1800-2012', '1800-2017', or '1800-2023'.
6060
6161
=item Verilog::Language::language_maximum
6262
6363
Returns the greatest language currently standardized, presently
64-
'1800-2017'.
64+
'1800-2023'.
6565
6666
=item Verilog::Language::number_bigint($number_string)
6767
@@ -219,6 +219,9 @@ foreach my $kwd (qw(
219219
foreach my $kwd (qw(
220220
)) { $Keywords{'1800-2017'}{$kwd} = '1800-2017'; }
221221

222+
foreach my $kwd (qw(
223+
)) { $Keywords{'1800-2023'}{$kwd} = '1800-2023'; }
224+
222225
foreach my $kwd (qw(
223226
above abs absdelay abstol ac_stim access acos acosh
224227
aliasparam analog analysis asin asinh assert atan atan2
@@ -304,7 +307,7 @@ foreach my $kwd (qw(
304307
#### Keyword utilities
305308

306309
sub language_maximum {
307-
return "1800-2017";
310+
return "1800-2023";
308311
}
309312

310313
sub _language_kwd_hash {
@@ -333,10 +336,14 @@ sub _language_kwd_hash {
333336
$Standard = '1800-2012';
334337
@subsets = ('1800-2012', '1800-2009', '1800-2005',
335338
'1364-2005', '1364-2001', '1364-1995');
336-
} elsif ($standard eq 'latest' || $standard eq '1800-2017') {
339+
} elsif ($standard eq '1800-2017') {
337340
$Standard = '1800-2017';
338341
@subsets = ('1800-2017', '1800-2012', '1800-2009', '1800-2005',
339342
'1364-2005', '1364-2001', '1364-1995');
343+
} elsif ($standard eq 'latest' || $standard eq '1800-2023') {
344+
$Standard = '1800-2023';
345+
@subsets = ('1800-2023', '1800-2017', '1800-2012', '1800-2009', '1800-2005',
346+
'1364-2005', '1364-2001', '1364-1995');
340347
} elsif ($standard =~ /^V?AMS/) {
341348
$Standard = 'VAMS';
342349
@subsets = ('VAMS',

Parser/VParseLex.l

+21-19
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#define YY_SKIP_YYWRAP
4242

43-
#define STATE_VERILOG_RECENT S17 // State name for most recent Verilog Version
43+
#define STATE_VERILOG_RECENT S23 // State name for most recent Verilog Version
4444

4545
// Flex 2.5.35 has compile warning in ECHO, so we'll default our own rule
4646
#define ECHO yyerrorf("Missing VParseLex.l rule: ECHO rule invoked in state %d: %s", YY_START, yytext);
@@ -88,7 +88,7 @@ void yyerrorf(const char* format, ...) {
8888
/**********************************************************************/
8989
%}
9090

91-
%s V95 V01 V05 S05 S09 S12 S17
91+
%s V95 V01 V05 S05 S09 S12 S17 S23
9292
%s STRING ATTRMODE
9393
%s CMTMODE PROTMODE
9494
%s DUMMY_TO_AVOID_WARNING
@@ -114,7 +114,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
114114
<INITIAL>.|\n {BEGIN STATE_VERILOG_RECENT; yyless(0); }
115115

116116
/* Verilog 1995 */
117-
<V95,V01,V05,S05,S09,S12,S17>{
117+
<V95,V01,V05,S05,S09,S12,S17,S23>{
118118
{ws} { StashPrefix; } /* otherwise ignore white-space */
119119
{crnl} { StashPrefix; NEXTLINE(); } /* Count line numbers */
120120
/* Keywords */
@@ -224,7 +224,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
224224
}
225225

226226
/* Verilog 2001 */
227-
<V01,V05,S05,S09,S12,S17>{
227+
<V01,V05,S05,S09,S12,S17,S23>{
228228
/* Keywords*/
229229
"automatic" { FL; VALTEXT; CALLBACK(keywordCb); return yAUTOMATIC; }
230230
"endgenerate" { FL; VALTEXT; CALLBACK(keywordCb); return yENDGENERATE; }
@@ -252,13 +252,13 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
252252
}
253253

254254
/* Verilog 2005 */
255-
<V05,S05,S09,S12,S17>{
255+
<V05,S05,S09,S12,S17,S23>{
256256
/* Keywords */
257257
"uwire" { FL; VALTEXT; CALLBACK(keywordCb); return yWIRE; }
258258
}
259259

260260
/* System Verilog 2005 */
261-
<S05,S09,S12,S17>{
261+
<S05,S09,S12,S17,S23>{
262262
/* System Tasks */
263263
"$error" { FL; VALTEXT; CALLBACK(keywordCb); return yD_ERROR; }
264264
"$fatal" { FL; VALTEXT; CALLBACK(keywordCb); return yD_FATAL; }
@@ -367,7 +367,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
367367
}
368368

369369
/* System Verilog 2009 */
370-
<S09,S12,S17>{
370+
<S09,S12,S17,S23>{
371371
/* Keywords */
372372
"accept_on" { FL; VALTEXT; CALLBACK(keywordCb); return yACCEPT_ON; }
373373
"checker" { FL; VALTEXT; CALLBACK(keywordCb); return yCHECKER; }
@@ -395,7 +395,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
395395
}
396396

397397
/* System Verilog 2012 */
398-
<S12,S17>{
398+
<S12,S17,S23>{
399399
/* Keywords */
400400
"implements" { FL; VALTEXT; CALLBACK(keywordCb); return yIMPLEMENTS; }
401401
"interconnect" { FL; VALTEXT; CALLBACK(keywordCb); return yINTERCONNECT; }
@@ -407,18 +407,18 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
407407
/* No new keywords */
408408

409409
/* Default PLI rule */
410-
<V95,V01,V05,S05,S09,S12,S17>{
410+
<V95,V01,V05,S05,S09,S12,S17,S23>{
411411
"$"[a-zA-Z_$][a-zA-Z0-9_$]* { FL; VALTEXT; CALLBACK(sysfuncCb); return ygenSYSCALL; }
412412
}
413413

414414
/************************************************************************/
415415

416416
/* Single character operator thingies */
417-
<V95,V01,V05,S05,S09,S12,S17>{
417+
<V95,V01,V05,S05,S09,S12,S17,S23>{
418418
"{" { FL; VALTEXT; CALLBACK(operatorCb); return yytext[0]; }
419419
"}" { FL; VALTEXT; CALLBACK(operatorCb); return yytext[0]; }
420420
}
421-
<V95,V01,V05,S05,S09,S12,S17>{
421+
<V95,V01,V05,S05,S09,S12,S17,S23>{
422422
"!" { FL; VALTEXT; CALLBACK(operatorCb); return yytext[0]; }
423423
"#" { FL; VALTEXT; CALLBACK(operatorCb); return yytext[0]; }
424424
"$" { FL; VALTEXT; CALLBACK(operatorCb); return yytext[0]; }
@@ -450,7 +450,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
450450
/* Operators and multi-character symbols */
451451

452452
/* Verilog 1995 Operators */
453-
<V95,V01,V05,S05,S09,S12,S17>{
453+
<V95,V01,V05,S05,S09,S12,S17,S23>{
454454
"&&" { FL; VALTEXT; CALLBACK(operatorCb); return yP_ANDAND; }
455455
"||" { FL; VALTEXT; CALLBACK(operatorCb); return yP_OROR; }
456456
"<=" { FL; VALTEXT; CALLBACK(operatorCb); return yP_LTE; }
@@ -472,7 +472,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
472472
}
473473

474474
/* Verilog 2001 Operators */
475-
<V01,V05,S05,S09,S12,S17>{
475+
<V01,V05,S05,S09,S12,S17,S23>{
476476
"<<<" { FL; VALTEXT; CALLBACK(operatorCb); return yP_SLEFT; }
477477
">>>" { FL; VALTEXT; CALLBACK(operatorCb); return yP_SSRIGHT; }
478478
"**" { FL; VALTEXT; CALLBACK(operatorCb); return yP_POW; }
@@ -482,7 +482,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
482482
}
483483

484484
/* SystemVerilog 2005 Operators */
485-
<S05,S09,S12,S17>{
485+
<S05,S09,S12,S17,S23>{
486486
"'" { FL; VALTEXT; CALLBACK(operatorCb); return yP_TICK; }
487487
"'{" { FL; VALTEXT; CALLBACK(operatorCb); return yP_TICKBRA; }
488488
"==?" { FL; VALTEXT; CALLBACK(operatorCb); return yP_WILDEQUAL; }
@@ -517,12 +517,12 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
517517
}
518518
519519
/* SystemVerilog 2009 Operators */
520-
<S09,S12,S17>{
520+
<S09,S12,S17,S23>{
521521
"<->" { FL; VALTEXT; CALLBACK(operatorCb); return yP_LTMINUSGT; }
522522
}
523523
524524
/* Identifiers and numbers */
525-
<V95,V01,V05,S05,S09,S12,S17>{
525+
<V95,V01,V05,S05,S09,S12,S17,S23>{
526526
/* Consume a following space, as we're going to add one to the symbol, we'd like to avoid inserting an extra */
527527
{escid}{space} { if (VParseLex::symEscapeless(yytext+1,yyleng-1-1)) {
528528
string sym = string(yytext+1,yyleng-1-1);
@@ -619,13 +619,13 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
619619
/************************************************************************/
620620
/* Attributes */
621621
/* Note simulators vary in support for "(* /_*something*_/ foo*)" where _ doesn't exist */
622-
<V95,V01,V05,S05,S09,S12,S17>{
622+
<V95,V01,V05,S05,S09,S12,S17,S23>{
623623
"(*"({ws}|{crnl})*({id}|{escid}) { yymore(); yy_push_state(ATTRMODE); } /* Doesn't match (*), but (* attr_spec */
624624
}
625625

626626
/************************************************************************/
627627
/* Preprocessor */
628-
<V95,V01,V05,S05,S09,S12,S17>{
628+
<V95,V01,V05,S05,S09,S12,S17,S23>{
629629
"`accelerate" { FL; VALTEXT; CALLBACK(preprocCb); } // Verilog-XL compatibility
630630
"`autoexpand_vectornets" { FL; VALTEXT; CALLBACK(preprocCb); } // Verilog-XL compatibility
631631
"`celldefine" { FL; VALTEXT; CALLBACK(preprocCb); LEXP->m_inCellDefine=true; }
@@ -669,13 +669,14 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
669669
"`begin_keywords"[ \t]*\"1800-2009\" { yy_push_state(S09); CALLBACK(preprocCb); }
670670
"`begin_keywords"[ \t]*\"1800-2012\" { yy_push_state(S12); CALLBACK(preprocCb); }
671671
"`begin_keywords"[ \t]*\"1800-2017\" { yy_push_state(S17); CALLBACK(preprocCb); }
672+
"`begin_keywords"[ \t]*\"1800-2023\" { yy_push_state(S23); CALLBACK(preprocCb); }
672673
"`end_keywords" { yy_pop_state(); CALLBACK(preprocCb); }
673674
}
674675

675676
/************************************************************************/
676677
/* Default rules - leave last */
677678

678-
<V95,V01,V05,S05,S09,S12,S17>{
679+
<V95,V01,V05,S05,S09,S12,S17,S23>{
679680
"`"[a-zA-Z_0-9]+ { FL; VALTEXT;
680681
if (LPARSEP->sigParser()) { yyerrorf("Define or directive not defined: %s",yytext); }
681682
else { CALLBACK(preprocCb); } }
@@ -882,6 +883,7 @@ void VParseLex::language(const char* value) {
882883
else if (0==strcmp(value,"1800-2009")) { BEGIN S09; }
883884
else if (0==strcmp(value,"1800-2012")) { BEGIN S12; }
884885
else if (0==strcmp(value,"1800-2017")) { BEGIN S17; }
886+
else if (0==strcmp(value,"1800-2023")) { BEGIN S23; }
885887
else yyerrorf("Unknown setLanguage code: %s", value);
886888
}
887889

README.pod

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ It understands and implements all preprocessor features of SystemVerilog
154154
Verilog::Parser is useful when you need to tokenize or write source filters
155155
(where you need everything including whitespace). It can take raw files,
156156
or preprocessed input, and generates callbacks. It understands all
157-
SystemVerilog 2017 keywords.
157+
SystemVerilog 2023 keywords.
158158

159159
=item Abstract Syntax Tree
160160

t/10_keywords.t

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use strict;
99
use Test::More;
1010

11-
BEGIN { plan tests => 26 }
11+
BEGIN { plan tests => 27 }
1212
BEGIN { require "./t/test_utils.pl"; }
1313

1414
use Verilog::Language;
@@ -18,7 +18,8 @@ ok (Verilog::Language::is_keyword("input"));
1818
ok (!Verilog::Language::is_keyword("not_input"));
1919
ok (Verilog::Language::is_compdirect("`define"));
2020

21-
is (Verilog::Language::language_standard(), '1800-2017');
21+
is (Verilog::Language::language_standard(), '1800-2023');
22+
is (Verilog::Language::language_standard('1800-2023'), '1800-2023');
2223
is (Verilog::Language::language_standard('1800-2017'), '1800-2017');
2324
is (Verilog::Language::language_standard('1800-2012'), '1800-2012');
2425
is (Verilog::Language::language_standard('1800-2009'), '1800-2009');
@@ -34,7 +35,7 @@ ok (Verilog::Language::is_keyword("generate"));
3435
is (Verilog::Language::language_standard(1995), '1364-1995');
3536
ok (!Verilog::Language::is_keyword("generate"));
3637

37-
is (Verilog::Language::language_maximum(), '1800-2017', 'language_maximum');
38+
is (Verilog::Language::language_maximum(), '1800-2023', 'language_maximum');
3839

3940
is (Verilog::Language::strip_comments("he/**/l/**/lo"), "hello");
4041
is (Verilog::Language::strip_comments("he//xx/*\nllo"), "he\nllo");

vhier

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (! GetOptions (
6363
"input-files!" => \$Opt_InFiles,
6464
"resolve-files!" => \$Opt_ResolveFiles,
6565
"skiplist=s" => \$opt_skiplist,
66-
"sv!" => sub { shift; Verilog::Language::language_standard("1800-2017"); },
66+
"sv!" => sub { shift; Verilog::Language::language_standard("1800-2023"); },
6767
"language=s" => sub { shift; Verilog::Language::language_standard(shift); },
6868
"missing!" => \$Opt_Missing,
6969
"missing-modules!" => \$Opt_Missing_Modules,
@@ -468,7 +468,7 @@ example module I<x> is referenced, look in I<x>.I<ext>.
468468
=item -sv
469469
470470
Specifies SystemVerilog language features should be enabled; equivalent to
471-
"--language 1800-2017". This option is selected by default, it exists for
471+
"--language 1800-2023". This option is selected by default, it exists for
472472
compatibility with other simulators.
473473
474474
=item -y I<dir>
@@ -513,7 +513,7 @@ necessary to resolve it into an absolute path for further processing.
513513
514514
With --cells or --forest, show module instance names.
515515
516-
=item --language <1364-1995|1364-2001|1364-2005|1800-2005|1800-2009|1800-2012|1800-2017>
516+
=item --language <1364-1995|1364-2001|1364-2005|1800-2005|1800-2009|1800-2012|1800-2017|1800-2023>
517517
518518
Set the language standard for the files. This determines which tokens are
519519
signals versus keywords, such as the ever-common "do" (data-out signal,

vpassert

+1-1
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ Exclude processing any files which begin with the specified prefix.
14951495
14961496
Displays this message and program version and exits.
14971497
1498-
=item --language <1364-1995|1364-2001|1364-2005|1800-2005|1800-2009|1800-2012|1800-2017>
1498+
=item --language <1364-1995|1364-2001|1364-2005|1800-2005|1800-2009|1800-2012|1800-2017|1800-2023>
14991499
15001500
Set the language standard for the files. This determines which tokens are
15011501
signals versus keywords, such as the ever-common "do" (data-out signal,

vrename

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ changing a keyword will probably result in unrunnable code, however,
677677
occasionally it may be necessary to rename signals which happen to match
678678
the name of keywords recently added to the language (such as 'bit').
679679
680-
=item --language <1364-1995|1364-2001|1364-2005|1800-2005|1800-2009|1800-2012|1800-2017>
680+
=item --language <1364-1995|1364-2001|1364-2005|1800-2005|1800-2009|1800-2012|1800-2017|1800-2023>
681681
682682
Set the language standard for the files. This determines which tokens are
683683
signals versus keywords, such as the ever-common "do" (data-out signal,

0 commit comments

Comments
 (0)