> From: bill lam
>
> Nice addition!
>
> BTW I guess the kludge by defining an extra id such as
>
> <context id="comment1" style-ref="comment" end-at-line-end="true">
>
> can be replaced by a better method that reuse existing id, but I'm
> inexperience in this matter.
Me too, but I think I figured it out.
The following tidies the specification up a bit, as well as more closely
matching the behaviour of the J parser.
Still room for improvement though!!
<?xml version="1.0" encoding="UTF-8"?>
<!-- Authors: Jsoftware -->
<language id="j" _name="J" version="2.0" _section="Sources">
<metadata>
<property name="mimetypes">text/x-j;text/x-jsrc</property>
<property name="globs">*.ijs</property>
<property name="line-comment-start">NB\.</property>
</metadata>
<styles>
<style id="comment" _name="Comment" />
<style id="note" _name="Multiline Comment" />
<style id="string" _name="String" />
<style id="parens" _name="Parens" />
<style id="control" _name="Control" />
<style id="global" _name="Global" />
<style id="local" _name="Local" />
<style id="primitive" _name="Primitive" />
<style id="number" _name="Number" />
<style id="noundef" _name="Noun Definition" />
</styles>
<definitions>
<!-- problems/shortcomings
perhaps control should be done as keywords
not sure how to include suffix
primitives other than =: =.
highlight missing single quotes would be nice
parens inside expdef
matched vs unmatched parens coloring
marking matching paren might be nice but how to
do () and not {} and [] -->
<!-- NB. -->
<context id="comment" style-ref="comment" end-at-line-end="true">
<start>\%[NB\.</start>
</context>
<!-- 'abc' -->
<context id="string" style-ref="string" end-at-line-end="true">
<start>L?'</start><end>'</end>
</context>
<!-- 2.34 -->
<context id="number" style-ref="number">
<match extended="true">\%[[_0-9][_0-9\.a-zA-Z]*\%]</match>
</context>
<!-- () -->
<context id="parens" style-ref="parens">
<match extended="true">[\(\)]</match>
</context>
<define-regex id="valid-name">[a-zA-Z][a-zA-Z0-9_]*\.</define-regex>
<define-regex id="close-expdef">^\s*\)\s*$</define-regex>
<!-- explicit definition -->
<context id="expdef" style-inside="true">
<start>\%[(([1-4]|13)\s+:\s*0)|((adverb|conjunction|verb|monad|dyad)\s+define)\%]</start>
<end>\%{close-expdef}</end>
<include>
<context ref="comment"/>
<context ref="string"/>
<context ref="number"/>
<context id="control" style-ref="control">
<match extended="true">
\%[(assert\.|break\.|continue\.|for\.|do\.|end\.|if\.|
else\.|elseif\.|return\.|select\.|case\.|fcase\.|
throw\.|try\.|catch\.|catchd\.|catcht\.|while\.|whilst\.|
for_\%{valid-name}|
goto_\%{valid-name}|
label_\%{valid-name})
</match>
</context>
</include>
</context>
<!-- explicit noun definition -->
<context id="noundef" style-ref="noundef" style-inside="true">
<start>\%[(0\s+:\s*0|noun\s+define)\%].*$</start>
<end>\%{close-expdef}</end>
</context>
<!-- Note or multiline comment -->
<context id="note" style-ref="comment" style-inside="true">
<start>\%[Note\%].*$</start>
<end>\%{close-expdef}</end>
</context>
<!-- =: -->
<context id="global" style-ref="global">
<match>=:</match>
</context>
<!-- =\. -->
<context id="local" style-ref="local">
<match>=.</match>
</context>
<context id="j">
<include>
<context ref="comment"/>
<context ref="string"/>
<context ref="expdef"/>
<context ref="noundef"/>
<context ref="note"/>
<context ref="number"/>
<context ref="global"/>
<context ref="local"/>
</include>
</context>
</definitions>
</language>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm