citrus 3.0.1 → 3.0.2
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.
- checksums.yaml +4 -4
- data/README.md +18 -18
- data/citrus.gemspec +1 -1
- data/doc/example.markdown +1 -1
- data/doc/index.markdown +1 -1
- data/lib/citrus.rb +5 -5
- data/lib/citrus/version.rb +1 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d8b5389cb9cd24e66e80cccf3919854caa40f2a
|
4
|
+
data.tar.gz: fb65be9111329304a3c6e14d469799ae5fcd939a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3ea3ad5c127c4496350c36545abeeadd632ef61c070733e7fc2878767681e54c69434aa71e3f7cf2f5725d0ca0261288d1bb9aaed7ffa41ffccb7d8d253511a
|
7
|
+
data.tar.gz: 0ba669d11e232d8060cad7a1e6c1d116e41eef1bcfac3a98707bdbdea2ced9fb5c386a21f5aaeb3e0b28f1d0fae39188a6c27a106aae3dde8af654cac85aa18d
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ Via [RubyGems](http://rubygems.org/):
|
|
15
15
|
|
16
16
|
From a local copy:
|
17
17
|
|
18
|
-
$ git clone git://github.com/
|
18
|
+
$ git clone git://github.com/mjackson/citrus.git
|
19
19
|
$ cd citrus
|
20
20
|
$ rake package install
|
21
21
|
|
@@ -47,7 +47,7 @@ In Citrus, there are three main types of objects: rules, grammars, and matches.
|
|
47
47
|
|
48
48
|
## Rules
|
49
49
|
|
50
|
-
A [Rule](http://
|
50
|
+
A [Rule](http://mjackson.github.io/citrus/api/classes/Citrus/Rule.html) is an object
|
51
51
|
that specifies some matching behavior on a string. There are two types of rules:
|
52
52
|
terminals and non-terminals. Terminals can be either Ruby strings or regular
|
53
53
|
expressions that specify some input to match. For example, a terminal created
|
@@ -65,7 +65,7 @@ of Ruby modules. Rules use these modules to extend the matches they create.
|
|
65
65
|
|
66
66
|
## Grammars
|
67
67
|
|
68
|
-
A [Grammar](http://
|
68
|
+
A [Grammar](http://mjackson.github.io/citrus/api/classes/Citrus/Grammar.html) is a
|
69
69
|
container for rules. Usually the rules in a grammar collectively form a complete
|
70
70
|
specification for some language, or a well-defined subset thereof.
|
71
71
|
|
@@ -79,7 +79,7 @@ Ruby's `super` keyword.
|
|
79
79
|
|
80
80
|
## Matches
|
81
81
|
|
82
|
-
A [Match](http://
|
82
|
+
A [Match](http://mjackson.github.io/citrus/api/classes/Citrus/Match.html) object
|
83
83
|
represents a successful recognition of some piece of the input. Matches are
|
84
84
|
created by rule objects during a parse.
|
85
85
|
|
@@ -128,8 +128,8 @@ match in a case-insensitive manner.
|
|
128
128
|
Besides case sensitivity, case-insensitive strings have the same behavior as
|
129
129
|
double quoted strings.
|
130
130
|
|
131
|
-
See [Terminal](http://
|
132
|
-
[StringTerminal](http://
|
131
|
+
See [Terminal](http://mjackson.github.io/citrus/api/classes/Citrus/Terminal.html) and
|
132
|
+
[StringTerminal](http://mjackson.github.io/citrus/api/classes/Citrus/StringTerminal.html)
|
133
133
|
for more information.
|
134
134
|
|
135
135
|
## Repetition
|
@@ -153,7 +153,7 @@ The `+` and `?` operators are supported as well for the common cases of `1*` and
|
|
153
153
|
'abc'+ # match "abc" one or more times
|
154
154
|
'abc'? # match "abc" zero or one time
|
155
155
|
|
156
|
-
See [Repeat](http://
|
156
|
+
See [Repeat](http://mjackson.github.io/citrus/api/classes/Citrus/Repeat.html) for
|
157
157
|
more information.
|
158
158
|
|
159
159
|
## Lookahead
|
@@ -175,9 +175,9 @@ that does not match a given expression.
|
|
175
175
|
When using this operator (the tilde), at least one character must be consumed
|
176
176
|
for the rule to succeed.
|
177
177
|
|
178
|
-
See [AndPredicate](http://
|
179
|
-
[NotPredicate](http://
|
180
|
-
and [ButPredicate](http://
|
178
|
+
See [AndPredicate](http://mjackson.github.io/citrus/api/classes/Citrus/AndPredicate.html),
|
179
|
+
[NotPredicate](http://mjackson.github.io/citrus/api/classes/Citrus/NotPredicate.html),
|
180
|
+
and [ButPredicate](http://mjackson.github.io/citrus/api/classes/Citrus/ButPredicate.html)
|
181
181
|
for more information.
|
182
182
|
|
183
183
|
## Sequences
|
@@ -188,7 +188,7 @@ should match in that order.
|
|
188
188
|
'a' 'b' 'c' # match "a", then "b", then "c"
|
189
189
|
'a' [0-9] # match "a", then a numeric digit
|
190
190
|
|
191
|
-
See [Sequence](http://
|
191
|
+
See [Sequence](http://mjackson.github.io/citrus/api/classes/Citrus/Sequence.html)
|
192
192
|
for more information.
|
193
193
|
|
194
194
|
## Choices
|
@@ -204,7 +204,7 @@ It is important to note when using ordered choice that any operator binds more
|
|
204
204
|
tightly than the vertical bar. A full chart of operators and their respective
|
205
205
|
levels of precedence is below.
|
206
206
|
|
207
|
-
See [Choice](http://
|
207
|
+
See [Choice](http://mjackson.github.io/citrus/api/classes/Citrus/Choice.html) for
|
208
208
|
more information.
|
209
209
|
|
210
210
|
## Labels
|
@@ -263,7 +263,7 @@ In the example above, the `FloatingPoint` grammar includes `Number`. Both have a
|
|
263
263
|
rule named `number`, so `FloatingPoint#number` has access to `Number#number` by
|
264
264
|
means of using `super`.
|
265
265
|
|
266
|
-
See [Super](http://
|
266
|
+
See [Super](http://mjackson.github.io/citrus/api/classes/Citrus/Super.html) for more
|
267
267
|
information.
|
268
268
|
|
269
269
|
## Precedence
|
@@ -343,7 +343,7 @@ and "1 + 2+3", but it does not have enough semantic information to be able to
|
|
343
343
|
actually interpret these expressions.
|
344
344
|
|
345
345
|
At this point, when the grammar parses a string it generates a tree of
|
346
|
-
[Match](http://
|
346
|
+
[Match](http://mjackson.github.io/citrus/api/classes/Citrus/Match.html) objects.
|
347
347
|
Each match is created by a rule and may itself be comprised of any number of
|
348
348
|
submatches.
|
349
349
|
|
@@ -420,14 +420,14 @@ commands in a terminal.
|
|
420
420
|
Congratulations! You just ran your first piece of Citrus code.
|
421
421
|
|
422
422
|
One interesting thing to notice about the above sequence of commands is the
|
423
|
-
return value of [Citrus#load](http://
|
423
|
+
return value of [Citrus#load](http://mjackson.github.io/citrus/api/classes/Citrus.html#M000003).
|
424
424
|
When you use `Citrus.load` to load a grammar file (and likewise
|
425
|
-
[Citrus#eval](http://
|
425
|
+
[Citrus#eval](http://mjackson.github.io/citrus/api/classes/Citrus.html#M000004) to
|
426
426
|
evaluate a raw string of grammar code), the return value is an array of all the
|
427
427
|
grammars present in that file.
|
428
428
|
|
429
429
|
Take a look at
|
430
|
-
[calc.citrus](http://github.com/
|
430
|
+
[calc.citrus](http://github.com/mjackson/citrus/blob/master/lib/citrus/grammars/calc.citrus)
|
431
431
|
for an example of a calculator that is able to parse and evaluate more complex
|
432
432
|
mathematical expressions.
|
433
433
|
|
@@ -535,7 +535,7 @@ made to test equality of match objects with string values.
|
|
535
535
|
|
536
536
|
## Debugging
|
537
537
|
|
538
|
-
When a parse fails, a [ParseError](http://
|
538
|
+
When a parse fails, a [ParseError](http://mjackson.github.io/citrus/api/classes/Citrus/ParseError.html)
|
539
539
|
object is generated which provides a wealth of information about exactly where
|
540
540
|
the parse failed including the offset, line number, line text, and line offset.
|
541
541
|
Using this object, you could possibly provide some useful feedback to the user
|
data/citrus.gemspec
CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.rdoc_options = %w< --line-numbers --inline-source --title Citrus --main Citrus >
|
31
31
|
s.extra_rdoc_files = %w< README.md CHANGES >
|
32
32
|
|
33
|
-
s.homepage = 'http://
|
33
|
+
s.homepage = 'http://mjackson.github.io/citrus'
|
34
34
|
end
|
data/doc/example.markdown
CHANGED
@@ -120,7 +120,7 @@ grammar code), the return value is an array of all the grammars present in that
|
|
120
120
|
file.
|
121
121
|
|
122
122
|
Take a look at
|
123
|
-
[examples/calc.citrus](http://github.com/
|
123
|
+
[examples/calc.citrus](http://github.com/mjackson/citrus/blob/master/examples/calc.citrus)
|
124
124
|
for an example of a calculator that is able to parse and evaluate more complex
|
125
125
|
mathematical expressions.
|
126
126
|
|
data/doc/index.markdown
CHANGED
data/lib/citrus.rb
CHANGED
@@ -8,7 +8,7 @@ require 'citrus/version'
|
|
8
8
|
# elegance and expressiveness of the language with the simplicity and power of
|
9
9
|
# parsing expressions.
|
10
10
|
#
|
11
|
-
# http://
|
11
|
+
# http://mjackson.github.io/citrus
|
12
12
|
module Citrus
|
13
13
|
autoload :File, 'citrus/file'
|
14
14
|
|
@@ -199,7 +199,7 @@ module Citrus
|
|
199
199
|
|
200
200
|
# Returns the 0-based offset of the given +pos+ in the input on the line
|
201
201
|
# on which it is found. +pos+ defaults to the current pointer position.
|
202
|
-
def line_offset(pos=pos)
|
202
|
+
def line_offset(pos=pos())
|
203
203
|
p = 0
|
204
204
|
string.each_line do |line|
|
205
205
|
len = line.length
|
@@ -211,7 +211,7 @@ module Citrus
|
|
211
211
|
|
212
212
|
# Returns the 0-based number of the line that contains the character at the
|
213
213
|
# given +pos+. +pos+ defaults to the current pointer position.
|
214
|
-
def line_index(pos=pos)
|
214
|
+
def line_index(pos=pos())
|
215
215
|
p = n = 0
|
216
216
|
string.each_line do |line|
|
217
217
|
p += line.length
|
@@ -223,7 +223,7 @@ module Citrus
|
|
223
223
|
|
224
224
|
# Returns the 1-based number of the line that contains the character at the
|
225
225
|
# given +pos+. +pos+ defaults to the current pointer position.
|
226
|
-
def line_number(pos=pos)
|
226
|
+
def line_number(pos=pos())
|
227
227
|
line_index(pos) + 1
|
228
228
|
end
|
229
229
|
|
@@ -231,7 +231,7 @@ module Citrus
|
|
231
231
|
|
232
232
|
# Returns the text of the line that contains the character at the given
|
233
233
|
# +pos+. +pos+ defaults to the current pointer position.
|
234
|
-
def line(pos=pos)
|
234
|
+
def line(pos=pos())
|
235
235
|
lines[line_index(pos)]
|
236
236
|
end
|
237
237
|
|
data/lib/citrus/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: citrus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Jackson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Parsing Expressions for Ruby
|
@@ -32,9 +32,13 @@ extra_rdoc_files:
|
|
32
32
|
- README.md
|
33
33
|
- CHANGES
|
34
34
|
files:
|
35
|
+
- CHANGES
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
35
38
|
- benchmark/seqpar.citrus
|
36
39
|
- benchmark/seqpar.gnuplot
|
37
40
|
- benchmark/seqpar.rb
|
41
|
+
- citrus.gemspec
|
38
42
|
- doc/background.markdown
|
39
43
|
- doc/example.markdown
|
40
44
|
- doc/extras.markdown
|
@@ -43,11 +47,11 @@ files:
|
|
43
47
|
- doc/links.markdown
|
44
48
|
- doc/syntax.markdown
|
45
49
|
- doc/testing.markdown
|
50
|
+
- lib/citrus.rb
|
46
51
|
- lib/citrus/core_ext.rb
|
47
52
|
- lib/citrus/file.rb
|
48
53
|
- lib/citrus/grammars.rb
|
49
54
|
- lib/citrus/version.rb
|
50
|
-
- lib/citrus.rb
|
51
55
|
- test/_files/alias.citrus
|
52
56
|
- test/_files/file1.citrus
|
53
57
|
- test/_files/file2.citrus
|
@@ -88,36 +92,32 @@ files:
|
|
88
92
|
- test/string_terminal_test.rb
|
89
93
|
- test/super_test.rb
|
90
94
|
- test/terminal_test.rb
|
91
|
-
|
92
|
-
- Rakefile
|
93
|
-
- README.md
|
94
|
-
- CHANGES
|
95
|
-
homepage: http://mjijackson.com/citrus
|
95
|
+
homepage: http://mjackson.github.io/citrus
|
96
96
|
licenses: []
|
97
97
|
metadata: {}
|
98
98
|
post_install_message:
|
99
99
|
rdoc_options:
|
100
|
-
- --line-numbers
|
101
|
-
- --inline-source
|
102
|
-
- --title
|
100
|
+
- "--line-numbers"
|
101
|
+
- "--inline-source"
|
102
|
+
- "--title"
|
103
103
|
- Citrus
|
104
|
-
- --main
|
104
|
+
- "--main"
|
105
105
|
- Citrus
|
106
106
|
require_paths:
|
107
107
|
- lib
|
108
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.2.2
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Parsing Expressions for Ruby
|