<glimmer-definition>
   <settings>
      <language>Ada</language>
      <compiler>glimmerout gnatmake %1/%2 2&gt;&amp;1</compiler>
      <debugger>%term% -e gnatgdb %1/%2</debugger>
      <execution>%1/%3</execution>
      <auto-indent>1</auto-indent>
      <use-spaces>1</use-spaces>
      <tab-stop>3</tab-stop>
   </settings>

   <mime-types>
      <extension>ada</extension>
      <extension>adb</extension>
      <extension>ads</extension>
   </mime-types>

   <syntax-items>
      <syntax-item>
         <name>string1</name>
         <start-regex>&quot;</start-regex>
         <end-regex>\(&quot;\|\n\)</end-regex>
         <style>string</style>
      </syntax-item>
      <syntax-item>
         <name>comment</name>
         <start-regex>--</start-regex>
         <end-regex>\n</end-regex>
         <style>comment</style>
      </syntax-item>
   </syntax-items>

   <pattern-items>
      <pattern-item>
         <name>char-string</name>
         <regex>&apos;\\?[a-zA-Z0-9_\\()#@!$%^&amp;*-=+&quot;{}&lt;)]&apos;</regex>
         <style>char_string</style>
      </pattern-item>
      <pattern-item>
         <name>preprocessor1</name>
         <regex>\b\(PACKAGE\|PRAGMA\|USE\|WITH\)</regex>
         <style>preprocessor</style>
      </pattern-item>
      <pattern-item>
         <name>preprocessor2</name>
         <regex>\b\(Package\|Pragma\|Use\|With\)</regex>
         <style>preprocessor</style>
      </pattern-item>
      <pattern-item>
         <name>preprocessor3</name>
         <regex>\b\(package\|pragma\|use\|with\)</regex>
         <style>preprocessor</style>
      </pattern-item>
      <pattern-item>
         <name>function1</name>
         <regex>\b\(FUNCTION\|PROCEDURE\|RETURN\)</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>function2</name>
         <regex>\b\(Function\|Procedure\|Return\)</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>function3</name>
         <regex>\b\(function\|procedure\|return\)</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>keywords1</name>
         <regex>\b\(ABORT\|ABS\|ACCEPT\|ACCESS\|ALL\|AND\|ARRAY\|AT\|BEGIN\|BODY\|CASE\|CONSTANT\|DECLARE\|DELAY\|DELTA\|DIGITS\|DO\|ELSE\|ELSIF\|END\|ENTRY\|EXCEPTION\|EXIT\|FOR\|GENERIC\|GOTO\|IF\|IN\|IS\|LIMITED\|LOOP\|MOD\|NEW\|NOT\|NULL\|OF\|OR\|OTHERS\|OUT\|PRIVATE\|RAISE\|RANGE\|RECORD\|REM\|RENAMES\|REVERSE\|SELECT\|SEPARATE\|SUBTYPE\|TASK\|TERMINATE\|THEN\|TYPE\|WHEN\|WHILE\|XOR\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>keywords2</name>
         <regex>\b\(Abort\|Abs\|Accept\|Access\|All\|And\|Array\|At\|Begin\|Body\|Case\|Constant\|Declare\|Delay\|Delta\|Digits\|Do\|Else\|Elsif\|End\|Entry\|Exception\|Exit\|For\|Generic\|Goto\|If\|In\|Is\|Limited\|Loop\|Mod\|New\|Not\|Null\|Of\|Or\|Others\|Out\|Private\|Raise\|Range\|Record\|Rem\|Renames\|Reverse\|Select\|Separate\|Subtype\|Task\|Terminate\|Then\|Type\|When\|While\|Xor\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>keywords3</name>
         <regex>\b\(abort\|abs\|accept\|access\|all\|and\|array\|at\|begin\|body\|case\|constant\|declare\|delay\|delta\|digits\|do\|else\|elsif\|end\|entry\|exception\|exit\|for\|generic\|goto\|if\|in\|is\|limited\|loop\|mod\|new\|not\|null\|of\|or\|others\|out\|private\|raise\|range\|record\|rem\|renames\|reverse\|select\|separate\|subtype\|task\|terminate\|then\|type\|when\|while\|xor\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>types1</name>
         <regex>\b\(BOOLEAN\|CHARACTER\|COUNT\|DURATION\|FLOAT\|INTEGER\|LONG_FLOAT\|LONG_INTEGER\|PRIORITY\|SHORT_FLOAT\|SHORT_INTEGER\|STRING\)\b</regex>
         <style>data_type</style>
      </pattern-item>
      <pattern-item>
         <name>types2</name>
         <regex>\b\(Boolean\|Character\|Count\|Duration\|Float\|Integer\|Long_Float\|Long_Integer\|Priority\|Short_Float\|Short_Integer\|String\)\b</regex>
         <style>data_type</style>
      </pattern-item>
      <pattern-item>
         <name>types3</name>
         <regex>\b\(boolean\|character\|count\|duration\|float\|integer\|long_float\|long_integer\|priority\|short_float\|short_integer\|string\)\b</regex>
         <style>data_type</style>
      </pattern-item>
      <pattern-item>
         <name>numbers</name>
         <regex>\b[0-9][0-9\.]*\b</regex>
         <style>decimal</style>
      </pattern-item>
      <pattern-item>
         <name>tnf</name>
         <regex>\b\(TRUE\|FALSE\|True\|False\|true\|false\)\b</regex>
         <style>macro</style>
      </pattern-item>
      <pattern-item>
         <name>operators</name>
         <regex>\(:\|;\|,\|+\|-\|\*\|&gt;=\|&lt;=\|&gt;\|&lt;\|/=\|:=\|=\|&amp;\|\.\|&apos;\|\*\*\|/\|(\|)\)</regex>
         <style>operator</style>
      </pattern-item>
   </pattern-items>
</glimmer-definition>

<python-definition>
import glimmer
import re

def ada_enter_callback():
    insert = "\n"
    extralen = 0
    slen = 0
    file = glimmer.get_file_number()
    tstart = glimmer.line_start()
    tend = glimmer.current_position()
    if (tend-tstart) > 0:
        chars = glimmer.get_text(tstart, tend)
        slen = len(chars)
        if slen > 0:
            index = 0
            while index < slen:
                c = chars[index]
                if c == '\t' or c == ' ':
                    insert = insert + chars[index]
                    index = index+1
                else:
                    break
            output = re.search("(begin|declare|else|exception|generic|loop|or|private|select|is|do|then abort|then)$", chars, re.I)
            if not(output):
               output = re.search("(when|of)", chars, re.I)
            if output:
                extralen = glimmer.get_file_tab_width(file)
                if glimmer.get_file_use_spaces(file):
                    while extralen > 0:
                        insert = insert + " "
                        extralen = extralen-1
                else:
                    insert = insert + '\t'
    glimmer.insert(insert)

glimmer.register_signal_hook("enter-pressed", ada_enter_callback)

def ada_tab_callback():
   tablen = 0
   insertchars = ""
   file = glimmer.get_file_number()
   if glimmer.get_file_use_spaces(file):
      tablen = glimmer.get_file_tab_width(file)
      pos = glimmer.current_position()
      lstart = glimmer.line_start()
      if pos - lstart > 0:
         str1 = glimmer.get_text(lstart, pos)
      else:
         str1 = ""
      if glimmer.get_tab_stops():
         str1 = string.expandtabs(str1, tablen)
         len1 = len(str1)
         del str1
         tablen = tablen - (len1 % tablen)
      while tablen > 0:
         insertchars = insertchars + " "
         tablen = tablen-1
   else:
      insertchars = insertchars + "\t"
   glimmer.insert(insertchars)

glimmer.register_signal_hook("tab-pressed", ada_tab_callback)

def insert_ada_comment():
    glimmer.freeze()
    if glimmer.has_selection():
        start = glimmer.selection_start()
        end = glimmer.selection_end()
        file = glimmer.get_file_number()
        glimmer.move(0)
        line1 = glimmer.line_by_pos(start)
        line2 = glimmer.line_by_pos(end)
        cur = line1
        print start
        print end
        while cur <= line2:
           glimmer.move_to_col(0)
           glimmer.move_to_line(cur)
           glimmer.insert("--")
           cur = cur+2
        glimmer.move_to(end+((line2-line1)+1)*2)
    else:
        glimmer.insert("--")
    glimmer.thaw()

glimmer.add_sub_to_menu("_Insert/", "Ada", -1)
glimmer.add_item_to_menu("_Insert/Ada/", "Comment (--)", "", "", -1, insert_ada_comment)
glimmer.add_item_to_popup_menu("Comment (--)", -1, insert_ada_comment)
</python-definition>
