Module: Coradoc::Parser::Asciidoc::AttributeList

Included in:
Base, Base
Defined in:
lib/coradoc/parser/asciidoc/attribute_list.rb

Instance Method Summary collapse

Instance Method Details

#attribute_list(name = :attribute_list) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 53

def attribute_list(name = :attribute_list)
  str('[') >> str("[").absent? >> 
  ( named_many |
    positional_one_named_many |
    positional_many_named_many |
    positional_many |
    positional_zero_or_one
  ).as(:attribute_array).as(name) >>
  str("]")
end

#named_attributeObject



14
15
16
17
18
19
20
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 14

def named_attribute
  (match('[a-zA-Z0-9_-]').repeat(1).as(:named_key) >>
    str(' ').maybe >> str("=") >> str(' ').maybe >>
    match['a-zA-Z0-9_\- \"'].repeat(1).as(:named_value) >>
    str(' ').maybe
    ).as(:named)
end

#named_attribute_nameObject



6
7
8
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 6

def named_attribute_name
  attribute_name
end

#named_attribute_valueObject



10
11
12
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 10

def named_attribute_value
  match('[^\],]').repeat(1)
end

#named_manyObject



28
29
30
31
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 28

def named_many
  (named_attribute.repeat(1,1) >>
      (str(",") >> space.maybe >> named_attribute).repeat(0))
end

#positional_attributeObject



22
23
24
25
26
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 22

def positional_attribute
  (match['a-zA-Z0-9_\-%'].repeat(1) >>
    str("=").absent?
    ).as(:positional)
end

#positional_manyObject



44
45
46
47
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 44

def positional_many
  (positional_attribute.repeat(1,1) >>
    (str(",") >> space.maybe >> positional_attribute).repeat(0))
end

#positional_many_named_manyObject



38
39
40
41
42
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 38

def positional_many_named_many
  (positional_attribute.repeat(1,1) >>
    (str(",") >> space.maybe >> positional_attribute).repeat(1) >>
    (str(",") >> space.maybe>> named_attribute).repeat(1))
end

#positional_one_named_manyObject



33
34
35
36
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 33

def positional_one_named_many
  (positional_attribute.repeat(1,1) >>
    (str(",") >> space.maybe >> named_attribute).repeat(1))
end

#positional_zero_or_oneObject



49
50
51
# File 'lib/coradoc/parser/asciidoc/attribute_list.rb', line 49

def positional_zero_or_one
  positional_attribute.repeat(0,1)
end