7

Is there a Common Lisp syntax highlighting .xshd file for use with ICSharpCode.TextEditor? I haven't been able to find one on google, and the format for writing syntax highlighting specification files is so wretchedly documented that I can't make a very good one myself. I can highlight basic keywords, but not much more.

It needs to have the following:

  • Highlight common lisp keywords, such as list, dolist, read-line. lambda, etc.
  • Syntax highlighting for the words after defun, defmacro, defvar, etc, such that in the text (defun a () ...), a is highlighted. It doesn't have to be complete because I can add more, just one or two is fine to show how it's done.
  • Highlight symbols like :a
  • Highlight quoted lists in both backquote and single quote form, and "unhighlight" escaped forms within quoted lists (escaped by ,, @,, etc)
  • Highlight the name of a function being called. For example, in the text (a b c), a needs to be highlighted
  • Optional: anything else that I missed that would be helpful (I'm new to lisp so I don't know everything that can be highlighted)

Does anyone know where to get a Common Lisp syntax highlighting file for ICSharpCode.TextEditor that has these features?

Seth Carnegie
  • 73,875
  • 22
  • 181
  • 249
  • 1
    'Ping' me if you get an answer, I would like this too for Scheme :) – leppie Sep 02 '11 at 06:46
  • @leppie I doubt I will get an answer but I'm gonna set up a bounty pretty quickly. – Seth Carnegie Sep 02 '11 at 12:59
  • What version of ICSharpCode.TextEditor are you using? I can perhaps look. – leppie Sep 02 '11 at 13:00
  • @leppie I have tried 3.2 and that latest version (4.something). If you do find one, ill be happy to award you the bounty. – Seth Carnegie Sep 02 '11 at 13:04
  • The code should be relativly simple, I have made ones for both xacc.ide and VS2008 for IronScheme in the past. – leppie Sep 02 '11 at 13:09
  • @leppie the problem is I can't find any specification of the XML format it requires. The most innocuous examples from the internet (and even the Sharpdev website) cause the code to throw that exception. And the "complete list" has about 3 on it. – Seth Carnegie Sep 02 '11 at 13:14
  • I was looking earlier, basically going to start off with the XML-Mode.xhsd. – leppie Sep 02 '11 at 17:51
  • I made a little start, should be good enough for you I hope :) – leppie Sep 02 '11 at 19:05

1 Answers1

3

Here is a start for a Scheme highlighter. Not very fancy, but shows how recursion works with the rulesets.

<SyntaxDefinition name="Scheme" extensions=".sls;.sps;.ss;.scm" 
     xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
  <Color foreground="Green" name="Comment" />
  <Color foreground="Blue" name="Syntax" />
  <Color foreground="Blue" name="Library Syntax" />
  <Color foreground="Blue" name="Auxilliary Syntax" />
  <Color foreground="DarkMagenta" name="Procedure" />

  <RuleSet>
    <Import ruleSet="Expression"/>
  </RuleSet>

    <RuleSet name="Expression">
        <Span color="Comment" multiline="false">
            <Begin>;</Begin>
        </Span>
    <Span color="Comment" multiline="true" >
      <Begin>\#\|</Begin>
      <End>\|\#</End>
    </Span>
    <Span ruleSet="Expression" multiline="true" >
      <Begin fontWeight="bold">\(</Begin>
      <End fontWeight="bold">\)</End>
    </Span>
    <Span  ruleSet="Expression" multiline="true">
      <Begin fontWeight="bold">\#\(</Begin>
      <End fontWeight="bold">\)</End>
    </Span>

    <Keywords color="Library Syntax">
      <Word>import</Word>
      <Word>export</Word>
      <Word>library</Word>
    </Keywords>

    <Keywords color="Syntax">
      <Word>define</Word>
      <Word>set!</Word>
      <Word>lambda</Word>
      <Word>begin</Word>
      <Word>if</Word>
      <Word>cond</Word>
      <Word>let</Word>
      <Word>letrec</Word>
    </Keywords>

    <Keywords color="Auxilliary Syntax">
      <Word>else</Word>
    </Keywords>

    <Keywords color="Procedure">
      <Word>map</Word>
      <Word>cons</Word>
      <Word>car</Word>
    </Keywords>

  </RuleSet>

</SyntaxDefinition>
leppie
  • 115,091
  • 17
  • 196
  • 297
  • That's about what I had, starting from the Ruby .xshd. Do you know how to make it highlight the first word in parentheses? Like in `(a b c)` `a` would be highlighted. – Seth Carnegie Sep 02 '11 at 19:06
  • in the Ruby one, it had `(` which makes the word before a `(` blue. I have tried `MarkNext` but it doesn't work. Can you think of anything? – Seth Carnegie Sep 02 '11 at 19:08
  • Using positive lookbehind assertion regex in a Rule should work, but it doesnt :( – leppie Sep 02 '11 at 19:35
  • How do you use regexes? Do you have to tell it they're regexes rather than plain text? – Seth Carnegie Sep 02 '11 at 19:36
  • Then, could you write a rule to escape things inside a quoted list? For instance, in `\`(a b @,c d e @,(f g h))`, the whole thing should be highlighted, except for `c` and `(f g h)`. – Seth Carnegie Sep 02 '11 at 19:54
  • 1
    Even though this isn't exactly what I needed, thanks for trying, have 50 rep :) – Seth Carnegie Sep 11 '11 at 14:17