@@ -217,10 +217,6 @@ function paren_expr(expr) {
217217 ) ) ;
218218}
219219
220- function directive ( command ) {
221- return alias ( new RegExp ( '`' + command ) , 'directive_' + command ) ;
222- }
223-
224220
225221/**
226222 *
@@ -3891,7 +3887,8 @@ const rules = {
38913887 $ . conditional_expression ,
38923888 $ . inside_expression ,
38933889 $ . tagged_union_expression ,
3894- $ . text_macro_usage , // Out of LRM
3890+ $ . text_macro_usage , // Out of LRM
3891+ $ . file_or_line_compiler_directive // Out of LRM
38953892 ) ,
38963893
38973894 tagged_union_expression : $ => prec . right ( seq (
@@ -4511,7 +4508,7 @@ const rules = {
45114508
45124509
45134510// ** 22-3 `resetall
4514- resetall_compiler_directive : $ => directive ( ' resetall') ,
4511+ resetall_compiler_directive : $ => '` resetall',
45154512
45164513
45174514// ** 22-4 `include
@@ -4522,11 +4519,11 @@ const rules = {
45224519 ) ) ,
45234520
45244521 include_compiler_directive : $ => seq (
4525- directive ( ' include') ,
4522+ '` include',
45264523 choice (
45274524 $ . quoted_string ,
45284525 $ . system_lib_string ,
4529- $ . text_macro_usage , // Out of LRM (test sv-tests/chapter-22/22.5.1--include-define-expansion)
4526+ $ . text_macro_usage , // Out of LRM (test sv-tests/chapter-22/22.5.1--include-define-expansion)
45304527 )
45314528 ) ,
45324529
@@ -4539,7 +4536,7 @@ const rules = {
45394536 macro_text : $ => token ( prec ( - 1 , / ( \\ ( .| \r ? \n ) | [ ^ \\ \n ] ) * / ) ) ,
45404537
45414538 text_macro_definition : $ => seq (
4542- directive ( ' define') ,
4539+ '` define',
45434540 $ . text_macro_name ,
45444541 optional ( $ . macro_text ) ,
45454542 token . immediate ( / \r ? \n / ) ,
@@ -4552,10 +4549,14 @@ const rules = {
45524549
45534550 list_of_formal_arguments : $ => commaSep1 ( $ . formal_argument ) ,
45544551
4555- formal_argument : $ => seq (
4556- reserved ( 'macros' , $ . simple_identifier ) ,
4557- optseq ( '=' , optchoice ( $ . default_text , $ . string_literal , $ . tf_call , $ . text_macro_usage , reserved ( 'macros' , $ . simple_identifier ) ) ) ,
4558- ) ,
4552+ // formal_argument: $ => seq(
4553+ // reserved('macros', $.simple_identifier),
4554+ // optseq('=', optchoice($.default_text, $.string_literal, $.tf_call, $.text_macro_usage, reserved('macros', $.simple_identifier))),
4555+ // ),
4556+ formal_argument : $ => reserved ( 'macros' , seq (
4557+ $ . simple_identifier ,
4558+ optseq ( '=' , optchoice ( $ . default_text , $ . string_literal , $ . tf_call , $ . text_macro_usage , $ . simple_identifier ) ) ,
4559+ ) ) ,
45594560
45604561 text_macro_identifier : $ => $ . _identifier ,
45614562
@@ -4575,23 +4576,23 @@ const rules = {
45754576 ';'
45764577 ) ,
45774578
4578- undefine_compiler_directive : $ => seq ( directive ( ' undef') , $ . text_macro_identifier ) ,
4579+ undefine_compiler_directive : $ => seq ( '` undef', $ . text_macro_identifier ) ,
45794580
4580- undefineall_compiler_directive : $ => directive ( ' undefineall') ,
4581+ undefineall_compiler_directive : $ => '` undefineall',
45814582
45824583
45834584// ** 22.6 `ifdef, `else, `elsif, `endif, `ifndef
45844585 // Modified with respect to LRM: do not parse preprocessed code
45854586 conditional_compilation_directive : $ => choice (
45864587 seq ( $ . _ifdef_or_ifndef , $ . ifdef_condition ) ,
4587- seq ( directive ( ' elsif') , $ . ifdef_condition ) ,
4588- directive ( ' else') ,
4589- directive ( ' endif')
4588+ seq ( '` elsif', $ . ifdef_condition ) ,
4589+ '` else',
4590+ '` endif'
45904591 ) ,
45914592
45924593 _ifdef_or_ifndef : $ => choice (
4593- directive ( ' ifdef') ,
4594- directive ( ' ifndef')
4594+ '` ifdef',
4595+ '` ifndef'
45954596 ) ,
45964597
45974598 ifdef_condition : $ => choice (
@@ -4611,7 +4612,7 @@ const rules = {
46114612
46124613// ** 22-7 timescale
46134614 timescale_compiler_directive : $ => seq (
4614- directive ( ' timescale') ,
4615+ '` timescale',
46154616 $ . time_literal , // time_unit,
46164617 '/' ,
46174618 $ . time_literal , // time_precision
@@ -4620,7 +4621,7 @@ const rules = {
46204621
46214622// ** 22-8 default_nettype
46224623 default_nettype_compiler_directive : $ => seq (
4623- directive ( ' default_nettype') ,
4624+ '` default_nettype',
46244625 $ . default_nettype_value ,
46254626 token . immediate ( / \r ? \n / ) ,
46264627 ) ,
@@ -4630,21 +4631,21 @@ const rules = {
46304631
46314632// ** 22-9
46324633 unconnected_drive_compiler_directive : $ => seq (
4633- directive ( ' unconnected_drive') ,
4634+ '` unconnected_drive',
46344635 choice ( 'pull0' , 'pull1' ) ,
46354636 token . immediate ( / \r ? \n / ) ,
46364637 ) ,
46374638
46384639
46394640// ** 22.10 `celldefine and `endcelldefine
4640- celldefine_compiler_directive : $ => directive ( ' celldefine') ,
4641+ celldefine_compiler_directive : $ => '` celldefine',
46414642
4642- endcelldefine_compiler_directive : $ => directive ( ' endcelldefine') ,
4643+ endcelldefine_compiler_directive : $ => '` endcelldefine',
46434644
46444645
46454646// ** 22.11 `pragma
46464647 pragma : $ => prec . right ( seq (
4647- directive ( ' pragma') ,
4648+ '` pragma',
46484649 $ . pragma_name ,
46494650 commaSep ( $ . pragma_expression ) ,
46504651 ) ) ,
@@ -4672,7 +4673,7 @@ const rules = {
46724673
46734674// ** 22-12 `line
46744675 line_compiler_directive : $ => seq (
4675- directive ( ' line') ,
4676+ '` line',
46764677 $ . unsigned_number ,
46774678 $ . quoted_string ,
46784679 alias ( token ( / [ 0 - 2 ] / ) , $ . level ) ,
@@ -4681,14 +4682,14 @@ const rules = {
46814682
46824683// ** 22.13 `__FILE__ and `__LINE__
46834684 file_or_line_compiler_directive : $ => choice (
4684- directive ( ' __FILE__') ,
4685- directive ( ' __LINE__') ,
4685+ '` __FILE__',
4686+ '` __LINE__',
46864687 ) ,
46874688
46884689
46894690// ** 22.14 `begin_keywords, `end_keywords
46904691 keywords_directive : $ => seq (
4691- directive ( ' begin_keywords') ,
4692+ '` begin_keywords',
46924693 '\"' ,
46934694 $ . version_specifier ,
46944695 '\"' ,
@@ -4706,7 +4707,7 @@ const rules = {
47064707 '1364-1995' ,
47074708 ) ,
47084709
4709- endkeywords_directive : $ => directive ( ' end_keywords') ,
4710+ endkeywords_directive : $ => '` end_keywords',
47104711
47114712} ;
47124713
@@ -4722,6 +4723,7 @@ module.exports = grammar({
47224723 // Annex B
47234724 reserved : {
47244725 global : $ => [
4726+ // Keywords
47254727 'accept_on' , 'alias' , 'always' , 'always_comb' , 'always_ff' ,
47264728 'always_latch' , 'and' , 'assert' , 'assign' , 'assume' , 'automatic' ,
47274729 'before' , 'begin' , 'bind' , 'bins' , 'binsof' , 'bit' , 'break' , 'buf' ,
@@ -4761,6 +4763,12 @@ module.exports = grammar({
47614763 'vectored' , 'virtual' , 'void' , 'wait' , 'wait_order' , 'wand' , 'weak' ,
47624764 'weak0' , 'weak1' , 'while' , 'wildcard' , 'wire' , 'with' , 'within' , 'wor' ,
47634765 'xnor' , 'xor' ,
4766+ // Compiler directives
4767+ '`__FILE__' , '`__LINE__' , '`begin_keywords' , '`celldefine' ,
4768+ '`default_nettype' , '`define' , '`else' , '`elsif' , '`end_keywords' ,
4769+ '`endcelldefine' , '`endif' , '`ifdef' , '`ifndef' , '`include' , '`line' ,
4770+ '`pragma' , '`resetall' , '`timescale' , '`unconnected_drive' , '`undef' ,
4771+ '`undefineall' ,
47644772 ] ,
47654773
47664774 macros : $ => [ ] ,
@@ -6154,3 +6162,4 @@ module.exports = grammar({
61546162 ] ,
61556163
61566164} ) ;
6165+
0 commit comments