We are looking to add FEEL, a language introduce by an OMG DMN specification, to CodeMiror. I started looking at how to define new language and I was wondering if there is a mapping available somewhere between eBNF (into which the whole syntax of FEEL is described) and the system used by CodeMirror?
I’m not aware of such a thing, though it would definitely be theoretically possible (and probably not even very hard) to implement. I’ve been hoping someone puts together a good open-source implementation, but no luck so far.
I wasn’t even looking at an automated mapping but more more like a guide how how to “translate” ebnf to CodeMirror parser.
(If you don’t need a ‘deep’ parse, you can get away with just implementing a tokenizer, plus maybe some simple rules for tracking context for indentation, which is what most modes do.)
Thanks Marijn for those insights.
The biggest difficulty of FEEL is that it allows space in variable and function name which makes me doubt it is LL(1). I have to look forward until I find a match to one of the existing variables to know it is a variable. They even allow language keyword (such as if, for) to show un in those variable names, but not at the beginning. So in FEEL something like that could be valid, assuming “Gift for teacher” is a variable in the context.
if Gift for teacher = "apple" then
return "grocery store"
So the produced highlight in that post isn’t that bad, except that “for” should not be black as it is not a keyword in that case.