FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Rewrite grammar for class and module declarations · atom/language-ruby@51690ca · GitHub

This repository was archived by the owner on Dec 15, 2022. It is now read-only.
/ language-ruby Public archive

Commit 51690ca

Browse files
authored andcommitted
Rewrite grammar for class and module declarations
1 parent 7185bae commit 51690ca

1 file changed

Lines changed: 74 additions & 46 deletions

File tree

‎grammars/ruby.cson‎

Lines changed: 74 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -60,60 +60,88 @@
6060
'''
6161
'patterns': [
6262
{
63+
'begin': '\\bclass\\b'
6364
'captures':
64-
'1':
65+
'0':
6566
'name': 'keyword.control.class.ruby'
66-
'2':
67-
'name': 'entity.name.type.class.ruby'
68-
'4':
69-
'name': 'entity.other.inherited-class.ruby'
70-
'5':
71-
'name': 'punctuation.separator.inheritance.ruby'
72-
'6':
73-
'name': 'variable.other.object.ruby'
74-
'7':
75-
'name': 'punctuation.definition.variable.ruby'
76-
'match': '''(?x)
77-
^\\s*(class)\\s+
78-
(
79-
(
80-
[.a-zA-Z0-9_:]+
81-
(\\s*(<)\\s*[.a-zA-Z0-9_:]+)? # class A < B
82-
)
83-
|
84-
((<<)\\s*[.a-zA-Z0-9_:]+) # class << C
85-
)
86-
'''
67+
'end': '\\s*$|(?![\\s\\w.:<])'
8768
'name': 'meta.class.ruby'
69+
'patterns': [
70+
{
71+
'match': '[A-Z]\\w*'
72+
'name': 'entity.name.type.class.ruby'
73+
}
74+
{
75+
'include': '#separators'
76+
}
77+
{
78+
'begin': '<<'
79+
'captures':
80+
'0':
81+
'name': 'punctuation.definition.variable.ruby'
82+
'end': '(?=$)|(?![\\s\\w.:])'
83+
'patterns': [
84+
{
85+
'begin': '\\s*'
86+
'end': '(?=$)|(?![\\s\\w.:])'
87+
'contentName': 'variable.other.object.ruby'
88+
'patterns': [
89+
{
90+
'match': '[A-Z]\\w*'
91+
'name': 'entity.name.type.class.ruby'
92+
}
93+
{
94+
'include': '#separators'
95+
}
96+
]
97+
}
98+
]
99+
}
100+
{
101+
'begin': '<'
102+
'captures':
103+
'0':
104+
'name': 'punctuation.separator.inheritance.ruby'
105+
'end': '(?=$)|(?![\\s\\w.:])'
106+
'patterns': [
107+
{
108+
'begin': '\\s*'
109+
'end': '(?=$)|(?![\\s\\w.:])'
110+
'contentName': 'entity.other.inherited-class.ruby'
111+
'patterns': [
112+
{
113+
'match': '[A-Z]\\w*'
114+
'name': 'entity.name.type.class.ruby'
115+
}
116+
{
117+
'include': '#separators'
118+
}
119+
]
120+
}
121+
]
122+
}
123+
]
88124
}
89125
{
126+
'begin': '^\\bmodule\\b'
90127
'captures':
91-
'1':
128+
'0':
92129
'name': 'keyword.control.module.ruby'
93-
'2':
94-
'name': 'entity.name.type.module.ruby'
95-
'3':
96-
'name': 'entity.other.inherited-class.module.first.ruby'
97-
'4':
98-
'name': 'punctuation.separator.inheritance.ruby'
99-
'5':
100-
'name': 'entity.other.inherited-class.module.second.ruby'
101-
'6':
102-
'name': 'punctuation.separator.inheritance.ruby'
103-
'7':
104-
'name': 'entity.other.inherited-class.module.third.ruby'
105-
'8':
106-
'name': 'punctuation.separator.inheritance.ruby'
107-
'match': '''(?x)
108-
^\\s*(module)\\s+
109-
(
110-
([A-Z]\\w*(::))?
111-
([A-Z]\\w*(::))?
112-
([A-Z]\\w*(::))*
113-
[A-Z]\\w*
114-
)
115-
'''
130+
'end': '\\s*$|(?![\\s\\w.:])'
116131
'name': 'meta.module.ruby'
132+
'patterns': [
133+
{
134+
'match': '[A-Z]\\w*(?=::)'
135+
'name': 'entity.other.inherited-class.module.ruby'
136+
}
137+
{
138+
'match': '[A-Z]\\w*'
139+
'name': 'entity.name.type.module.ruby'
140+
}
141+
{
142+
'include': '#separators'
143+
}
144+
]
117145
}
118146
{
119147
'comment': 'else if is a common mistake carried over from other languages. it works if you put in a second end, but it’s never what you want.'

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL