rparsec 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/rparsec.rb +2 -2
- data/rparsec/context.rb +81 -66
- data/rparsec/error.rb +22 -19
- data/rparsec/expressions.rb +179 -136
- data/rparsec/functors.rb +270 -249
- data/rparsec/id_monad.rb +13 -11
- data/rparsec/keywords.rb +101 -89
- data/rparsec/locator.rb +36 -32
- data/rparsec/misc.rb +109 -102
- data/rparsec/monad.rb +57 -51
- data/rparsec/operators.rb +116 -109
- data/rparsec/parser.rb +892 -794
- data/rparsec/parser_monad.rb +19 -16
- data/rparsec/parsers.rb +614 -603
- data/rparsec/token.rb +23 -20
- data/test/src/simple_monad_test.rb +21 -21
- metadata +49 -41
data/rparsec/token.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
|
-
require 'rparsec/misc'
|
2
|
-
|
3
|
-
#
|
4
|
-
# This class represents a token during lexical analysis.
|
5
|
-
#
|
6
|
-
class Token
|
7
|
-
extend DefHelper
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
require 'rparsec/misc'
|
2
|
+
|
3
|
+
#
|
4
|
+
# This class represents a token during lexical analysis.
|
5
|
+
#
|
6
|
+
class Token
|
7
|
+
extend DefHelper
|
8
|
+
|
9
|
+
def_readable :kind, :text, :index
|
10
|
+
|
11
|
+
#
|
12
|
+
# The length of the token.
|
13
|
+
#
|
14
|
+
def length
|
15
|
+
@text.length
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# String representation of the token.
|
20
|
+
#
|
21
|
+
def to_s
|
22
|
+
"#{@kind}: #{@text}"
|
23
|
+
end
|
21
24
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require 'import'
|
2
|
-
require 'runit/testcase'
|
3
|
-
import :id_monad, :monad
|
4
|
-
|
5
|
-
class Idm
|
6
|
-
include Monad
|
7
|
-
MyMonad = IdMonad.new
|
8
|
-
def initialize(v)
|
9
|
-
initMonad(MyMonad, v);
|
10
|
-
end
|
11
|
-
def to_s
|
12
|
-
@obj.to_s
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class SimpleMonadTest < RUNIT::TestCase
|
17
|
-
def test1
|
18
|
-
assert 20, Idm.new(10).map{|i|i*2}
|
19
|
-
assert 10, Idm.new(10).plus(Idm.new(20))
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require 'import'
|
2
|
+
require 'runit/testcase'
|
3
|
+
import :id_monad, :monad
|
4
|
+
|
5
|
+
class Idm
|
6
|
+
include Monad
|
7
|
+
MyMonad = IdMonad.new
|
8
|
+
def initialize(v)
|
9
|
+
initMonad(MyMonad, v);
|
10
|
+
end
|
11
|
+
def to_s
|
12
|
+
@obj.to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class SimpleMonadTest < RUNIT::TestCase
|
17
|
+
def test1
|
18
|
+
assert 20, Idm.new(10).map{|i|i*2}
|
19
|
+
assert 10, Idm.new(10).plus(Idm.new(20))
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: rparsec
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date:
|
6
|
+
version: 0.4.2
|
7
|
+
date: 2008-04-09 00:00:00 -05:00
|
8
8
|
summary: A Ruby Parser Combinator Framework
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- .
|
11
11
|
email: ajoo.email@gmail.com
|
12
12
|
homepage:
|
13
13
|
rubyforge_project:
|
@@ -18,50 +18,58 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
27
29
|
authors:
|
28
|
-
|
30
|
+
- Ben Yu
|
29
31
|
files:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
- rparsec/context.rb
|
33
|
+
- rparsec/error.rb
|
34
|
+
- rparsec/expressions.rb
|
35
|
+
- rparsec/functors.rb
|
36
|
+
- rparsec/id_monad.rb
|
37
|
+
- rparsec/keywords.rb
|
38
|
+
- rparsec/locator.rb
|
39
|
+
- rparsec/misc.rb
|
40
|
+
- rparsec/monad.rb
|
41
|
+
- rparsec/operators.rb
|
42
|
+
- rparsec/parser.rb
|
43
|
+
- rparsec/parser_monad.rb
|
44
|
+
- rparsec/parsers.rb
|
45
|
+
- rparsec/token.rb
|
46
|
+
- rparsec.rb
|
45
47
|
test_files:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
48
|
+
- test/src/expression_test.rb
|
49
|
+
- test/src/full_parser_test.rb
|
50
|
+
- test/src/functor_test.rb
|
51
|
+
- test/src/import.rb
|
52
|
+
- test/src/keyword_test.rb
|
53
|
+
- test/src/operator_test.rb
|
54
|
+
- test/src/parser_test.rb
|
55
|
+
- test/src/perf_benchmark.rb
|
56
|
+
- test/src/s_expression_test.rb
|
57
|
+
- test/src/scratch.rb
|
58
|
+
- test/src/simple_monad_test.rb
|
59
|
+
- test/src/simple_parser_test.rb
|
60
|
+
- test/src/sql.rb
|
61
|
+
- test/src/sql_parser.rb
|
62
|
+
- test/src/sql_test.rb
|
63
|
+
- test/src/tests.rb
|
62
64
|
rdoc_options: []
|
65
|
+
|
63
66
|
extra_rdoc_files: []
|
67
|
+
|
64
68
|
executables: []
|
69
|
+
|
65
70
|
extensions: []
|
71
|
+
|
66
72
|
requirements: []
|
67
|
-
|
73
|
+
|
74
|
+
dependencies: []
|
75
|
+
|