textpow 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,107 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>BBEditDocumentType</key>
6
- <string>CodelessLanguageModule</string>
7
- <key>BBLMColorsSyntax</key>
8
- <true/>
9
- <key>BBLMIsCaseSensitive</key>
10
- <true/>
11
- <key>BBLMKeywordList</key>
12
- <array>
13
- <string>and</string>
14
- <string>or</string>
15
- <string>xor</string>
16
- <string>virtual</string>
17
- <string>if</string>
18
- <string>else</string>
19
- <string>do</string>
20
- <string>while</string>
21
- <string>use</string>
22
- <string>bundle</string>
23
- <string>native</string>
24
- <string>static</string>
25
- <string>public</string>
26
- <string>private</string>
27
- <string>class</string>
28
- <string>interface</string>
29
- <string>select</string>
30
- <string>other</string>
31
- <string>enum</string>
32
- <string>for</string>
33
- <string>each</string>
34
- <string>label</string>
35
- <string>return</string>
36
- <string>Byte</string>
37
- <string>Int</string>
38
- <string>Parent</string>
39
- <string>from</string>
40
- <string>Float</string>
41
- <string>Char</string>
42
- <string>Bool</string>
43
- <string>String</string>
44
- <string>Nil</string>
45
- <string>true</string>
46
- <string>false</string>
47
- <string>function</string>
48
- <string>method</string>
49
- </array>
50
- <key>BBLMLanguageCode</key>
51
- <string>LSL</string>
52
- <key>BBLMLanguageDisplayName</key>
53
- <string>Objeck</string>
54
- <key>BBLMScansFunctions</key>
55
- <true/>
56
- <key>BBLMSuffixMap</key>
57
- <array>
58
- <dict>
59
- <key>BBLMLanguageSuffix</key>
60
- <string>.obs</string>
61
- </dict>
62
- </array>
63
- <key>Language Features</key>
64
- <dict>
65
- <key>Close Block Comments</key>
66
- <string>~#</string>
67
- <key>Close Parameter Lists</key>
68
- <string>)</string>
69
- <key>Close Statement Blocks</key>
70
- <string>}</string>
71
- <key>Close Strings 1</key>
72
- <string>&quot;</string>
73
- <key>Close Strings 2</key>
74
- <string>&apos;</string>
75
- <key>End-of-line Ends Strings 1</key>
76
- <false/>
77
- <key>End-of-line Ends Strings 2</key>
78
- <false/>
79
- <key>Escape Char in Strings 1</key>
80
- <string>\</string>
81
- <key>Escape Char in Strings 2</key>
82
- <string>\</string>
83
- <key>Identifier and Keyword Characters</key>
84
- <string>@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz</string>
85
- <key>Open Block Comments</key>
86
- <string>#~</string>
87
- <key>Open Line Comments</key>
88
- <string>#</string>
89
- <key>Open Parameter Lists</key>
90
- <string>(</string>
91
- <key>Open Statement Blocks</key>
92
- <string>{</string>
93
- <key>Open Strings 1</key>
94
- <string>&quot;</string>
95
- <key>Open Strings 2</key>
96
- <string>&apos;</string>
97
- <key>Prefix for Functions</key>
98
- <string></string>
99
- <key>Prefix for Procedures</key>
100
- <string></string>
101
- <key>Terminator for Prototypes 1</key>
102
- <string></string>
103
- <key>Terminator for Prototypes 2</key>
104
- <string></string>
105
- </dict>
106
- </dict>
107
- </plist>
@@ -1,107 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>BBEditDocumentType</key>
6
- <string>CodelessLanguageModule</string>
7
- <key>BBLMColorsSyntax</key>
8
- <true/>
9
- <key>BBLMIsCaseSensitive</key>
10
- <true/>
11
- <key>BBLMKeywordList</key>
12
- <array>
13
- <string>and</string>
14
- <string>or</string>
15
- <string>xor</string>
16
- <string>virtual</string>
17
- <string>if</string>
18
- <string>else</string>
19
- <string>do</string>
20
- <string>while</string>
21
- <string>use</string>
22
- <string>bundle</string>
23
- <string>native</string>
24
- <string>static</string>
25
- <string>public</string>
26
- <string>private</string>
27
- <string>class</string>
28
- <string>interface</string>
29
- <string>select</string>
30
- <string>other</string>
31
- <string>enum</string>
32
- <string>for</string>
33
- <string>each</string>
34
- <string>label</string>
35
- <string>return</string>
36
- <string>Byte</string>
37
- <string>Int</string>
38
- <string>Parent</string>
39
- <string>from</string>
40
- <string>Float</string>
41
- <string>Char</string>
42
- <string>Bool</string>
43
- <string>String</string>
44
- <string>Nil</string>
45
- <string>true</string>
46
- <string>false</string>
47
- <string>function</string>
48
- <string>method</string>
49
- </array>
50
- <key>BBLMLanguageCode</key>
51
- <string>LSL</string>
52
- <key>BBLMLanguageDisplayName</key>
53
- <string>Objeck</string>
54
- <key>BBLMScansFunctions</key>
55
- <true/>
56
- <key>BBLMSuffixMap</key>
57
- <array>
58
- <dict>
59
- <key>BBLMLanguageSuffix</key>
60
- <string>.obs</string>
61
- </dict>
62
- </array>
63
- <key>Language Features</key>
64
- <dict>
65
- <key>Close Block Comments</key>
66
- <string>~#</string>
67
- <key>Close Parameter Lists</key>
68
- <string>)</string>
69
- <key>Close Statement Blocks</key>
70
- <string>}</string>
71
- <key>Close Strings 1</key>
72
- <string>&quot;</string>
73
- <key>Close Strings 2</key>
74
- <string>&apos;</string>
75
- <key>End-of-line Ends Strings 1</key>
76
- <false/>
77
- <key>End-of-line Ends Strings 2</key>
78
- <false/>
79
- <key>Escape Char in Strings 1</key>
80
- <string>\</string>
81
- <key>Escape Char in Strings 2</key>
82
- <string>\</string>
83
- <key>Identifier and Keyword Characters</key>
84
- <string>@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz</string>
85
- <key>Open Block Comments</key>
86
- <string>#~</string>
87
- <key>Open Line Comments</key>
88
- <string>#</string>
89
- <key>Open Parameter Lists</key>
90
- <string>(</string>
91
- <key>Open Statement Blocks</key>
92
- <string>{</string>
93
- <key>Open Strings 1</key>
94
- <string>&quot;</string>
95
- <key>Open Strings 2</key>
96
- <string>&apos;</string>
97
- <key>Prefix for Functions</key>
98
- <string></string>
99
- <key>Prefix for Procedures</key>
100
- <string></string>
101
- <key>Terminator for Prototypes 1</key>
102
- <string></string>
103
- <key>Terminator for Prototypes 2</key>
104
- <string></string>
105
- </dict>
106
- </dict>
107
- </plist>
@@ -1 +0,0 @@
1
- ü
@@ -1,2 +0,0 @@
1
- $LOAD_PATH.unshift 'lib'
2
- require 'textpow'
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Textpow::ScoreManager do
4
- it "calculates scores" do
5
- sp = Textpow::ScoreManager.new
6
- reference_scope = 'text.html.basic source.php.embedded.html string.quoted.double.php'
7
-
8
- sp.score('source.php string', reference_scope).should_not == 0
9
- sp.score('text.html source.php', reference_scope).should_not == 0
10
- sp.score('string source.php', reference_scope).should == 0
11
- sp.score('source.php text.html', reference_scope).should == 0
12
-
13
- sp.score('text.html source.php - string', reference_scope).should == 0
14
- sp.score('text.html source.php - ruby', reference_scope ).should_not == 0
15
-
16
- sp.score('string', reference_scope).should > sp.score('source.php', reference_scope)
17
- sp.score('string.quoted', reference_scope).should > sp.score('source.php', reference_scope)
18
- sp.score('text source string', reference_scope).should > sp.score( 'source string', reference_scope)
19
- end
20
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "syntax files" do
4
- before do
5
- STDERR.stub!(:puts)
6
- end
7
-
8
- it "has syntax files" do
9
- Dir["#{Textpow.syntax_path}/*.syntax"].should_not == []
10
- end
11
-
12
- Dir["#{Textpow.syntax_path}/*.syntax"].each do |syntax|
13
- it "can parse with #{syntax}" do
14
- Textpow.syntax(syntax).parse("xxx\n1 + 1\n### xxx")
15
- end
16
-
17
- it "can parse UTF-8 with #{syntax}" do
18
- Textpow.syntax(syntax).parse(File.read("spec/fixtures/utf8.txt"))
19
- end
20
- end
21
-
22
- xit "parses markdown" do
23
- node = Textpow.syntax("lib/textpow/syntax/broken/markdown.syntax")
24
- node.parse("### xxx\nabc\n xxx\nyyy\n - abc\n - ac").stack.should_not == []
25
- end
26
- end
@@ -1,225 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Textpow::SyntaxNode do
4
- before do
5
- Textpow::SyntaxNode.send(:class_variable_set, "@@syntaxes", {})
6
- end
7
-
8
- describe "#load" do
9
- it "can load from xml .plist" do
10
- Textpow::SyntaxNode.load('spec/fixtures/objeck.plist').should_not == nil
11
- end
12
-
13
- it "can load from yaml .syntax" do
14
- Textpow::SyntaxNode.load('lib/textpow/syntax/source.ruby.syntax').should_not == nil
15
- end
16
-
17
- it "cannot load missing file" do
18
- lambda{
19
- Textpow::SyntaxNode.load('xxx.syntax')
20
- }.should raise_error
21
- end
22
-
23
- it "cannot load missing plist file" do
24
- lambda{
25
- Textpow::SyntaxNode.load('xxx.plist')
26
- }.should raise_error
27
- end
28
- end
29
-
30
- describe "#new" do
31
- it "loads strings from given hash" do
32
- syntax = Textpow::SyntaxNode.new('content' => 'CONTENT', 'name' => 'NAME')
33
- syntax.content.should == 'CONTENT'
34
- syntax.name.should == 'NAME'
35
- end
36
-
37
- it "loads regex from given hash" do
38
- syntax = Textpow::SyntaxNode.new('firstLineMatch' => 'aaa', 'foldingStartMarker' => 'bbb')
39
- syntax.firstLineMatch.inspect.should == "/aaa/"
40
- syntax.foldingStartMarker.inspect.should == "/bbb/"
41
- end
42
-
43
- it "raises ParsingError on invalid regex" do
44
- lambda{
45
- Textpow::SyntaxNode.new('firstLineMatch' => '$?)(:[/\]')
46
- }.should raise_error(Textpow::ParsingError)
47
- end
48
-
49
- it "stores itself as parent" do
50
- node = Textpow::SyntaxNode.new({})
51
- node.syntax.should == node
52
- end
53
-
54
- it "stores given parent" do
55
- node = Textpow::SyntaxNode.new({}, :syntax => 1)
56
- node.syntax.should == 1
57
- end
58
-
59
- it "stores itself in global namespace under scopeName" do
60
- node = Textpow::SyntaxNode.new("scopeName" => 'xxx')
61
- node.syntaxes['xxx'].should == node
62
- Textpow::SyntaxNode.new({}).syntaxes['xxx'].should == node
63
- end
64
-
65
- it "stores itself in scoped global namespace under scopeName" do
66
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx'}, :name_space => 'foo')
67
- node.syntaxes['xxx'].should == node
68
- Textpow::SyntaxNode.new({},:name_space => 'foo').syntaxes['xxx'].should == node
69
- Textpow::SyntaxNode.new({}).syntaxes['xxx'].should == nil
70
- end
71
- end
72
-
73
- describe "#parse" do
74
- let(:node){ Textpow.syntax('ruby') }
75
-
76
- it "uses a RecordingProcessor by default" do
77
- node.parse("111").stack.should == [
78
- [:start_parsing, "source.ruby"],
79
- [:new_line, "111"],
80
- [:open_tag, "constant.numeric.ruby", 0],
81
- [:close_tag, "constant.numeric.ruby", 3],
82
- [:end_parsing, "source.ruby"]
83
- ]
84
- end
85
-
86
- it "can parse with a processor" do
87
- processor = Textpow::RecordingProcessor.new
88
- processor.stack << 'xxx'
89
- node.parse("111", processor).stack.should == [
90
- "xxx",
91
- [:start_parsing, "source.ruby"],
92
- [:new_line, "111"],
93
- [:open_tag, "constant.numeric.ruby", 0],
94
- [:close_tag, "constant.numeric.ruby", 3],
95
- [:end_parsing, "source.ruby"]
96
- ]
97
- end
98
-
99
- it "can parse multiline syntax via stack" do
100
- node.parse("=begin\n111\n=end").stack.should == [
101
- [:start_parsing, "source.ruby"],
102
- [:new_line, "=begin\n"],
103
- [:open_tag, "comment.block.documentation.ruby", 0],
104
- [:open_tag, "punctuation.definition.comment.ruby", 0],
105
- [:close_tag, "punctuation.definition.comment.ruby", 6],
106
- [:new_line, "111\n"],
107
- [:new_line, "=end"],
108
- [:open_tag, "punctuation.definition.comment.ruby", 0],
109
- [:close_tag, "punctuation.definition.comment.ruby", 4],
110
- [:close_tag, "comment.block.documentation.ruby", 4],
111
- [:end_parsing, "source.ruby"]
112
- ]
113
- end
114
-
115
- it "loads included syntax files" do
116
- pending
117
- node = Textpow.syntax('html_rails')
118
- node.parse("<br/>")
119
- end
120
- end
121
-
122
- describe "#match_first_son" do
123
- it "returns nil when patterns are empty" do
124
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx'})
125
- node.send(:match_first_son, "xxx", 0).should == nil
126
- end
127
-
128
- it "matches a pattern" do
129
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx', 'patterns' => [
130
- {"match" => "xxx", "name" => "foo"}
131
- ]})
132
- pattern, match = node.send(:match_first_son, "xxxyy", 0)
133
- match.to_s.should == 'xxx'
134
- pattern.name.should == 'foo'
135
- end
136
-
137
- it "matches the first pattern" do
138
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx', 'patterns' => [
139
- {"match" => "yyy", "name" => "bar"},
140
- {"match" => "xxx", "name" => "foo"},
141
- {"match" => "zzz", "name" => "baz"},
142
- ]})
143
- pattern, match = node.send(:match_first_son, "xxxyyyzzz", 0)
144
- match.to_s.should == 'xxx'
145
- pattern.name.should == 'foo'
146
- end
147
-
148
- it "matches the first pattern for equal positions" do
149
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx', 'patterns' => [
150
- {"match" => "xxx", "name" => "bar"},
151
- {"match" => "xxxyyy", "name" => "foo"},
152
- {"match" => "xxxyy", "name" => "baz"},
153
- ]})
154
- pattern, match = node.send(:match_first_son, "xxxyyyzzz", 0)
155
- match.to_s.should == 'xxx'
156
- pattern.name.should == 'bar'
157
- end
158
- end
159
-
160
- describe "proxying" do
161
- it "cannot proxy by scopeName if syntax is missing" do
162
- STDERR.should_not_receive(:puts)
163
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx', 'patterns' => [{'include' => 'foo'}]})
164
- node.parse('bar').stack.should == [
165
- [:start_parsing, "xxx"],
166
- [:new_line, "bar"],
167
- [:end_parsing, "xxx"]
168
- ]
169
- end
170
-
171
- it "can proxy by scopeName if syntax is available in repo" do
172
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx', 'patterns' => [{'include' => 'source.ruby'}]})
173
- node.parse('1').stack.should == [
174
- [:start_parsing, "xxx"],
175
- [:new_line, "1"],
176
- [:open_tag, "constant.numeric.ruby", 0],
177
- [:close_tag, "constant.numeric.ruby", 1],
178
- [:end_parsing, "xxx"]
179
- ]
180
- end
181
-
182
- it "can proxy by scopeName if syntax is loaded (even later)" do
183
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx', 'patterns' => [{'include' => 'foo'}]})
184
- Textpow::SyntaxNode.new({"scopeName" => 'foo', 'patterns' => [{'name' => 'foo.1', 'match' => 'bar'}]})
185
- node.parse('bar').stack.should == [
186
- [:start_parsing, "xxx"],
187
- [:new_line, "bar"],
188
- [:open_tag, "foo.1", 0],
189
- [:close_tag, "foo.1", 3],
190
- [:end_parsing, "xxx"]
191
- ]
192
- end
193
-
194
- it "can proxy to a pattern defined in an repository" do
195
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx',
196
- 'repository' => {'foo' => {'name' => 'foo.1', 'match' => 'bar'}},
197
- 'patterns' => [{'include' => '#foo'}]
198
- })
199
- node.parse('bar').stack.should == [
200
- [:start_parsing, "xxx"],
201
- [:new_line, "bar"],
202
- [:open_tag, "foo.1", 0],
203
- [:close_tag, "foo.1", 3],
204
- [:end_parsing, "xxx"]
205
- ]
206
- end
207
-
208
- it "can proxy to a pattern nested included in an repository" do
209
- node = Textpow::SyntaxNode.new({"scopeName" => 'xxx',
210
- 'repository' => {
211
- 'baz' => {'patterns' => [{'include' => '#foo'}]},
212
- 'foo' => {'name' => 'foo.1', 'match' => 'bar'}
213
- },
214
- 'patterns' => [{'include' => '#baz'}]
215
- })
216
- node.parse('bar').stack.should == [
217
- [:start_parsing, "xxx"],
218
- [:new_line, "bar"],
219
- [:open_tag, "foo.1", 0],
220
- [:close_tag, "foo.1", 3],
221
- [:end_parsing, "xxx"]
222
- ]
223
- end
224
- end
225
- end