6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/pubid/parser/common_parse_rules.rb', line 6
def self.included(base)
base.class_eval do
rule(:space) { str(" ") }
rule(:space?) { space.maybe }
rule(:digits) do
match('\d').repeat(1)
end
rule(:year) do
match('\d').repeat(4, 4).as(:year)
end
rule(:comma) { str(", ") }
rule(:comma?) { comma.maybe }
rule(:comma_space) { comma | space }
rule(:dash) { str("-") }
rule(:dot) { str(".") }
rule(:words_digits) { match('[\dA-Za-z]').repeat(1) }
rule(:words) { match("[A-Za-z]").repeat(1) }
rule(:words?) { words.maybe }
rule(:year_digits) do
(str("19") | str("20")) >> match('\d').repeat(2,
2) >> digits.absent?
end
rule(:month_digits) do
match('\d').repeat(2, 2)
end
rule(:day_digits) do
match('\d').repeat(2, 2)
end
rule(:originator) do
organization.as(:publisher) >>
(space? >> str("/") >> organization.as(:copublisher)).repeat
end
rule(:comma_month_year) do
comma >> words.as(:month) >> space >> year_digits.as(:year)
end
rule(:year_month) do
year_digits >> dash >> month_digits
end
end
end
|