Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to parse nature terminated by ; #39

Open
guitorri opened this issue Feb 6, 2016 · 6 comments
Open

Fail to parse nature terminated by ; #39

guitorri opened this issue Feb 6, 2016 · 6 comments
Milestone

Comments

@guitorri
Copy link
Member

guitorri commented Feb 6, 2016

nature [name]; --> parser fails at ;

@guitorri guitorri added this to the 2.3.6 milestone Feb 16, 2016
@guitorri guitorri modified the milestones: 2.3.7, 2.3.6 Nov 19, 2016
@ngwood
Copy link
Contributor

ngwood commented Jun 15, 2021

An optional semicolon is also valid after an identifier in a discipline declaration. Both first appeared in VAMS-LRM-2.3.

@ngwood
Copy link
Contributor

ngwood commented Jan 3, 2022

This was actually easier to solve than I thought it would be.

diff --git a/admsXml/verilogaYacc.y.in b/admsXml/verilogaYacc.y.in
index e746d00..a8bee0c 100644
--- a/admsXml/verilogaYacc.y.in
+++ b/admsXml/verilogaYacc.y.in
@@ -140,6 +140,7 @@ R_s.admsParse
         ;
 R_discipline_member
         | tk_discipline R_discipline_name R_l.discipline_assignment tk_enddiscipline
+        | tk_discipline R_discipline_name ';' R_l.discipline_assignment tk_enddiscipline
           _ adms_admsmain_list_discipline_prepend_once_or_abort(root(),gDiscipline);
           _ gDiscipline=NULL;
         ;
@@ -175,6 +176,7 @@ R_discipline.naturename
 
 R_nature_member
         | tk_nature tk_ident R_l.nature_assignment tk_endnature
+        | tk_nature tk_ident ';' R_l.nature_assignment tk_endnature
           _ p_nature mynature=NULL;
           _ if(gNatureAccess) 
           _   mynature=adms_admsmain_list_nature_prepend_by_id_once_or_abort(root(),gNatureAccess);

ngwood added a commit to ngwood/ADMS that referenced this issue Jan 3, 2022
Version 2.3.0 of the Verilog-AMS Language Reference Manual introduced
an optional semicolon after a nature and discipline identifier in a
nature and discipline declaration, respectively; e.g.,

    nature identifier;
        ...
    endnature

and

    discipline identifier;
        ...
    enddiscipline

are now also legal syntax.

ADMS behaves the same as when the semicolon is absent.

This brings ADMS one step closer to being able to parse the most
recent Accellera standard disciplines header files.

This commit fixes GitHub issue Qucs#39.
felix-salfelder pushed a commit that referenced this issue Jan 4, 2022
Version 2.3.0 of the Verilog-AMS Language Reference Manual introduced
an optional semicolon after a nature and discipline identifier in a
nature and discipline declaration, respectively; e.g.,

    nature identifier;
        ...
    endnature

and

    discipline identifier;
        ...
    enddiscipline

are now also legal syntax.

ADMS behaves the same as when the semicolon is absent.

This brings ADMS one step closer to being able to parse the most
recent Accellera standard disciplines header files.

This commit fixes GitHub issue #39.
@ngwood
Copy link
Contributor

ngwood commented Jan 4, 2022

I am very embarrassed. This doesn't do what I thought it did! The code is getting assigned to the new rules, meaning the versions without the semicolons are not longer valid, which is certainly not what we want. I was able to get it to work by duplicating the code and putting it with each rule, but this is definitely not the best way of doing this. My limited knowledge of bison means I cannot suggest a better solution right now.

@felix-salfelder
Copy link
Member

felix-salfelder commented Jan 4, 2022 via email

@ngwood
Copy link
Contributor

ngwood commented Jan 4, 2022

Success!

diff --git a/admsXml/verilogaYacc.y.in b/admsXml/verilogaYacc.y.in
index a8bee0c..fc7b7a3 100644
--- a/admsXml/verilogaYacc.y.in
+++ b/admsXml/verilogaYacc.y.in
@@ -138,9 +138,12 @@ R_s.admsParse
         | R_discipline_member
         | R_nature_member
         ;
+R_optional_semicolon
+        |
+        | ';'
+        ;
 R_discipline_member
-        | tk_discipline R_discipline_name R_l.discipline_assignment tk_enddiscipline
-        | tk_discipline R_discipline_name ';' R_l.discipline_assignment tk_enddiscipline
+        | tk_discipline R_discipline_name R_optional_semicolon R_l.discipline_assignment tk_enddiscipline
           _ adms_admsmain_list_discipline_prepend_once_or_abort(root(),gDiscipline);
           _ gDiscipline=NULL;
         ;
@@ -175,8 +178,7 @@ R_discipline.naturename
         ;
 
 R_nature_member
-        | tk_nature tk_ident R_l.nature_assignment tk_endnature
-        | tk_nature tk_ident ';' R_l.nature_assignment tk_endnature
+        | tk_nature tk_ident R_optional_semicolon R_l.nature_assignment tk_endnature
           _ p_nature mynature=NULL;
           _ if(gNatureAccess) 
           _   mynature=adms_admsmain_list_nature_prepend_by_id_once_or_abort(root(),gNatureAccess);

My book on Flex/Bison is still in the post! I just wanted this fixed for the next release.

I created a new rule for an optional semicolon. Then I added this in place of the previous change.

I've tested with Accellera 2.2 (no semicolons) and Accellera 2.3.1 (semicolons) disciplines.vams files and they both work.

@felix-salfelder
Copy link
Member

felix-salfelder commented Jan 4, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants