Open VladimirAlexiev opened 5 years ago
Wow, Semantic Bovinator seems really cool!(short howto) I just wrote a ShExC mode for highlight.js where I provided context-sensitivity (e.g. the shape expression content model allows shapeDecl, shapeRef, ...) but I couldn't find any way to say that the PREFIX keyword is followed by a namespace prefix and an IRI in that order. That said, I'm pretty much in an LSE mode right now so I'd be glad to pair with you on this. I was also about to start on an Ace module; maybe I can slow this whole process down by trying to dream up some meta-meta-language to help us create these meta-languages. Hmm, maybe it's called "BNF".
semantic
can provision a bunch of related functionalities which otherwise use different mechanisms (font-lock regexps, imenu regexp, beginning-of-defun definitions, etc).
https://www.gnu.org/software/emacs/manual/html_node/emacs/Semantic.html: "Most of the language-aware features in Emacs, such as Font Lock mode (see Font Lock), rely on rules of thumb (regexps and syntax tables) that usually give good results but are never completely exact".
Homepage: http://cedet.sourceforge.net/semantic.shtml. I think the up to date doc is at https://www.gnu.org/software/emacs/manual/html_mono/semantic.html. It mentions it can be used for the following functionalities, and I've added a comment
semantic
. This bug is about font-lock; also your question "how to make the keywords case-insensitive" falls hereimenu-generic-expression
imenu-list
but shows a separate frame, and collapses the tree by defaultmy-goto-function
does that using imenu
. It uses (thing-at-point 'symbol)
to pick up the word at point, which I fixed by setting the syntax of *+
to "punctuation"imenu
and is useful when you're in the middle of a long shape.
beginning-of-defun narrow-to-defun end-of-defun
respectively, and we don't have proper support for these in shexc-mode
I'm sure you'll get a kick of converting the g4 grammar to bovinator or wisent, and probably you can do it very quickly. I myself don't have time to grok this. But if you redo shexc-mode
to use semantic
, I'll figure out how to redo the imenu
support to use that. This would be the high-road way, and in principle the better way.
The low-road way would be to just fix the font-lock regexps.
wrote a ShExC mode for highlight.js
Great! Earlier I wrote highlight.js modules for Turtle and SPARQL. It wasn't properly merged, but now cygri and w3c (respec) want to use it, so I'll make an effort to do it. But they tell me the new organization is to have a repo per language, so I expect you'll also have to turn your PR into a separate repo: see https://github.com/highlightjs/highlight.js/pull/1553
I think that a value list like
should use
font-lock-function-name-face
on the PrefixedName, just like a bigger shape definition does, egBoth of them are shapes, no matter if they are small or large. (In emacs culture a "function" is any block of code that has its own identity). Barring full shex parsing in emacs (there is the "semantic bovinator" that can do that), we can recognize them by virtue of being at beginning of line.
The current definition:
<Account>
to PrefixedNamemyshapes:Account
, it won't be recognized as a "function"font-lock-type-face
for the prefix butfont-lock-constant-face
for the local name?font-lock-function-name-face
?To sum up:
font-lock-function-name-face
should be used on any PrefixedName or IRIREF at the beginning of a line without intervening SP.I've made a corresponding fix to imenu support: