Commit Graph
4 Commits
Author SHA1 Message Date
Chandler Carruth b4d4f5423d [highlightjs] Add virtual method keywords. (#1377)
This also tidies up the keyword detection for classes a bit so we won't
highlight bizarre things like `allyourbase class`, or `base classy` etc.
2022-07-10 00:05:51 -07:00
Chandler Carruth 0ed6600615 [highlightjs] Add struct literal support. (#1370)
This is especially tricky, as there doesn't seem to be support for
indirect recursion, only direct recursion. As a consequence, its
important to have a single recursive pattern that handles all the
balanced delimiters in an expression context.

I've tried to add some comments to help explain this.

I also tried to add something to check that the balanced delimiters
*matched* and re-synchronize if they don't, but that didn't end up
working. I also tried various things to force re-synchronizing more
rapidly in the face of unbalanced delimiters but they all produced
strictly worse highlighting than what I have here. I will try again in
a follow-up commit, but for now this will work well enough for slides.
2022-07-09 20:05:38 -07:00
Chandler Carruthandjosh11b e2c5a7ef68 [highlightjs] Add support for var and let. (#1366)
This required reworking how `=` and `;` were handled as well as more
general surgery on patterns.

This looks for initializers at the top level of parameters and at the
end of `var` or `let` declarations. It supports fancy nested `var`
patterns within `let` declarations, etc.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2022-07-09 19:40:09 -07:00
Chandler Carruthandjosh11b 1f075a1348 Add a language definition for highlight.js. (#1365)
There are still quite a few parts of the language that need support
here, but I've tried to piece together a decent foundation and address
some of the particular challenges with building a good framework that
handles some of the complex parts of the grammar such as successfully
identifying the declared names in even reasonably complex patterns.

I've included a pretty ad-hoc test file I've been using to make sure it
works. If folks want a particular testing strategy for this, happy to
explore building one although I don't really know what it should look
like.

Also happy to have suggestions about where this should live in the
repository. No strong opinions there. Hoping to eventually add
a `tmLanguage` file and any other syntax highlighting systems that are
useful.

I'll next be finishing off other parts of the language, and then I plan
to use this as a component of our presentation material, which is why
I'm focused on Highlight.js -- that's the system used most widely in
HTML-based presentation infrastructure like Reveal.js.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2022-07-07 23:20:29 -07:00