File: matlab_support.py

package info (click to toggle)
gnat-gps 18-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,716 kB
  • sloc: ada: 362,679; python: 31,031; xml: 9,597; makefile: 1,030; ansic: 917; sh: 264; java: 17
file content (42 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from highlighter.common import words, tag_keyword, region, tag_comment, \
        hl_comment_notes, hl_inside_strings, simple, tag_number, \
        register_highlighter, tag_string
import GPS


# Load language definition before the gps_started hook, and before we load
# the project.
XML = """
<Language>
  <Name>matlab</Name>
  <Body_Suffix>.m</Body_Suffix>
  <Obj_Suffix>-</Obj_Suffix>
  <Context>
    <Can_Indent>True</Can_Indent>
    <Syntax_Highlighting>False</Syntax_Highlighting>
    <Case_Sensitive>True</Case_Sensitive>
  </Context>
</Language>
"""
GPS.parse_xml(XML)

register_highlighter(
    language="matlab",
    spec=(
        # Match keywords
        words(["break", "case", "catch", "continue", "else", "elseif",
               "end", "for", "function", "global", "if", "otherwise",
               "persistent", "return", "switch", "try", "while", "classdef",
               "methods"],
              tag=tag_keyword),

        # Match comments lines
        region(r"%", "\n", tag=tag_comment, highlighter=(hl_comment_notes,)),

        # Match strings
        region(r"'", r"'|$", tag=tag_string, highlighter=(hl_inside_strings,)),

        # Match number literals
        simple(r"\b[0-9]*\.?[0-9]+\b", tag=tag_number),
    )
)