Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:42
    MikePopoloski closed #505
  • 14:42
    MikePopoloski closed #505
  • 14:42

    MikePopoloski on master

    remove extra semicolons that tr… (compare)

  • Dec 03 20:17
    codecov[bot] commented #505
  • Dec 03 20:17
    codecov[bot] commented #505
  • Dec 03 19:27
    Kuree opened #505
  • Dec 03 19:27
    Kuree opened #505
  • Nov 30 14:22
    MikePopoloski commented #504
  • Nov 30 14:22
    MikePopoloski commented #504
  • Nov 30 07:21
    Practical-UVM-Step-By-Step opened #504
  • Nov 30 07:21
    Practical-UVM-Step-By-Step opened #504
  • Nov 24 02:22

    MikePopoloski on master

    Portability fixes for architect… (compare)

  • Nov 24 02:22
    MikePopoloski closed #503
  • Nov 24 02:22
    MikePopoloski closed #503
  • Nov 23 23:35
    codecov[bot] commented #503
  • Nov 23 23:35
    codecov[bot] commented #503
  • Nov 23 22:41
    jesec opened #503
  • Nov 23 22:41
    jesec opened #503
  • Nov 23 21:20
    MikePopoloski commented #502
  • Nov 23 21:20
    MikePopoloski commented #502
Julien FAUCHER
@suzizecat
@DeeeeLAN if you want to get to setting a language server (and are a bit versed in python) you might want to check pygls which will handle all of the backend for you ;)
1 reply
Michael Popoloski
@MikePopoloski
I'm not aware of any language server projects using slang -- it sounds like a great use though
Julien FAUCHER
@suzizecat
If you want to make a language server though, you might be lacking the position of each symbol in the AST with regard to the files.
As in, you have a list of all symbols and all binding, but you actually don't know where they are in the files.
Would that be possible to add to the AST output (or already present in some output I don't know about ?)
Michael Popoloski
@MikePopoloski
it's not in the JSON output right now but could be added
it's certainly available in the AST data structures though, so if your language server was compiled as a C binary then it would be easy to expose
I'd be wary of trying to use the JSON output as a robust interchange format just because of how memory inefficient it is; it would probably make the project unusable for real-world sized designs
DeeeeLAN
@DeeeeLAN
So would it make sense to use the compiled slang binary in the language server, or would it be better to pull in the code itself and use it as an API that gets compiled into a more server-like tool that runs persistently? I assume if I went the pygls route I would want to (or have to) just use the compiled tool
10 replies
Does slang maintain any sort of state between calls? I thought I remember seeing something about incremental compiles in the docs, but I don't see anything generated in the directory after invoking the tool.
Michael Popoloski
@MikePopoloski
no, there's no state saved between calls at the moment
certainly at some point incremental compilation should be considered but I have not yet gotten to that
DeeeeLAN
@DeeeeLAN
No problem, I will make due with what we have. It is possible the language server code will handle some of that state anyway.
DeeeeLAN
@DeeeeLAN
Do you have the "API" functions grouped together in the code at all? I haven't looked through it extensively yet, but I am wondering if the functions that would be worth exposing to an end-user are spread out or not. I assume there are plenty of internal functions that will not need to be exposed.
Michael Popoloski
@MikePopoloski
I think it depends on what people want to do with it. Most of the library components are designed to be usable somewhat independently, but if you don't need them then you don't need to expose them. For example, the Lexer / Preprocessor / Parser classes are usable on their own but most people can probably just use SyntaxTree which wraps that all up into a simpler interface
DeeeeLAN
@DeeeeLAN
Okay. I am mostly just looking for what would be a good starting point. It won't be hard to add more over time, but there is enough there that choosing a subset as a proof of concept is helpful.
I will start with SyntaxTree, that sounds like a good balance of size and capability.
Michael Popoloski
@MikePopoloski
you can also look at the pieces the driver's main.cpp uses, as those are the major entry points for various tasks
DeeeeLAN
@DeeeeLAN
Okay thanks, I will check there too.
Shoreshen
@Shoreshen
Hi, may I simply ask how to get the parent expression of an expression....
Michael Popoloski
@MikePopoloski
Expression objects don't track a parent pointer to save space, since you can't get a hold of such an object without first going through its parent anyway
your code can remember the parent when it descends into the child object
Shoreshen
@Shoreshen
thx a lot~~
DeeeeLAN
@DeeeeLAN
Is it possible to generate Diagnositcs.h separately from the rest of the build process? Trying to import the headers is frustrating when that file doesn't stick around
5 replies
DeeeeLAN
@DeeeeLAN
Is #include "slang/util/Util.h" necessary in Enum.h?
Michael Popoloski
@MikePopoloski
I think currently yes, it is
why do you ask?
DeeeeLAN
@DeeeeLAN
I was getting a weird include error since there is a circular dependency between those two errors when trying out a python package, but I think I got it resolved. I am currently attempting to use cppyy. Swig and pybind11 were both kind of busts, they weren't very compatible with some of the newer C++ constructs like shared_ptr and string_view. But cppyy is handling them just fine once I got everything imported properly, and I have actually instantiated a SyntaxTree in the python interpreter!
Now I am just trying to figure out how to actually use the API
DeeeeLAN
@DeeeeLAN

Okay, I believe I have everything working, but I am having a hard time wrapping my head around how to actually use the library. Here is how I would expect the flow to go: Get text from the user when they open or edit a file -> Load it into a SyntaxTree -> Grab the diagnostics -> Return any errors or warnings so the editor can display them in the appropriate location.

Is that what you would expect to have happen? I am able to load code into a syntaxtree without issue, but when I load a file, the object's diagnostics list is empty. When I load the same code using fromText, the errors I would expect to see show up in the list.

How can I dump the diagnostics in a usable format? JSON would probably be easiest and I have seen it mentioned in the docs once or twice, but I can't figure that one out.

20 replies
DeeeeLAN
@DeeeeLAN
What are the types we should be using for the SyntaxVisitor template classes?
Michael Popoloski
@MikePopoloski
The SyntaxVisitor visits node types derived from SyntaxNode, so anything that shows up in AllSyntax.h
the templated nature won't translate well to Python I think
you can see it in use from C++ in the rewriter example tool
You would probably need to write a derived class that is more easily consumed from Python
possibly generating it from syntax_gen.py
DeeeeLAN
@DeeeeLAN
cppyy actually has support for templates, but I am still trying to figure out how to make it work, the documentation isn't super verbose with examples. But if I can't get it to work then yes maybe creating a specific subclass in c++ first would make sense, good idea.
DeeeeLAN
@DeeeeLAN
Would I want to create a new diagnostic engine and client and compilation object for each syntax tree? Or what is the best way to handle that? I believe the LSP client will send new code on each change, so I imagine that will get loaded in as a fresh syntaxTree each time.
Michael Popoloski
@MikePopoloski
You should have a separate Compilation object for each attempt at compiling the complete design
a complete design might involve more than one syntax tree, so the Compilation supports adding more than one tree to it
but you can't remove trees, or add a new tree once you've finalized the design and started inspecting it (including getting diagnostics) so at that point you need to throw it out and build a new one
for a language server you probably want to store all of the syntax trees and not reparse them unless they change, but create a new Compilation object each time something changes
the DiagnosticEngine can probably be reused, you can call clearCounts on it to clear out state specific to a compilation run
it's not a very expensive object to build though so it probably doesn't matter much either way
Alex Wilson
@alwilson
I want to see the variables and constraints in a class with the --ast-json flag, but the resulting json doesn't appear to list the variables or constraints, just the name of the class. I tried a few other snippets of SV and those appear to show up in the json file. Constraints and classes appear to be supported. I assume I must be mis-understanding what that flag does or what I'm looking for is something different.
Michael Popoloski
@MikePopoloski
oh huh, looks like a bug that classes are not visited when dumping JSON
I can fix that
Alex Wilson
@alwilson

I can fix that

Oh awesome! Pulled your changes and I can see the variables and constraints now. I was thinking about some constraint problems recently and wished I could translate SV constraints into SMT-LIB format to explore in other tools.

supalshah75
@supalshah75
I am quite new to this. So I have silly question. Can I install slang as a vim plugin? This way, whenever I type any SV code in GVIM, it will show me any error dynamically...?
Michael Popoloski
@MikePopoloski
not out of the box, slang is a library that could be used to build such a plugin
@DeeeeLAN is working on such a language server, not necessarily targeted at vim but could probably be used with it
DeeeeLAN
@DeeeeLAN
Eventually I will add a vim client but it will be down the road a bit, I need to get the server working well first, so I am only working on one client at the moment.