-
Notifications
You must be signed in to change notification settings - Fork 743
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
Add Stan Lexer #1735
Add Stan Lexer #1735
Conversation
Looks like I didn't take into account functions being called inside other functions. Shouldn't be difficult to resolve (just add another scope for parentheses) but I will be away for a few days and will fix it then. |
Oh I didn't know this already existed! |
Just added the complex type and complex literals! |
Does this have the |
Ah, good catch on the array syntax—that's an easy fix. Can you point me to the spec / something describing the structure of |
No worries this is brand new. It should just highlight the same as .stan files but allow the ending to be .stanfunctions. The doc is at stan-dev/docs#434. vs-code put it in by just adding |
Cool, both easy changes—should be taken care of now. |
|
@spinkney The lexer should deal with all of those issues. Let me know if anything still looks weird to you. |
there's a typo on line 160 for |
also, @jgaeb how did you get/make that list of functions/distributions? |
It looks like the I constructed the list manually from the function reference. I thought a little bit if there might be a way to pull it out of the compiler code or something like that, but I'm not sure where the language's standard functions (as opposed to just the functions defined in the |
You can get all the signatures this way: clone the stan-docs repo then cd into it run the python script with the major and minor version numbers: python3 extract_function_sigs.py 2 28 then run a bash command to extract only the unique names cut -d ';' -f1 stan-functions-2_28.txt | uniq -u > stan_functions_list-2_28.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution @jgaeb ❤️ Warm welcome to the Rouge project. stan
is an interesting language and it would be great to add this support to Rouge. The PR looks great to me. I have added some minor suggestions for your consideration. Please let me know what you think 🙏🏼
Could you also please add stan
to the list of supported languages?
@tancnle Thank you very much for the suggestions! I made all of the changes you requested, including to preprocessor directives. |
Thank you for a delightful collaboration on this @jgaeb ❤️ Your work is greatly appreciated 🙏🏼 |
This PR adds a lexer for the Stan Bayesian data analysis language, based on the
C
andR
lexers. Stan files do not have an associated mime type, so I've left that attribute asnil
—please let me know if it should be a default text type or something like that. (I figured that would lead to it being chosen as a default parser for text files, but maybe that's not right.)