kpeg 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -140,7 +140,11 @@ b(p) = x
140
140
  end
141
141
 
142
142
  def test_regexp_options
143
- assert_rule G.reg(/foo/u), match('a=/foo/u')
143
+ if RUBY_VERSION > "1.8.7"
144
+ assert_rule G.reg(/foo/n), match('a=/foo/n')
145
+ else
146
+ assert_rule G.reg(/foo/u), match('a=/foo/u')
147
+ end
144
148
  end
145
149
 
146
150
  def test_char_range
@@ -171,6 +175,10 @@ b(p) = x
171
175
  def test_arbitrary_multiple
172
176
  assert_rule G.multiple(:b, 5, 9), match('a=b[5,9]')
173
177
  end
178
+
179
+ def test_single_value_for_multiple
180
+ assert_rule G.multiple(:b, 5, 5), match('a=b[5]')
181
+ end
174
182
 
175
183
  def test_no_max_multiple
176
184
  assert_rule G.multiple(:b, 5, nil), match('a=b[5,*]')
@@ -315,6 +323,16 @@ Value = NUMBER:i { i }
315
323
  assert_rule G.seq(:b, :c, G.action(" b + { c + d } ")), m
316
324
  end
317
325
 
326
+ def test_actions_handle_double_quoted_strings
327
+ m = match 'a=b c { b + c + "}" }'
328
+ assert_rule G.seq(:b, :c, G.action(' b + c + "}" ')), m
329
+ end
330
+
331
+ def test_actions_handle_single_quoted_strings
332
+ m = match "a=b c { b + c + '}' }"
333
+ assert_rule G.seq(:b, :c, G.action(" b + c + '}' ")), m
334
+ end
335
+
318
336
  def test_action_send
319
337
  m = match 'a=b c ~d'
320
338
  assert_rule G.seq(:b, :c, G.action("d")), m
@@ -416,6 +434,12 @@ fact = fact "*" num
416
434
  return inst
417
435
  end
418
436
 
437
+ def test_allow_ends_with_comment
438
+ path = File.expand_path("../inputs/comments.kpeg", __FILE__)
439
+ parser = KPeg::FormatParser.new File.read(path), true
440
+ assert true, parser.parse
441
+ end
442
+
419
443
  def test_roundtrip
420
444
  path = File.expand_path("../../lib/kpeg/format.kpeg", __FILE__)
421
445
  parser = KPeg::FormatParser.new File.read(path)
@@ -220,4 +220,16 @@ root = .
220
220
  TXT
221
221
  assert_equal expected, io.string
222
222
  end
223
+
224
+ def test_multiple_render
225
+ gram = KPeg.grammar do |g|
226
+ g.root = g.multiple("a", 3, 5)
227
+ end
228
+
229
+ io = StringIO.new
230
+ gr = KPeg::GrammarRenderer.new(gram)
231
+ gr.render(io)
232
+
233
+ assert_equal "root = \"a\"[3, 5]\n", io.string
234
+ end
223
235
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kpeg
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
9
+ - 1
10
+ version: 0.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Evan Phoenix
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-06 00:00:00 -07:00
18
+ date: 2011-04-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,7 +56,6 @@ files:
56
56
  - bin/kpeg
57
57
  - doc/syntax_kpeg/ftdetect/kpeg.vim
58
58
  - doc/syntax_kpeg/syntax/kpeg.vim
59
- - LICENSE
60
59
  - README.md
61
60
  - Rakefile
62
61
  - kpeg.gemspec
data/LICENSE DELETED
@@ -1,25 +0,0 @@
1
- Copyright (c) 2011, Evan Phoenix
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
- * Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
8
- * Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
11
- * Neither the name of the <organization> nor the
12
- names of its contributors may be used to endorse or promote products
13
- derived from this software without specific prior written permission.
14
-
15
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
- DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
-