Rob Rohan's Lab

Syntax Files

The syntax files Afae uses are based on the JEdit format or Mode files. Afae does not support the full rule set that JEdit does.

PROPS

The root element of the mode files is MODE. Within MODE the first element should be PROPS. You can define several PROPERTIES in the PRPOS section, but only commentStart and commentEnd are used at present.

<MODE>
    <PROPS>
        <PROPERTY NAME="commentStart" VALUE="=begin" />
        <PROPERTY NAME="commentEnd" VALUE="=end" />
    <PROPS>
    ...

These two properties control what characters are used when you use "Wrap text in a comment" (ctrl+c ctrl+k on the Mac).

RULES

After the PROPS section there are one or more RULES sections. The RULES sections describe how to colorize the document. For example the following rule has a SPAN command to do HTML style comments:

...
<PROPS>

<RULES IGNORE_CASE="TRUE">
    <SPAN TYPE="COMMENT1">
        <BEGIN>&lt;!--</BEGIN>
        <END>--&gt;</END>
    </SPAN>

    ...

RULES can take several attribute parameters they are the following:

SET : [NAME] : Name used when referring to the rule from commands
HIGHLIGHT_DIGITS : [TRUE or FALSE] : Should this rule highlight digits
IGNORE_CASE : [TRUE or FALSE] : Should this rule ignore case
ESCAPE : [SINGLE CHAR] : A character that allows the rule to be escaped. For example \ in a C string "This is a \"quote\" in a quote"
DEFAULT : [PARTITION NAME] : The default color to make the partition, or blank for plain text

There are several commands that can be put into RULES. Each command will take at least a TYPE attribute that says what partition to use when the command is satisified. Here are the supported commands in Afae, and at the bottom of the page are the supported partition types.

SEQ

The SEQ command allows you to define a group of characters for partitioning.

<SEQ TYPE="OPERATOR">:</SEQ>

That defines the colon character to get the OPERATOR partition type.

AT_LINE_START : [TRUE or FALSE] :
* AT_WHITESPACE_END : [TRUE or FALSE] :
* AT_WORD_START : [TRUE or FALSE] :
TYPE
DELEGATE

SPAN

The span rule allows you to define an area to apply a partition to. For example:

<SPAN TYPE="COMMENT1">
    <BEGIN>(</BEGIN>
    <END>)</END>
</SPAN>

Defines an area between (), and says to apply the COMMENT1 partition type to the area. SPAN can also use a DELEGATE attribute to call a named RULE somewhere else in the file. When you do this the TYPE must be set to null. For example:

<SPAN TYPE="NULL" DELEGATE="LITERAL">
    <BEGIN>(</BEGIN>
    <END>)</END>
</SPAN>
...
<RULES SET="LITERAL" DEFAULT="LITERAL1" ESCAPE="\">
    <SEQ TYPE="OPERATOR">:</SEQ>
</RULES>

That SPAN command uses the commands within the LITERAL rule set to do it's partitioning. It is important to note that Afae does not allow nested rule set jumping. Meaning that if a SPAN delegates to a RULES set, that RULES set cannot have a SPAN that also delegates to a different RULE set.

The SPAN command can take the following attributes:

TYPE : [PARTITION TYPE] 
AT_LINE_START : [TRUE or FALSE] : The span can only start at the beginning of a line
EXCLUDE_MATCH : [TRUE or FALSE] : The span should or should not include the markers in the coloring
NO_LINE_BREAK : [TRUE or FALSE] : Are newlines allowed with in the span
NO_WORD_BREAK : [TRUE or FALSE] : Are word breaks allowed within the span (only a space is a word break at present)
DELEGATE : [TRUE or FALSE] : Forward to another defined rule set
IGNORE_CASE : [TRUE or FALSE] : Should this rule ignore case (overrides the RULE setting)
ESCAPE : A string of chars that can be used to keep the span from ending (a list with no delimiters). A single char could be \ in a C string for example.

MARK_FOLLOWING

'MARK_FOLLOWING has been deprecated and should not be used. See SPAN_REGEXP'

'Warning' MARK_FOLLOWING is buggy in the current release (0.9.98). It can cause the editor to fail to start and result in an error like:

java.lang.IllegalArgumentException: Argument not valid
at org.eclipse.swt.SWT.error(SWT.java:3358) at 
org.eclipse.swt.SWT.error(SWT.java:3297) at 
org.eclipse.swt.SWT.error(SWT.java:3268) at
...

The only workaround at present is to not use the tag

The mark following command marks an area after the defined text. For example:

<MARK_FOLLOWING TYPE="KEYWORD2" EXCLUDE_MATCH="FALSE">#</MARK_FOLLOWING>

would use the KEWORD2 partition on everything after the # symbol.

* AT_LINE_START : [TRUE or FALSE] :
* AT_WHITESPACE_END : [TRUE or FALSE] :
EXCLUDE_MATCH : [TRUE or FALSE] :
* AT_WORD_START : [TRUE or FALSE] :
TYPE : [NAME]
DELEGATE : [NAME]

MARK_PREVIOUS

'MARKPREVIOUS has been deprecated and should not be used. See SPANREGEXP'

<MARK_PREVIOUS TYPE="LABEL" EXCLUDE_MATCH="TRUE" AT_LINE_START="TRUE">:</MARK_PREVIOUS>


* AT_LINE_START : [TRUE or FALSE] :
* AT_WHITESPACE_END : [TRUE or FALSE] :
EXCLUDE_MATCH : [TRUE or FALSE] :
* AT_WORD_START : [TRUE or FALSE] :
TYPE : [NAME]
DELEGATE : [NAME]

EOL_SPAN

<EOL_SPAN TYPE="KEYWORD2">#</EOL_SPAN>


TYPE : [PARTITION TYPE] 
AT_LINE_START : [TRUE or FALSE] : The span can only start at the beginning of a line
* EXCLUDE_MATCH : [TRUE or FALSE] : The span should or should not include the markers in the coloring
DELEGATE : Forward to another defined rule set

SPAN_REGEXP

Regular expression rule. The regular expression must be anchored at both sides. Here it is anchored to the start of the string and ends at the first white space outside of a > symbol. The IGNORE_CASE attribute is used only on the END part of the span.

The HASH_CHAR attribute is another anchor marker and is required. It is the single character that will cause this rule to fire. The character is repeated in the actual regular expression as seen in the example below. HASH_CHAR can take a string - each char in the string should be a char that fires off the rule. There can only be one SPAN_REGEXP HASH_CHAR per Rule set - meaning you can't have 2 SPAN_REGEXP that have the same HASH_CHAR value.

EXCLUDE_MATCH will keep the END match from color coding. This is useful when the END is being used as a stabilizing anchor.

<SPAN_REGEXP HASH_CHAR="&lt;" TYPE="LITERAL1" AT_LINE_START="FALSE" 
    EXCLUDE_MATCH="FALSE" NO_WORD_BREAK="FALSE" IGNORE_CASE="TRUE">
    <BEGIN>^(&lt;[sS][cC][rR][iI][pP][tT] .*&gt;)\s</BEGIN>
    <END>&lt;/script&gt;</END>
</SPAN_REGEXP>


TYPE : [PARTITION TYPE] 
AT_LINE_START : [TRUE or FALSE] : The span can only start at the beginning of a line
EXCLUDE_MATCH : [TRUE or FALSE] : The span should or should not include the markers in the coloring
NO_LINE_BREAK : [TRUE or FALSE] : Are newlines allowed with in the span
NO_WORD_BREAK : [TRUE or FALSE] : Are word breaks allowed within the span (only a space is a word break at present)
DELEGATE : [TRUE or FALSE] : Forward to another defined rule set
IGNORE_CASE : [TRUE or FALSE] : Should this rule ignore case (overrides the RULE setting)
ESCAPE : A string of chars that can be used to keep the span from ending (a list with no delimiters). A single char could be \ in a C string for example.

KEYWORDS

...
<KEYWORDS IGNORE_CASE="FALSE">
    <KEYWORD1>auto</KEYWORD1>
    <KEYWORD2>asm</KEYWORD2>
    <KEYWORD3>char</KEYWORD3>   
    <LITERAL2>true</LITERAL2>
<KEYWORDS>
...

PARTITION TYPES

NULL
COMMENT1
COMMENT2
LITERAL1
LITERAL2
LABEL
KEYWORD1
KEYWORD2
KEYWORD3
FUNCTION
MARKUP
OPERATOR
DIGIT
METHOD

* = Not fully implemented