-
Notifications
You must be signed in to change notification settings - Fork 5.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 Scheme mode #1231
Add Scheme mode #1231
Conversation
new file: lib/ace/mode/scheme.js new file: lib/ace/mode/scheme_highlight_rules.js
modified: demo/kitchen-sink/doclist.js modified: demo/kitchen-sink/modelist.js new file: lib/ace/mode/_test/tokens_scheme.json modified: lib/ace/mode/scheme_highlight_rules.js
}, | ||
{ | ||
"token" : keywordMapper, | ||
"regex" : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't match things like eq?
or #t
. Lisp mode had the same problem.
Which symbols can be included in scheme keywords?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think '?' '#' and ':' at least.
I've tested #f , it's fine, but I didn't test #t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything should I fix for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you forgot to add docs/scheme.scheme
to commit.
I see ["constant.language","#f"] in the test, but #f
is highlighted as ["punctuation.definition.constant.character.scheme", "constant.character.scheme"]
.
I'd suggest to move constant.language into it's own regexp and change keyword regexp to something like [a-zA-Z_$][^\s()[]{}"'+]*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the Lisp-mode was generated by some other format, and there're some strange things, like 0xFFLL which doesn't contained in Lisp/Scheme. And all keywords are missed in the parsing.
Maybe I need to rewrite part of the code rather than modify the keywords name, the Lisp-mode parser is a incorrect one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lisp mode highlighter was converted from textmate syntax, which highlights 0xFFLL as well.
It can be wrong, since probably not many people use textmate/sublime for lisp.
If you can, improve lisp and scheme modes, please do.
new file: demo/kitchen-sink/docs/scheme.scheme
modified: demo/kitchen-sink/docs/scheme.scheme * fix typo modified: lib/ace/mode/scheme_highlight_rules.js * remove '() since it's hard to parse and trivious for coloring. * keyword and constant coloring fine now.
Scheme-mode looks fine now. |
Much better:) something like this (foo bar baz
(+ '(a b c)))
(position-if-not:ss (+ 1 2) (more (+ 1 2) 3fe #F #f))
(#eeee:ee (+ 1 2) (more (+ 1 2) "
multiline string\n
") |
}, | ||
{ | ||
"token": ["punctuation.definition.constant.character.scheme", "constant.character.scheme"], | ||
"regex": "#:[^ ]+" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be #:\S+
, or tabs are ok here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"#:[^ ]+" won't match tabs I think, and I tested, seems ok.
If you know there's an exception, could you show me an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try /#:[^ ]+/.exec("#:s\ts")
maybe you've tested with soft tabs enabled and editor converted tabs to spaces?
Actually, we don't parse '(name' for color usually. Just for keywords and 'define' and 'define-syntax'... |
Fixed: 'minus' shouldn't be a delimiter Fixed: '\t' shouldn't be included in keword-type
I saw test throw wrong, but I'm not sure what's wrong. |
tokens_scheme.json you've added is for old version of highlighter. run |
OK, now passes all tests for me ;-) |
Merged! Thanks! |
Modified from Lisp mode and tested well.