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
# File 'lib/code/parser/string.rb', line 38

def code_part
  opening_curly_bracket << code << closing_curly_bracket.maybe
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



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

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



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

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



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

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



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

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



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

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



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

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