Class: Code::Parser::String

Inherits:
Language show all
Defined in:
lib/code/parser/string.rb

Instance Method Summary collapse

Methods inherited from Language

<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |

Instance Method Details

#backslashObject



20
21
22
# File 'lib/code/parser/string.rb', line 20

def backslash
  str("\\")
end

#closing_curly_bracketObject



28
29
30
# File 'lib/code/parser/string.rb', line 28

def closing_curly_bracket
  str("}")
end

#codeObject



4
5
6
# File 'lib/code/parser/string.rb', line 4

def code
  ::Code::Parser::Code
end

#code_partObject



36
37
38
# File 'lib/code/parser/string.rb', line 36

def code_part
  opening_curly_bracket << code << closing_curly_bracket.maybe
end

#colonObject



32
33
34
# File 'lib/code/parser/string.rb', line 32

def colon
  str(":")
end

#double_quoteObject



16
17
18
# File 'lib/code/parser/string.rb', line 16

def double_quote
  str('"')
end

#double_quoted_stringObject



62
63
64
65
66
# File 'lib/code/parser/string.rb', line 62

def double_quoted_string
  double_quote.ignore <<
    (code_part.aka(:code) | double_quoted_text_part.aka(:text)).repeat <<
    double_quote.ignore.maybe
end

#double_quoted_text_partObject



48
49
50
51
52
53
54
# File 'lib/code/parser/string.rb', line 48

def double_quoted_text_part
  (
    backslash.ignore << opening_curly_bracket |
      backslash.ignore << double_quote |
      double_quote.absent << opening_curly_bracket.absent << any
  ).repeat(1)
end

#nameObject



8
9
10
# File 'lib/code/parser/string.rb', line 8

def name
  ::Code::Parser::Name
end

#opening_curly_bracketObject



24
25
26
# File 'lib/code/parser/string.rb', line 24

def opening_curly_bracket
  str("{")
end

#rootObject



72
73
74
75
# File 'lib/code/parser/string.rb', line 72

def root
  (single_quoted_string | double_quoted_string | symbol).aka(:string) |
    ::Code::Parser::Number
end

#single_quoteObject



12
13
14
# File 'lib/code/parser/string.rb', line 12

def single_quote
  str("'")
end

#single_quoted_stringObject



56
57
58
59
60
# File 'lib/code/parser/string.rb', line 56

def single_quoted_string
  single_quote.ignore <<
    (code_part.aka(:code) | single_quoted_text_part.aka(:text)).repeat <<
    single_quote.ignore.maybe
end

#single_quoted_text_partObject



40
41
42
43
44
45
46
# File 'lib/code/parser/string.rb', line 40

def single_quoted_text_part
  (
    backslash.ignore << opening_curly_bracket |
      backslash.ignore << single_quote |
      single_quote.absent << opening_curly_bracket.absent << any
  ).repeat(1)
end

#symbolObject



68
69
70
# File 'lib/code/parser/string.rb', line 68

def symbol
  (colon.ignore << name).aka(:text).repeat(1, 1)
end