File: ruby

package info (click to toggle)
dte 1.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,152 kB
  • sloc: ansic: 28,421; sh: 94; awk: 56; makefile: 13; sed: 1
file content (162 lines) | stat: -rw-r--r-- 3,491 bytes parent folder | download | duplicates (2)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
syntax .ruby-esc

# TODO: \unnnn  Unicode codepoint, where nnnn is exactly 4 hex digits
# TODO: \u{nnnn ...}  Unicode codepoint(s), where each nnnn is 1-6 hex digits
state esc special
    char "abefnrstv'\\\"" END special
    char 0-7 oct1
    char x hex0
    char c control
    str 'C-' control
    str 'M-' meta
    noeat END

state oct1 special
    char 0-7 oct2
    noeat END

state oct2 special
    char 0-7 END special
    noeat END

state hex0 special
    char 0-9a-fA-F hex1
    noeat END

state hex1 special
    char 0-9a-fA-F END special
    noeat END

state control special
    str "\\M-" ascii-print
    noeat ascii-print

state meta special
    str "\\c" ascii-print
    str "\\C-" ascii-print
    noeat ascii-print

state ascii-print special
    char "\x21-\x7e" END special
    noeat END

syntax ruby

# TODO: %Q() strings
# TODO: Expression substitution in strings (e.g. "my name is #{$ruby}")
# TODO: Here document strings (e.g. print <<EOF ...)
# TODO: Command output (e.g. `date` or %x{ date })
# TODO: Regular expression literals  (e.g. /^Ruby/i or %r|^/usr/local/.*|)
# TODO: Numeric literals

state line-start code
    char "\n" this
    char = line-start-eq
    noeat start

state start code
    char # comment
    char "\n" line-start
    char -b a-zA-Z_ ident
    char '"' dq
    char "'" sq
    char \$ global-variable
    char -b @ maybe-instance-variable
    char -b : maybe-symbol
    eat this

state global-variable
    char a-zA-Z0-9_- this
    char !@&`\'+~=/\\,\;.<>*\$?:\" start global-variable
    noeat start

state maybe-instance-variable instance-variable
    char -b a-zA-Z_ instance-variable
    recolor code
    noeat start

state instance-variable
    char a-zA-Z0-9_ this
    noeat start

state maybe-symbol symbol
    char -b a-zA-Z_ symbol
    char -b : double-colon
    recolor code
    noeat start

state double-colon
    recolor double-colon
    noeat start

state symbol
    char a-zA-Z0-9_ this
    noeat start

state comment
    char "\n" line-start
    eat this

state line-start-eq comment
    str 'begin' =begin
    recolor code 1
    noeat start

state =begin comment
    char "\n" =begin-line-start
    char " \t" =begin-text
    recolor code 6
    noeat start

state =begin-text comment
    char "\n" =begin-line-start
    eat this

state =begin-line-start comment
    char "\n" this
    str '=end' =begin-maybe-end
    noeat =begin-text

state =begin-maybe-end comment
    char "\n" line-start
    char " \t" =end
    noeat =begin-text

state =end comment
    char "\n" line-start
    eat this

state ident
    char -b a-zA-Z0-9_!? this
    inlist keyword start
    inlist true-false-nil start
    noeat start

state dq string
    char "\"" start string
    char "\n" line-start
    char -b "\\" .ruby-esc:this
    eat this

state sq string
    char "'" start string
    char "\n" line-start
    char -b "\\" .ruby-esc:this
    eat this

list keyword \
    __ENCODING__ __LINE__ __FILE__ BEGIN END \
    alias and begin break case class def defined? do else elsif end \
    ensure for if in module next not or redo rescue retry return self \
    super then undef unless until when while yield

# These keywords could be in the same list as above but they are kept
# separate here to allow the option of highlighting with a different color
list true-false-nil \
    true false nil

default keyword true-false-nil
default numeric symbol
default variable global-variable
default variable instance-variable
default operator double-colon