Skip to content
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

Closed
wants to merge 6 commits into from
Closed

Add Scheme mode #1231

wants to merge 6 commits into from

Conversation

NalaGinrut
Copy link
Contributor

Modified from Lisp mode and tested well.

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"
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Member

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()[]{}"'+]*

Copy link
Contributor Author

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.

Copy link
Member

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.
@NalaGinrut
Copy link
Contributor Author

Scheme-mode looks fine now.
constant and keywords get right color.

@nightwing
Copy link
Member

Much better:)
Only two questions. Should if be highlighted in position-if-not? it looks like a one identifier
will it be good to somehow highlight '+-*? and maybe (name should be highlighted differently from name?

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": "#:[^ ]+"
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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?

@NalaGinrut
Copy link
Contributor Author

Actually, we don't parse '(name' for color usually. Just for keywords and 'define' and 'define-syntax'...
And yes, 'position-if-not?' is an complete identifier, so '-' shouldn't be a delimiter.
It's fixed now.
Thanks!

Fixed: 'minus' shouldn't be a delimiter
Fixed: '\t' shouldn't be included in keword-type
@NalaGinrut
Copy link
Contributor Author

I saw test throw wrong, but I'm not sure what's wrong.

@nightwing
Copy link
Member

tokens_scheme.json you've added is for old version of highlighter. run node mode/highlight_rules_test.js --gen again check if output is right and commit modified version of tokens_scheme.json

@NalaGinrut
Copy link
Contributor Author

OK, now passes all tests for me ;-)

nightwing added a commit that referenced this pull request Feb 6, 2013
@nightwing
Copy link
Member

Merged! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants