Class: Code::Parser::String

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

Instance Method Summary collapse

Instance Method Details

#backslashObject



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

def backslash
  str('\\')
end

#closing_curly_bracketObject



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

def closing_curly_bracket
  str("}")
end

#codeObject



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

def code
  Code
end

#code_partObject



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

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

#colonObject



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

def colon
  str(":")
end

#double_quoteObject



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

def double_quote
  str('"')
end

#double_quoted_stringObject



65
66
67
68
69
# File 'lib/code/parser/string.rb', line 65

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



51
52
53
54
55
56
57
# File 'lib/code/parser/string.rb', line 51

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



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

def name
  Name
end

#opening_curly_bracketObject



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

def opening_curly_bracket
  str("{")
end

#rootObject



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

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

#single_quoteObject



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

def single_quote
  str("'")
end

#single_quoted_stringObject



59
60
61
62
63
# File 'lib/code/parser/string.rb', line 59

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



43
44
45
46
47
48
49
# File 'lib/code/parser/string.rb', line 43

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



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

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