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

Add missing keywords to LLVM lexer #1505

Merged
merged 5 commits into from Apr 20, 2020

Conversation

pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Apr 18, 2020

There are a number of keywords missing from the LLVM lexer. This PR adds them to the appropriate group.

It fixes #1502.

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Apr 18, 2020
@pyrmont pyrmont self-assigned this Apr 18, 2020
@pyrmont
Copy link
Contributor Author

pyrmont commented Apr 18, 2020

@guiferviz Thanks for the bug report. I had a look through the page you linked and I couldn't find the following keywords that you extracted from the Pygments lexer. Are these mistakes?

avr_intrcc
avr_signalcc
deplibs
function
ghccc
hhvm_ccc
hhvmcc
inline
intel_ocl_bicc
msp430_intrcc
none
spir_func
spir_kernel
unknown
variable
win64cc
x86_64_sysvcc
x86_intrcc
x86_regcallcc
x86_thiscallcc
x86_vectorcallcc

@guiferviz
Copy link

@pyrmont Thanks for your work.
You mean the link of the LLVM LangRef, right?

Unfortunately I'm not an LLVM expert and I can't tell you 100% sure what all those keywords are for.
I know some of them are calling conventions, very specific to the machine you're generating the code for. That's why I think they are not in the LLVM LangRef. LLVM's documentation is not particularly complete. It is a documentation that is made for people who already know how to use the tool 🤣

I've found this code that generates LLVM IR code (the code we are trying to highlight).

Also, if you search for those words in the LLVM repository maybe you get a *.ll file with those keywords. *.ll is the extension of LLVM IR code. For example, in this link you will see all the files with x86_vectorcallcc in the LLVM repository.
I didn't check all of them though.

We can:

  • Rely on Pygments keywords.
  • Check if all the keywords are in a *.ll file in the LLVM repository.
  • Wait for someone to open a new bug :)

@guiferviz
Copy link

Maybe I write to you so fast... I've just found this lexer. It's the official LLVM lexer for reading *.ll files!
It contains all those keywords.

@pyrmont
Copy link
Contributor Author

pyrmont commented Apr 19, 2020

@guiferviz Thanks for finding that lexer file. I wrote a Rake task that will automatically generate the keywords and put them into a file that can then be loaded as needed. How does it look?

@guiferviz
Copy link

It looks terrific! Now we are sure that it contains all the keywords.
I can't do a technical review of the code because I just learned what Rack is, but I checked that the generated keywords are in the Pygements lexer. We now even have 21 more keywords than the Pygments lexer!
Thank you so much!

@pyrmont pyrmont merged commit 42637b4 into rouge-ruby:master Apr 20, 2020
@pyrmont pyrmont deleted the bugfix.llvm-missing-keywords branch April 20, 2020 02:36
@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Apr 20, 2020
@pyrmont
Copy link
Contributor Author

pyrmont commented Apr 20, 2020

@guiferviz Thanks for your help on this! This will be part of the next version of Rouge: v3.19.0. That's scheduled for release on Tuesday 12 May. Thanks again!

@guiferviz
Copy link

@pyrmont Thanks for your time!

mattt pushed a commit to NSHipster/rouge that referenced this pull request May 21, 2020
The list of keywords that is recognised in the current LLVM lexer is
not as complete as in some other syntax highlighting libraries (such as 
Pygments). This commit adds a Rake task that checks a source file in
the public LLVM repo and generates a keyword file that is loaded on
request when the LLVM lexer is used.
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

Successfully merging this pull request may close these issues.

Missing keywords in LLVM lexer
2 participants