Class: Code::Parser::String

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

Instance Method Summary collapse

Instance Method Details

#backslashObject



26
27
28
# File 'lib/code/parser/string.rb', line 26

def backslash
  str('\\')
end

#closing_curly_bracketObject



34
35
36
# File 'lib/code/parser/string.rb', line 34

def closing_curly_bracket
  str("}")
end

#codeObject



6
7
8
# File 'lib/code/parser/string.rb', line 6

def code
  Code
end

#code_partObject



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

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

#colonObject



38
39
40
# File 'lib/code/parser/string.rb', line 38

def colon
  str(":")
end

#double_quoteObject



22
23
24
# File 'lib/code/parser/string.rb', line 22

def double_quote
  str('"')
end

#double_quoted_stringObject



69
70
71
72
73
# File 'lib/code/parser/string.rb', line 69

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



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

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

#label_nameObject



14
15
16
# File 'lib/code/parser/string.rb', line 14

def label_name
  LabelName
end

#nameObject



10
11
12
# File 'lib/code/parser/string.rb', line 10

def name
  Name
end

#opening_curly_bracketObject



30
31
32
# File 'lib/code/parser/string.rb', line 30

def opening_curly_bracket
  str("{")
end

#rootObject



79
80
81
82
# File 'lib/code/parser/string.rb', line 79

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

#single_quoteObject



18
19
20
# File 'lib/code/parser/string.rb', line 18

def single_quote
  str("'")
end

#single_quoted_stringObject



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

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



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

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



75
76
77
# File 'lib/code/parser/string.rb', line 75

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