iro 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/Rakefile +2 -0
- data/lib/iro/ruby/parser.rb +27 -3
- data/lib/iro/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e8919acfe7f9be5a6458e9a9be7ecb82dfa93519b36b037167631cdd60a7eba
|
4
|
+
data.tar.gz: 07cdfaa58a518b5498c289e0edac1b4a8b628311233f9ca1a32afb9fddfd77b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4bea256724d0ab3f55ad5fdd0bb41cfd0ee869330ec1c83665b4d09e925e6b67f9647500836092822cda924d7ce7b0621e06ae07d7d93c0bfb13dcd7397b722
|
7
|
+
data.tar.gz: 0bc07ca76b25009571cb1d0c64e2ebd5218f6fb50840f1bb8d97af88fa450220b80e4f052107ecad642b81b50afa9207d1795bca26f2686e151e56a4d59f79b2
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Iro
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Iro is a library for syntax highlighting.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,8 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
If you are a Vim user, you can use [Iro.vim](https://github.com/pocke/iro.vim).
|
24
|
+
And we have a DEMO web page. http://ruby-highlight.herokuapp.com/
|
26
25
|
|
27
26
|
## Development
|
28
27
|
|
data/Rakefile
CHANGED
@@ -13,9 +13,11 @@ end
|
|
13
13
|
task :smoke do
|
14
14
|
sh 'bin/smoke', 'tric/trick2013'
|
15
15
|
sh 'bin/smoke', 'tric/trick2015'
|
16
|
+
sh 'bin/smoke', 'tric/trick2018'
|
16
17
|
sh 'bin/smoke', 'ruby/ruby', 'trunk'
|
17
18
|
sh 'bin/smoke', 'gitlabhq/gitlabhq'
|
18
19
|
sh 'bin/smoke', 'rails/rails'
|
20
|
+
sh 'bin/smoke', 'discourse/discourse'
|
19
21
|
end
|
20
22
|
|
21
23
|
namespace :bump do
|
data/lib/iro/ruby/parser.rb
CHANGED
@@ -46,6 +46,14 @@ module Iro
|
|
46
46
|
def initialize(*)
|
47
47
|
super
|
48
48
|
@tokens = {}
|
49
|
+
@end_stack = []
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse
|
53
|
+
super
|
54
|
+
@end_stack.each do |end_kw|
|
55
|
+
register_scanner_event 'Keyword', end_kw
|
56
|
+
end
|
49
57
|
end
|
50
58
|
|
51
59
|
def register_token(group, token)
|
@@ -59,6 +67,10 @@ module Iro
|
|
59
67
|
register_token group, [pos[0], pos[1]+1, event.content.size]
|
60
68
|
end
|
61
69
|
|
70
|
+
def highlight_end_as(group)
|
71
|
+
register_scanner_event group, @end_stack.pop
|
72
|
+
end
|
73
|
+
|
62
74
|
def unhighlight!(scanner_event)
|
63
75
|
t = scanner_event.type[1..-1].to_sym
|
64
76
|
group = EVENT_NAME_TO_HIGHLIGT_NAME[t] ||
|
@@ -68,6 +80,7 @@ module Iro
|
|
68
80
|
t = scanner_event.position + [scanner_event.content.size]
|
69
81
|
t[1] += 1
|
70
82
|
@tokens[group].reject! { |ev| ev == t }
|
83
|
+
@end_stack.reject!{|e| e == scanner_event} if scanner_event.kw_type? && scanner_event.content == 'end'
|
71
84
|
end
|
72
85
|
|
73
86
|
EVENT_NAME_TO_HIGHLIGT_NAME.each do |tok_type, group|
|
@@ -85,9 +98,14 @@ module Iro
|
|
85
98
|
end
|
86
99
|
|
87
100
|
def on_kw(str)
|
88
|
-
|
89
|
-
|
90
|
-
|
101
|
+
super.tap do |result|
|
102
|
+
if str == 'end'
|
103
|
+
@end_stack << result
|
104
|
+
else
|
105
|
+
group = kw_group(str)
|
106
|
+
register_token group, [lineno, column+1, str.size]
|
107
|
+
end
|
108
|
+
end
|
91
109
|
end
|
92
110
|
|
93
111
|
# foo: bar
|
@@ -108,12 +126,14 @@ module Iro
|
|
108
126
|
def on_def(name, params, body)
|
109
127
|
unhighlight! name if name.kw_type?
|
110
128
|
register_scanner_event 'rubyFunction', name
|
129
|
+
highlight_end_as 'rubyDefine'
|
111
130
|
nil
|
112
131
|
end
|
113
132
|
|
114
133
|
def on_defs(recv, period, name, params, body)
|
115
134
|
unhighlight! name if name.kw_type?
|
116
135
|
register_scanner_event 'rubyFunction', name
|
136
|
+
highlight_end_as 'rubyDefine'
|
117
137
|
nil
|
118
138
|
end
|
119
139
|
|
@@ -153,6 +173,10 @@ module Iro
|
|
153
173
|
highlight_keyword_like_method(ident)
|
154
174
|
end
|
155
175
|
|
176
|
+
def on_vcall(ident)
|
177
|
+
highlight_keyword_like_method(ident)
|
178
|
+
end
|
179
|
+
|
156
180
|
def on_command(ident, _)
|
157
181
|
highlight_keyword_like_method(ident)
|
158
182
|
end
|
data/lib/iro/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|