Spectre 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +1 -0
- data/LICENSE +23 -0
- data/README +20 -0
- data/Rakefile +112 -0
- data/lib/spectre/base.rb +44 -0
- data/lib/spectre/base/closure.rb +96 -0
- data/lib/spectre/base/directive.rb +148 -0
- data/lib/spectre/base/grammar.rb +269 -0
- data/lib/spectre/base/inputiterator.rb +276 -0
- data/lib/spectre/base/node.rb +393 -0
- data/lib/spectre/base/operators.rb +342 -0
- data/lib/spectre/base/parser.rb +110 -0
- data/lib/spectre/generic.rb +115 -0
- data/lib/spectre/generic/directives.rb +246 -0
- data/lib/spectre/generic/negations.rb +68 -0
- data/lib/spectre/generic/primitives.rb +172 -0
- data/lib/spectre/generic/semanticaction.rb +43 -0
- data/lib/spectre/string.rb +57 -0
- data/lib/spectre/string/additionals.rb +80 -0
- data/lib/spectre/string/directives.rb +51 -0
- data/lib/spectre/string/inputiterator.rb +57 -0
- data/lib/spectre/string/primitives.rb +400 -0
- data/test/base/closure_tests.rb +108 -0
- data/test/base/grammar_tests.rb +97 -0
- data/test/base/operator_tests.rb +335 -0
- data/test/base/semanticaction_tests.rb +53 -0
- data/test/generic/directive_tests.rb +224 -0
- data/test/generic/negation_tests.rb +146 -0
- data/test/generic/primitive_tests.rb +99 -0
- data/test/string/POD2Parser_tests.rb +93 -0
- data/test/string/additional_tests.rb +43 -0
- data/test/string/directive_tests.rb +32 -0
- data/test/string/primitive_tests.rb +173 -0
- data/test/tests.rb +33 -0
- data/test/tutorial/funnymath_tests.rb +57 -0
- data/test/tutorial/html_tests.rb +171 -0
- data/test/tutorial/skipping_tests.rb +60 -0
- metadata +109 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This is Spectre, a parser framework inspired by Boost.Spirit,
|
3
|
+
# which can be found at http://spirit.sourceforge.net/.
|
4
|
+
#
|
5
|
+
# If you want to find out more or need a tutorial, go to
|
6
|
+
# http://spectre.rubyforge.org/
|
7
|
+
# You'll find a nice wiki there!
|
8
|
+
#
|
9
|
+
# Author:: Fabian Streitel (karottenreibe)
|
10
|
+
# Copyright:: Copyright (c) 2009 Fabian Streitel
|
11
|
+
# License:: Boost Software License 1.0
|
12
|
+
# For further information regarding this license, you can go to
|
13
|
+
# http://www.boost.org/LICENSE_1_0.txt
|
14
|
+
# or read the file LICENSE distributed with this software.
|
15
|
+
# Homepage:: http://spectre.rubyforge.org/
|
16
|
+
# Git repo:: http://rubyforge.org/scm/?group_id=7618
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
require 'test/unit'
|
21
|
+
require 'spectre/string'
|
22
|
+
|
23
|
+
class SkippingTests < Test::Unit::TestCase
|
24
|
+
include Spectre
|
25
|
+
include Spectre::StringParsing
|
26
|
+
include Spectre::ShortcutsMixin
|
27
|
+
|
28
|
+
def testSkipping
|
29
|
+
p = char("a") >> char("b") >> char("c")
|
30
|
+
assert_kind_of Match, parse( "abc", p )
|
31
|
+
assert_kind_of Match, parse( " a b c", p )
|
32
|
+
assert_kind_of Match, parse( " ab c", p )
|
33
|
+
|
34
|
+
p = char("a") >> lexeme_d[char("b") >> char("c")]
|
35
|
+
assert_kind_of Match, parse( "abc", p )
|
36
|
+
assert_kind_of Match, parse( " a bc", p )
|
37
|
+
assert_kind_of NilClass, parse( "ab c", p )
|
38
|
+
assert_kind_of NilClass, parse( "a b c", p )
|
39
|
+
|
40
|
+
p = lexeme_d[char("a") >> char("b") >> char("c")]
|
41
|
+
assert_kind_of Match, parse( "abc", p )
|
42
|
+
assert_kind_of Match, parse( " abc", p )
|
43
|
+
assert_kind_of NilClass, parse( "ab c", p )
|
44
|
+
assert_kind_of NilClass, parse( "a b c", p )
|
45
|
+
|
46
|
+
p = char("a") >> nopreskip_d[lexeme_d[char("b") >> char("c")]]
|
47
|
+
assert_kind_of Match, parse( "abc", p )
|
48
|
+
assert_kind_of Match, parse( " abc", p )
|
49
|
+
assert_kind_of NilClass, parse( "ab c", p )
|
50
|
+
assert_kind_of NilClass, parse( "a bc", p )
|
51
|
+
|
52
|
+
p = char("a") >> lexeme_d![char("b") >> char("c")]
|
53
|
+
assert_kind_of Match, parse( "abc", p )
|
54
|
+
assert_kind_of Match, parse( " abc", p )
|
55
|
+
assert_kind_of NilClass, parse( "ab c", p )
|
56
|
+
assert_kind_of NilClass, parse( "a bc", p )
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Spectre
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fabian Streitel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-12 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: karottenreibe @nospam@ gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- CHANGELOG
|
25
|
+
- LICENSE
|
26
|
+
files:
|
27
|
+
- lib/spectre/base/closure.rb
|
28
|
+
- lib/spectre/base/directive.rb
|
29
|
+
- lib/spectre/base/grammar.rb
|
30
|
+
- lib/spectre/base/inputiterator.rb
|
31
|
+
- lib/spectre/base/node.rb
|
32
|
+
- lib/spectre/base/operators.rb
|
33
|
+
- lib/spectre/base/parser.rb
|
34
|
+
- lib/spectre/base.rb
|
35
|
+
- lib/spectre/generic/directives.rb
|
36
|
+
- lib/spectre/generic/negations.rb
|
37
|
+
- lib/spectre/generic/primitives.rb
|
38
|
+
- lib/spectre/generic/semanticaction.rb
|
39
|
+
- lib/spectre/generic.rb
|
40
|
+
- lib/spectre/string/additionals.rb
|
41
|
+
- lib/spectre/string/directives.rb
|
42
|
+
- lib/spectre/string/inputiterator.rb
|
43
|
+
- lib/spectre/string/primitives.rb
|
44
|
+
- lib/spectre/string.rb
|
45
|
+
- test/base
|
46
|
+
- test/base/closure_tests.rb
|
47
|
+
- test/base/grammar_tests.rb
|
48
|
+
- test/base/operator_tests.rb
|
49
|
+
- test/base/semanticaction_tests.rb
|
50
|
+
- test/generic
|
51
|
+
- test/generic/directive_tests.rb
|
52
|
+
- test/generic/negation_tests.rb
|
53
|
+
- test/generic/primitive_tests.rb
|
54
|
+
- test/string
|
55
|
+
- test/string/additional_tests.rb
|
56
|
+
- test/string/directive_tests.rb
|
57
|
+
- test/string/POD2Parser_tests.rb
|
58
|
+
- test/string/primitive_tests.rb
|
59
|
+
- test/tests.rb
|
60
|
+
- test/tutorial
|
61
|
+
- test/tutorial/funnymath_tests.rb
|
62
|
+
- test/tutorial/html_tests.rb
|
63
|
+
- test/tutorial/skipping_tests.rb
|
64
|
+
- CHANGELOG
|
65
|
+
- LICENSE
|
66
|
+
- Rakefile
|
67
|
+
- README
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://spectre.rubyforge.org/
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: spectre
|
90
|
+
rubygems_version: 1.3.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 2
|
93
|
+
summary: This is Spectre, a parser framework inspired by Boost.Spirit.
|
94
|
+
test_files:
|
95
|
+
- test/base/closure_tests.rb
|
96
|
+
- test/base/grammar_tests.rb
|
97
|
+
- test/base/operator_tests.rb
|
98
|
+
- test/base/semanticaction_tests.rb
|
99
|
+
- test/generic/directive_tests.rb
|
100
|
+
- test/generic/negation_tests.rb
|
101
|
+
- test/generic/primitive_tests.rb
|
102
|
+
- test/string/additional_tests.rb
|
103
|
+
- test/string/directive_tests.rb
|
104
|
+
- test/string/POD2Parser_tests.rb
|
105
|
+
- test/string/primitive_tests.rb
|
106
|
+
- test/tests.rb
|
107
|
+
- test/tutorial/funnymath_tests.rb
|
108
|
+
- test/tutorial/html_tests.rb
|
109
|
+
- test/tutorial/skipping_tests.rb
|