-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 support for the Racket lisp #1513
Comments
I think the simplest implementation is just another alias for the current Otherwise, simpler is generally going to better if it's "good enough". We're not a parser, so perfection isn't the goal. Would def be interested in a PR if you want to give it a shot. |
Isn't racket just scheme with brackets in some places? it should work the same as for scheme syntax. If there is something missing in scheme I would add that to that language and use scheme for racket. Or if aliases are possible use racket as aliast for scheme. |
Well, mostly it is. There are some minor differences, for example the aforementioned braces and brackets, or syntax identifiers, such as Now that you've reminded me of this old issue, I think duplicating the scheme file and making some changes to it (i.e. creating a whole new language, not just aliasing to the old one) would be the best course of action. Or is there some downside to it that I'm missing? I'd rather not break (=ammend) the scheme syntax highlighting. |
Hmmm if it's really just brackets and very minor differences, couldn't we just write a little something with go through all scheme patterns and replaces all Like this:The following requires that if a character class in scheme contains both "(" and ")", they have to be at the beginning of the character class. E.g. Prism.languages.racket = Prism.languages.extend('scheme', {});
Prism.languages.DFS(Prism.languages.racket, function (key, value) {
if (Prism.util.type(value) === "RegExp") {
var source = value.source;
// replace lone "(" and ")" characters with a character class "[({[]" and "[)}\]]"
source = source.replace(/((?:^|[^\\])(?:\\{2})*)\\\(/g, "$1[({\\[]");
source = source.replace(/((?:^|[^\\])(?:\\{2})*)\\\)/g, "$1[)}\\]]");
// replace "()" in character classes with "(){}[\]"
source = source.replace(/((?:^|[^\\])(?:\\{2})*\[\^?)\(\)/g, "$1(){}[\\]");
this[key] = RegExp(source, value.flags);
}
});
Prism.languages.insertBefore('racket', 'some-token', {
// some tokens
}); Not tested in any way but I'm optimistic ;) |
I want to add something to the discussion. Consider this pretty good book about Scheme The Scheme Programming Language 4ed by R. Kent Dybvig (https://www.scheme.com/tspl4/further.html#./further:h1) It have mixed parenthesis and brackets I think that scheme should have those to be the same when there is It would be nice if Scheme syntax just behave the same if everywere are brackets instead of parenthesis, at Scheme FAQ there is written that R5RS spec say that brackets are reserved characters but don't say what they should do and that some scheme use that character. http://community.schemewiki.org/?scheme-faq-language#H-yoyi82 So basically if Prism should work with any Scheme implementation it should use brackets as well as parenthesis. |
Racket is basically like Scheme when it comes to syntax highlighting, it only has some minor differences. I have made a complete Racket grammar (link), but I think just copying the Scheme one and adding support for
racket
language will be cleaner and function just as well.If you want me I can open a PR, just need to decide if we want the complex grammar or rather the simple one.
EDIT: Updated the link to point to the renamed repo.
The text was updated successfully, but these errors were encountered: