alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

jEdit example source code file (cplusplus.xml)

This example jEdit source code file (cplusplus.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - jEdit tags/keywords

delegate, delegate, import, keyword1, keyword1, keyword3, keyword3, markup, markup, name, property, rules, type, value

The jEdit cplusplus.xml source code

<?xml version="1.0"?>

<!DOCTYPE MODE SYSTEM "xmode.dtd">

<!-- Extension of c.xml to add C++ specific syntax. -->
<!-- With some Qt keywords added -->
<MODE>
    <PROPS>
        <PROPERTY NAME="commentStart" VALUE="/*" />
        <PROPERTY NAME="commentEnd" VALUE="*/" />
        <PROPERTY NAME="lineComment" VALUE="//" />
        <PROPERTY NAME="wordBreakChars" VALUE=",+-=<>/?^&*" />

        <!-- Auto indent -->
        <PROPERTY NAME="indentOpenBrackets" VALUE="{" />
        <PROPERTY NAME="indentCloseBrackets" VALUE="}" />
        <PROPERTY NAME="unalignedOpenBrackets" VALUE="(" />
        <PROPERTY NAME="unalignedCloseBrackets" VALUE=")" />
        <PROPERTY NAME="indentNextLine"
            VALUE="(?!^\s*(#|//)).*(\b(if|while|for)\s*\(.*\)|\b(else|do)\b)[^{;]*$" />
        <PROPERTY NAME="unindentThisLine"
            VALUE="^\s*((.*case\b.*|[\p{Alpha}_][\p{Alnum}_]*)\s*(slots)?:(?!:)).*$" />
        <PROPERTY NAME="electricKeys" VALUE=":" />
    </PROPS>

    <RULES
        IGNORE_CASE="FALSE"
        HIGHLIGHT_DIGITS="TRUE" DIGIT_RE="[0-9][0-9a-zA-Z]*">
        <EOL_SPAN TYPE="KEYWORD2" AT_WHITESPACE_END="TRUE" DELEGATE="CPP">#

        <IMPORT DELEGATE="LEX"/>
        <IMPORT DELEGATE="CORE"/>
    </RULES>

    <!-- Core C++ language -->
    <RULES SET="LEX"
        IGNORE_CASE="FALSE"
        HIGHLIGHT_DIGITS="TRUE" DIGIT_RE="[0-9][0-9a-zA-Z]*">

        <!-- A hack not to mark namespace qualification like "std::"
            as labels. -->
        <SEQ TYPE="OPERATOR">::

        <IMPORT DELEGATE="c::LEX"/>
    </RULES>

    <!-- Core C++ language -->
    <RULES SET="CORE"
        IGNORE_CASE="FALSE"
        HIGHLIGHT_DIGITS="TRUE" DIGIT_RE="[0-9][0-9a-zA-Z]*">

        <IMPORT DELEGATE="c::CORE"/>

        <KEYWORDS>
            <KEYWORD3>catch
            <KEYWORD3>class
            <KEYWORD3>const_cast
            <KEYWORD1>delete
            <KEYWORD3>dynamic_cast
            <KEYWORD1>explicit
            <KEYWORD2>export
            <KEYWORD1>friend
            <KEYWORD3>mutable
            <KEYWORD2>namespace
            <KEYWORD1>new
            <KEYWORD3>operator
            <KEYWORD1>private
            <KEYWORD1>protected
            <KEYWORD1>public
            <KEYWORD1>signals
            <KEYWORD1>slots
            <KEYWORD3>reinterpret_cast
            <KEYWORD3>static_assert
            <KEYWORD3>static_cast
            <KEYWORD3>template
            <LITERAL2>this
            <KEYWORD1>throw
            <KEYWORD1>try
            <KEYWORD3>typeid
            <KEYWORD3>typename
            <KEYWORD2>using
            <KEYWORD1>virtual

        </KEYWORDS>
    </RULES>

    <!-- Preprocessor specific rules -->
    <RULES SET="CPP"
        IGNORE_CASE="FALSE"
        HIGHLIGHT_DIGITS="TRUE" DIGIT_RE="[0-9][0-9a-zA-Z]*">

        <EOL_SPAN_REGEXP HASH_CHAR="include" TYPE="MARKUP" DELEGATE="c::INCLUDE">include\b
        <EOL_SPAN_REGEXP HASH_CHAR="define" TYPE="MARKUP" DELEGATE="DEFINE">define\b
        <EOL_SPAN_REGEXP HASH_CHAR="endif" TYPE="MARKUP" DELEGATE="c::LEX">endif\b
        <EOL_SPAN_REGEXP HASH_CHAR="elif" TYPE="MARKUP" DELEGATE="c::CONDITION">elif\b
        <EOL_SPAN_REGEXP HASH_CHAR="if" TYPE="MARKUP" DELEGATE="c::CONDITION">if\b

        <IMPORT DELEGATE="LEX"/>

        <!-- Directives -->
        <KEYWORDS>
            <MARKUP>ifdef
            <MARKUP>ifndef
            <MARKUP>else
            <MARKUP>error
            <MARKUP>line
            <MARKUP>pragma
            <MARKUP>undef
            <MARKUP>warning
        </KEYWORDS>
    </RULES>

    <!-- After #define directive -->
    <!-- Almost same as the normal code,
        except two additional operators # and ##. -->
    <RULES SET="DEFINE"
        IGNORE_CASE="FALSE"
        HIGHLIGHT_DIGITS="TRUE" DIGIT_RE="[0-9][0-9a-zA-Z]*">
        <SEQ TYPE="OPERATOR">#
        <IMPORT DELEGATE="LEX"/>
        <IMPORT DELEGATE="CORE"/>
    </RULES>

</MODE>

Other jEdit examples (source code examples)

Here is a short list of links related to this jEdit cplusplus.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.