citrus 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ = 2.3.5 / 2011-02-07
2
+
3
+ * Fixed a bug that prevented Match objects from being printed properly using
4
+ Kernel#puts (thanks joachimm).
5
+
6
+ * Fixed a bug that prevented using rules with names that begin with "end"
7
+ (thanks Mark Wilden).
8
+
9
+ * Citrus#require accepts relative file paths, in addition to absolute ones.
10
+
11
+ * Simplified/cleaned up some example files.
12
+
1
13
  = 2.3.4 / 2011-01-17
2
14
 
3
15
  * Added CHANGES file.
data/README CHANGED
@@ -572,13 +572,13 @@ To install the [Vim](http://www.vim.org/) scripts, copy the files in
572
572
 
573
573
  The project source directory contains several example scripts that demonstrate
574
574
  how grammars are to be constructed and used. Each Citrus file in the examples
575
- directory has an accompanying Ruby file with the same name that contains a suite
576
- of tests for that particular file.
575
+ directory has an accompanying Ruby file that contains a suite of tests for that
576
+ particular file.
577
577
 
578
578
  The best way to run any of these examples is to pass the name of the Ruby file
579
579
  directly to the Ruby interpreter on the command line, e.g.:
580
580
 
581
- $ ruby -Ilib examples/calc.rb
581
+ $ ruby -Ilib examples/calc_test.rb
582
582
 
583
583
  This particular invocation uses the `-I` flag to ensure that you are using the
584
584
  version of Citrus that was bundled with that particular example file (i.e. the
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ task :default => :test
6
6
  # TESTS #######################################################################
7
7
 
8
8
  Rake::TestTask.new(:test) do |t|
9
- t.test_files = FileList['test/*_test.rb'] + FileList['examples/*.rb']
9
+ t.test_files = FileList['test/*_test.rb'] + FileList['examples/*_test.rb']
10
10
  end
11
11
 
12
12
  # DOCS ########################################################################
@@ -0,0 +1,192 @@
1
+ 12 0
2
+ 30 0
3
+ 35 0
4
+ 1749 10
5
+ 1962 9
6
+ 2383 9
7
+ 3728 29
8
+ 3919 30
9
+ 3952 30
10
+ 3995 30
11
+ 4063 39
12
+ 4325 30
13
+ 4527 29
14
+ 4570 40
15
+ 4607 39
16
+ 4654 29
17
+ 4679 40
18
+ 4774 39
19
+ 4968 29
20
+ 5059 39
21
+ 5383 49
22
+ 5915 40
23
+ 6109 49
24
+ 6122 49
25
+ 6218 50
26
+ 6332 49
27
+ 6681 59
28
+ 7440 60
29
+ 7530 60
30
+ 7605 60
31
+ 8155 70
32
+ 8402 60
33
+ 8420 60
34
+ 8617 70
35
+ 8635 59
36
+ 8841 70
37
+ 8843 70
38
+ 8852 80
39
+ 9151 69
40
+ 9271 80
41
+ 9521 80
42
+ 9525 69
43
+ 9566 70
44
+ 9584 79
45
+ 9642 70
46
+ 10138 80
47
+ 10181 80
48
+ 10225 80
49
+ 10338 79
50
+ 10449 80
51
+ 10629 80
52
+ 10763 89
53
+ 10817 79
54
+ 11059 80
55
+ 11062 89
56
+ 11215 89
57
+ 11698 89
58
+ 11891 89
59
+ 11945 90
60
+ 11956 89
61
+ 12018 89
62
+ 12053 89
63
+ 12178 100
64
+ 12283 89
65
+ 12326 99
66
+ 12430 99
67
+ 12438 89
68
+ 12572 89
69
+ 12638 100
70
+ 12687 90
71
+ 12703 89
72
+ 12896 99
73
+ 12922 99
74
+ 12996 100
75
+ 13137 110
76
+ 13211 99
77
+ 13462 110
78
+ 13477 109
79
+ 13576 109
80
+ 13577 109
81
+ 13584 99
82
+ 13605 119
83
+ 13631 109
84
+ 14216 109
85
+ 14237 110
86
+ 14260 109
87
+ 14367 120
88
+ 14371 109
89
+ 14741 110
90
+ 14893 129
91
+ 14910 109
92
+ 14917 109
93
+ 14977 109
94
+ 15049 120
95
+ 15191 109
96
+ 15382 120
97
+ 15618 120
98
+ 15623 120
99
+ 15629 120
100
+ 15856 120
101
+ 16496 130
102
+ 16512 130
103
+ 16956 130
104
+ 17074 130
105
+ 17237 129
106
+ 17371 140
107
+ 17568 130
108
+ 17945 139
109
+ 18147 139
110
+ 18343 139
111
+ 18417 139
112
+ 18823 140
113
+ 18970 150
114
+ 19285 150
115
+ 19333 140
116
+ 19500 150
117
+ 19548 149
118
+ 19634 149
119
+ 19673 150
120
+ 19689 160
121
+ 19909 150
122
+ 20054 149
123
+ 20107 150
124
+ 20248 160
125
+ 20580 160
126
+ 20744 160
127
+ 20806 160
128
+ 20954 160
129
+ 21034 160
130
+ 21187 160
131
+ 21303 160
132
+ 21450 160
133
+ 21626 169
134
+ 21931 169
135
+ 21950 169
136
+ 22359 169
137
+ 22626 169
138
+ 22638 169
139
+ 22772 169
140
+ 22885 169
141
+ 22897 170
142
+ 23114 179
143
+ 23242 179
144
+ 23428 180
145
+ 23452 179
146
+ 23495 189
147
+ 23499 180
148
+ 23558 190
149
+ 23744 179
150
+ 23881 180
151
+ 23945 179
152
+ 24361 189
153
+ 24501 190
154
+ 24642 189
155
+ 24672 190
156
+ 24694 190
157
+ 24706 190
158
+ 24931 199
159
+ 25065 189
160
+ 25140 189
161
+ 25402 189
162
+ 25702 199
163
+ 25743 199
164
+ 27139 210
165
+ 27316 209
166
+ 27333 210
167
+ 27414 209
168
+ 27771 220
169
+ 27798 210
170
+ 28583 230
171
+ 28906 219
172
+ 29025 230
173
+ 29209 229
174
+ 29272 219
175
+ 29273 219
176
+ 29359 229
177
+ 29577 220
178
+ 30886 240
179
+ 31170 240
180
+ 31593 240
181
+ 32460 250
182
+ 32486 250
183
+ 32630 250
184
+ 33010 259
185
+ 33137 259
186
+ 33142 250
187
+ 33739 259
188
+ 39880 309
189
+ 39940 319
190
+ 42952 320
191
+ 43227 329
192
+ 52855 420
@@ -0,0 +1,192 @@
1
+ 12 1
2
+ 30 0
3
+ 35 0
4
+ 1749 59
5
+ 1962 30
6
+ 2383 29
7
+ 3728 50
8
+ 3919 50
9
+ 3952 60
10
+ 3995 130
11
+ 4063 49
12
+ 4325 140
13
+ 4527 109
14
+ 4570 50
15
+ 4607 60
16
+ 4654 89
17
+ 4679 80
18
+ 4774 70
19
+ 4968 80
20
+ 5059 159
21
+ 5383 60
22
+ 5915 80
23
+ 6109 119
24
+ 6122 169
25
+ 6218 69
26
+ 6332 70
27
+ 6681 90
28
+ 7440 89
29
+ 7530 129
30
+ 7605 89
31
+ 8155 159
32
+ 8402 169
33
+ 8420 179
34
+ 8617 100
35
+ 8635 119
36
+ 8841 169
37
+ 8843 169
38
+ 8852 140
39
+ 9151 220
40
+ 9271 169
41
+ 9521 199
42
+ 9525 160
43
+ 9566 120
44
+ 9584 170
45
+ 9642 120
46
+ 10138 200
47
+ 10181 119
48
+ 10225 120
49
+ 10338 149
50
+ 10449 199
51
+ 10629 150
52
+ 10763 189
53
+ 10817 199
54
+ 11059 179
55
+ 11062 179
56
+ 11215 190
57
+ 11698 180
58
+ 11891 219
59
+ 11945 209
60
+ 11956 200
61
+ 12018 170
62
+ 12053 139
63
+ 12178 249
64
+ 12283 199
65
+ 12326 170
66
+ 12430 210
67
+ 12438 180
68
+ 12572 189
69
+ 12638 220
70
+ 12687 209
71
+ 12703 170
72
+ 12896 200
73
+ 12922 229
74
+ 12996 169
75
+ 13137 220
76
+ 13211 219
77
+ 13462 289
78
+ 13477 189
79
+ 13576 220
80
+ 13577 179
81
+ 13584 269
82
+ 13605 209
83
+ 13631 219
84
+ 14216 240
85
+ 14237 190
86
+ 14260 199
87
+ 14367 210
88
+ 14371 240
89
+ 14741 289
90
+ 14893 240
91
+ 14910 189
92
+ 14917 250
93
+ 14977 289
94
+ 15049 250
95
+ 15191 209
96
+ 15382 239
97
+ 15618 269
98
+ 15623 239
99
+ 15629 260
100
+ 15856 259
101
+ 16496 310
102
+ 16512 270
103
+ 16956 279
104
+ 17074 239
105
+ 17237 259
106
+ 17371 289
107
+ 17568 350
108
+ 17945 310
109
+ 18147 250
110
+ 18343 279
111
+ 18417 300
112
+ 18823 310
113
+ 18970 290
114
+ 19285 300
115
+ 19333 299
116
+ 19500 319
117
+ 19548 299
118
+ 19634 300
119
+ 19673 309
120
+ 19689 380
121
+ 19909 310
122
+ 20054 299
123
+ 20107 349
124
+ 20248 299
125
+ 20580 300
126
+ 20744 329
127
+ 20806 340
128
+ 20954 279
129
+ 21034 320
130
+ 21187 300
131
+ 21303 280
132
+ 21450 310
133
+ 21626 339
134
+ 21931 370
135
+ 21950 320
136
+ 22359 379
137
+ 22626 320
138
+ 22638 339
139
+ 22772 359
140
+ 22885 359
141
+ 22897 330
142
+ 23114 330
143
+ 23242 329
144
+ 23428 339
145
+ 23452 339
146
+ 23495 370
147
+ 23499 360
148
+ 23558 350
149
+ 23744 359
150
+ 23881 340
151
+ 23945 320
152
+ 24361 339
153
+ 24501 339
154
+ 24642 400
155
+ 24672 340
156
+ 24694 320
157
+ 24706 349
158
+ 24931 350
159
+ 25065 380
160
+ 25140 350
161
+ 25402 379
162
+ 25702 349
163
+ 25743 429
164
+ 27139 420
165
+ 27316 520
166
+ 27333 410
167
+ 27414 370
168
+ 27771 399
169
+ 27798 410
170
+ 28583 370
171
+ 28906 409
172
+ 29025 519
173
+ 29209 390
174
+ 29272 489
175
+ 29273 449
176
+ 29359 480
177
+ 29577 470
178
+ 30886 510
179
+ 31170 469
180
+ 31593 429
181
+ 32460 519
182
+ 32486 500
183
+ 32630 480
184
+ 33010 469
185
+ 33137 489
186
+ 33142 480
187
+ 33739 560
188
+ 39880 599
189
+ 39940 609
190
+ 42952 629
191
+ 43227 620
192
+ 52855 780
@@ -11,8 +11,8 @@ grammar Calc
11
11
  end
12
12
 
13
13
  rule additive
14
- (factor additive_operator term) {
15
- additive_operator.value(factor.value, term.value)
14
+ (factor operator:('+' | '-') space* term) {
15
+ factor.value.send(operator.to_s, term.value)
16
16
  }
17
17
  end
18
18
 
@@ -21,8 +21,8 @@ grammar Calc
21
21
  end
22
22
 
23
23
  rule multiplicative
24
- (prefix multiplicative_operator factor) {
25
- multiplicative_operator.value(prefix.value, factor.value)
24
+ (prefix operator:('*' | '/' | '%') space* factor) {
25
+ prefix.value.send(operator.to_s, factor.value)
26
26
  }
27
27
  end
28
28
 
@@ -31,8 +31,10 @@ grammar Calc
31
31
  end
32
32
 
33
33
  rule prefixed
34
- (unary_operator prefix) {
35
- unary_operator.value(prefix.value)
34
+ (operator:('-' | '+' | '~') space* prefix) {
35
+ s = operator.to_s
36
+ s += '@' unless s == '~' # Unary + and - require an @.
37
+ prefix.value.send(s)
36
38
  }
37
39
  end
38
40
 
@@ -41,8 +43,8 @@ grammar Calc
41
43
  end
42
44
 
43
45
  rule exponential
44
- (primary exponential_operator prefix) {
45
- exponential_operator.value(primary.value, prefix.value)
46
+ (primary operator:'**' space* prefix) {
47
+ primary.value.send(operator.to_s, prefix.value)
46
48
  }
47
49
  end
48
50
 
@@ -63,45 +65,15 @@ grammar Calc
63
65
  end
64
66
 
65
67
  rule float
66
- (digits '.' digits space*) {
67
- strip.to_f
68
- }
68
+ (digits '.' digits space*) { to_f }
69
69
  end
70
70
 
71
71
  rule integer
72
- (digits space*) {
73
- strip.to_i
74
- }
72
+ (digits space*) { to_i }
75
73
  end
76
74
 
77
75
  rule digits
78
- # Numbers may contain underscores in Ruby.
79
- [0-9]+ ('_' [0-9]+)*
80
- end
81
-
82
- rule additive_operator
83
- (('+' | '-') space*) { |a, b|
84
- a.send(strip, b)
85
- }
86
- end
87
-
88
- rule multiplicative_operator
89
- (('*' | '/' | '%') space*) { |a, b|
90
- a.send(strip, b)
91
- }
92
- end
93
-
94
- rule exponential_operator
95
- ('**' space*) { |a, b|
96
- a ** b
97
- }
98
- end
99
-
100
- rule unary_operator
101
- (('~' | '+' | '-') space*) { |n|
102
- # Unary + and - require an @.
103
- n.send(strip == '~' ? strip : '%s@' % strip)
104
- }
76
+ [0-9]+ ('_' [0-9]+)* # Numbers may contain underscores.
105
77
  end
106
78
 
107
79
  rule lparen '(' space* end