Class: Code::Parser::Dictionnary
Instance Method Summary
collapse
Methods inherited from Language
<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |
Instance Method Details
#closing_curly_bracket ⇒ Object
28
29
30
|
# File 'lib/code/parser/dictionnary.rb', line 28
def closing_curly_bracket
str("}")
end
|
4
5
6
|
# File 'lib/code/parser/dictionnary.rb', line 4
def code
::Code::Parser::Code.new.present
end
|
36
37
38
|
# File 'lib/code/parser/dictionnary.rb', line 36
def colon
str(":")
end
|
32
33
34
|
# File 'lib/code/parser/dictionnary.rb', line 32
def comma
str(",")
end
|
40
41
42
|
# File 'lib/code/parser/dictionnary.rb', line 40
def equal
str("=")
end
|
44
45
46
|
# File 'lib/code/parser/dictionnary.rb', line 44
def greater
str(">")
end
|
#key_value ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/code/parser/dictionnary.rb', line 48
def key_value
(name.aka(:name) << colon << code.aka(:value)) |
(statement.aka(:statement) << colon << code.aka(:value)) |
(
statement.aka(:statement) << whitespace? << equal << greater <<
code.aka(:value)
)
end
|
12
13
14
|
# File 'lib/code/parser/dictionnary.rb', line 12
def name
::Code::Parser::Name
end
|
#opening_curly_bracket ⇒ Object
24
25
26
|
# File 'lib/code/parser/dictionnary.rb', line 24
def opening_curly_bracket
str("{")
end
|
57
58
59
60
61
62
63
64
|
# File 'lib/code/parser/dictionnary.rb', line 57
def root
(
opening_curly_bracket.ignore << whitespace? <<
key_value.repeat(0, 1) <<
(whitespace? << comma << whitespace? << key_value).repeat <<
(whitespace? << closing_curly_bracket.ignore).maybe
).aka(:dictionnary) | ::Code::Parser::List
end
|
#statement ⇒ Object
8
9
10
|
# File 'lib/code/parser/dictionnary.rb', line 8
def statement
::Code::Parser::Statement
end
|
#whitespace ⇒ Object
16
17
18
|
# File 'lib/code/parser/dictionnary.rb', line 16
def whitespace
::Code::Parser::Whitespace
end
|
#whitespace? ⇒ Boolean
20
21
22
|
# File 'lib/code/parser/dictionnary.rb', line 20
def whitespace?
whitespace.maybe
end
|