-
Notifications
You must be signed in to change notification settings - Fork 31
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
Update ADMS parser to handle Accellera standard disciplines header file #103
Conversation
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.
Escaped identifier are denoted by a bachslash followed by any printable ASCII character and ending in whitespace. Currently ADMS cannot handle escaped identier. This prevents it from being able to parse the official Accellera standard disciplines header file. Fortunately, the offending escaped identifier "\logic " is equivalent to the simple identifier "logic", therefore we can simply tell the lexer to handle this cleanly. Note that the lexer doesn't technically provide full support for simple identifiers yet, as in Verilog-AMS they may contain embedded dollar signs. It's not great, but it's much better than not doing anything at all. That is to say, this adds functionality without breaking anything in the process.
On Mon, Jan 03, 2022 at 02:29:43PM -0800, Neal wrote:
* Allow semicolon after discipline/nature identifier
There might be neater way to specify an optional semicolon, but
nevermind (merged).
* Treat escaped identifiers as simple identifiers
I don't understand this.
|
There may well be a better way, but the change is innocuous and more importantly works. Regarding escaped identifiers, Verilog-AMS allows for variables with characters other than letters and underscores. Simple identifiers have letters, underscores and dollar signs (but not leading); no one should be using dollar signs though, so I wouldn't suggest we change this. Escaped identifiers all users to create variable names containing all of the other printable ASCII characters! There are four cases to point out; currently ADMS only handles one of them; my pull request handles a second one; the other two are not important:
Does this make sense? |
On Tue, Jan 04, 2022 at 02:38:10AM -0800, Neal wrote:
Escaped identifier with exotic ASCII characters:
e.g. "\my#value "
ADMS cannot currently parse this.
```
Does this make sense?
Thanks.
I think I get it now. Does "\my$value " in the input (still?) give a
sensible error message?
|
If I change
to
I get the same error as before.
This is because the bit between the opening Just to be safe, I also checked that I could still use escaped sequences inside of strings and everything is still working. This fix essentially says that if ADMS see something that looks like an escaped identifier, e.g., |
Note that the Verilog-AMS LRM say that we need to treat
is valid syntax. |
On Tue, Jan 04, 2022 at 04:22:25AM -0800, Neal wrote:
If I change
```
discipline \logic ;
```
to
```
discipline \log!c ;
```
I get the same error as before.
OK merged
thanks.
|
I take that back! The following example still doesn't work with ADMS. It still treats |
I should have used
Verilog-A:
Xyce C++:
|
Rather than just treating an escaped identifier as a unique simple identifier, we should convert the escaped identifier into the equivalent simple identifier; e.g., th Verilog-A snippet real \var ; var = 1.0; is supposed to be equivalent to real var; var = 1.0; Both will now produce C-style code similar to double var = 0.0; var = 1.0;
My previous attempt to allow for an optional semicolon after a nature and discipline identifier in a nature and discipline declaration, respectively, resulted in the semicolon now being mandatory. This commit actually makes it optional. I have tested this with Accellera's v2.2.0 and v2.3.1 standard headers as well as ADMS's v2.3.7 standard header.
Commit cbb960e seems to solve the issue of the optional semicolon after a nature and discipline identifier in a nature and discipline declaration, respectively. Maybe worth someone else testing? |
This pull request addresses two outstanding issues preventing ADMS from being able to parse the Accellera standard disciplines header file:
nature
terminated by;
#39.