Class: Code::Parser::Name

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

Instance Method Summary collapse

Instance Method Details

#ampersandObject



66
67
68
# File 'lib/code/parser/name.rb', line 66

def ampersand
  str("&")
end

#asteriskObject



78
79
80
# File 'lib/code/parser/name.rb', line 78

def asterisk
  str("*")
end

#begin_keywordObject



86
87
88
# File 'lib/code/parser/name.rb', line 86

def begin_keyword
  str("begin")
end

#characterObject



154
155
156
# File 'lib/code/parser/name.rb', line 154

def character
  reserved_character.absent << any
end

#closing_curly_bracketObject



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

def closing_curly_bracket
  str("}")
end

#closing_parenthesisObject



46
47
48
# File 'lib/code/parser/name.rb', line 46

def closing_parenthesis
  str(")")
end

#closing_square_bracketObject



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

def closing_square_bracket
  str("]")
end

#colonObject



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

def colon
  str(":")
end

#commaObject



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

def comma
  str(",")
end

#do_keywordObject



82
83
84
# File 'lib/code/parser/name.rb', line 82

def do_keyword
  str("do")
end

#dotObject



58
59
60
# File 'lib/code/parser/name.rb', line 58

def dot
  str(".")
end

#double_quoteObject



54
55
56
# File 'lib/code/parser/name.rb', line 54

def double_quote
  str('"')
end

#else_keywordObject



98
99
100
# File 'lib/code/parser/name.rb', line 98

def else_keyword
  str("else")
end

#elsif_keywordObject



94
95
96
# File 'lib/code/parser/name.rb', line 94

def elsif_keyword
  str("elsif")
end

#elsunless_keywordObject



118
119
120
# File 'lib/code/parser/name.rb', line 118

def elsunless_keyword
  str("elsunless")
end

#end_keywordObject



90
91
92
# File 'lib/code/parser/name.rb', line 90

def end_keyword
  str("end")
end

#equalObject



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

def equal
  str("=")
end

#exclamation_markObject



134
135
136
# File 'lib/code/parser/name.rb', line 134

def exclamation_mark
  str("!")
end

#false_keywordObject



126
127
128
# File 'lib/code/parser/name.rb', line 126

def false_keyword
  str("false")
end

#greaterObject



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

def greater
  str(">")
end

#if_keywordObject



110
111
112
# File 'lib/code/parser/name.rb', line 110

def if_keyword
  str("if")
end

#keywordObject



166
167
168
169
170
171
# File 'lib/code/parser/name.rb', line 166

def keyword
  do_keyword | begin_keyword | end_keyword | while_keyword |
    until_keyword | if_keyword | elsif_keyword | else_keyword |
    unless_keyword | elsunless_keyword | true_keyword | false_keyword |
    nothing_keyword
end

#lesserObject



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

def lesser
  str("<")
end

#newlineObject



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

def newline
  str("\n")
end

#nothing_keywordObject



130
131
132
# File 'lib/code/parser/name.rb', line 130

def nothing_keyword
  str("nothing")
end

#opening_curly_bracketObject



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

def opening_curly_bracket
  str("{")
end

#opening_parenthesisObject



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

def opening_parenthesis
  str("(")
end

#opening_square_bracketObject



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

def opening_square_bracket
  str("[")
end

#pipeObject



62
63
64
# File 'lib/code/parser/name.rb', line 62

def pipe
  str("|")
end

#question_markObject



138
139
140
# File 'lib/code/parser/name.rb', line 138

def question_mark
  str("?")
end

#reserved_characterObject



146
147
148
149
150
151
152
# File 'lib/code/parser/name.rb', line 146

def reserved_character
  ampersand | equal | pipe | dot | colon | comma | space | newline |
    opening_curly_bracket | closing_curly_bracket | opening_parenthesis |
    closing_parenthesis | opening_square_bracket |
    closing_square_bracket | single_quote | double_quote | lesser |
    greater | asterisk
end

#rootObject



173
174
175
176
177
178
179
180
181
# File 'lib/code/parser/name.rb', line 173

def root
  (
    (special_name << separator.ignore) |
      (
        (keyword << separator).absent << special_characters.absent <<
          character.repeat(1)
      )
  )
end

#separatorObject



158
159
160
# File 'lib/code/parser/name.rb', line 158

def separator
  reserved_character | any.absent
end

#single_quoteObject



50
51
52
# File 'lib/code/parser/name.rb', line 50

def single_quote
  str("'")
end

#spaceObject



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

def space
  str(" ")
end

#special_charactersObject



162
163
164
# File 'lib/code/parser/name.rb', line 162

def special_characters
  exclamation_mark | question_mark
end

#special_nameObject



142
143
144
# File 'lib/code/parser/name.rb', line 142

def special_name
  str("...") | str("..") | str(".") | str("**") | str("*") | str("&")
end

#true_keywordObject



122
123
124
# File 'lib/code/parser/name.rb', line 122

def true_keyword
  str("true")
end

#unless_keywordObject



114
115
116
# File 'lib/code/parser/name.rb', line 114

def unless_keyword
  str("unless")
end

#until_keywordObject



106
107
108
# File 'lib/code/parser/name.rb', line 106

def until_keyword
  str("until")
end

#while_keywordObject



102
103
104
# File 'lib/code/parser/name.rb', line 102

def while_keyword
  str("while")
end