Class: Hocon::Impl::Tokens
- Inherits:
-
Object
- Object
- Hocon::Impl::Tokens
show all
- Defined in:
- lib/hocon/impl/tokens.rb
Overview
FIXME the way the subclasses of Token are private with static isFoo and accessors is kind of ridiculous.
Defined Under Namespace
Classes: Comment, Line, Problem, Substitution, UnquotedText, Value
Constant Summary
collapse
- Token =
Hocon::Impl::Token
- TokenType =
Hocon::Impl::TokenType
- ConfigNumber =
Hocon::Impl::ConfigNumber
- ConfigString =
Hocon::Impl::ConfigString
- ConfigBoolean =
Hocon::Impl::ConfigBoolean
- START =
Token.new_without_origin(TokenType::START, "start of file")
- EOF =
Token.new_without_origin(TokenType::EOF, "end of file")
- COMMA =
Token.new_without_origin(TokenType::COMMA, "','")
- EQUALS =
Token.new_without_origin(TokenType::EQUALS, "'='")
- COLON =
Token.new_without_origin(TokenType::COLON, "':'")
- OPEN_CURLY =
Token.new_without_origin(TokenType::OPEN_CURLY, "'{'")
- CLOSE_CURLY =
Token.new_without_origin(TokenType::CLOSE_CURLY, "'}'")
- OPEN_SQUARE =
Token.new_without_origin(TokenType::OPEN_SQUARE, "'['")
- CLOSE_SQUARE =
Token.new_without_origin(TokenType::CLOSE_SQUARE, "']'")
- PLUS_EQUALS =
Token.new_without_origin(TokenType::PLUS_EQUALS, "'+='")
Class Method Summary
collapse
-
.comment?(t) ⇒ Boolean
-
.comment_text(token) ⇒ Object
-
.get_problem_cause(token) ⇒ Object
-
.get_problem_message(token) ⇒ Object
-
.get_problem_suggest_quotes(token) ⇒ Object
-
.new_boolean(origin, value) ⇒ Object
-
.new_comment(origin, text) ⇒ Object
-
.new_line(origin) ⇒ Object
-
.new_long(origin, value, original_text) ⇒ Object
-
.new_problem(origin, what, message, suggest_quotes, cause) ⇒ Object
-
.new_string(origin, value) ⇒ Object
-
.new_unquoted_text(origin, s) ⇒ Object
-
.new_value(value) ⇒ Object
-
.newline?(t) ⇒ Boolean
-
.problem?(t) ⇒ Boolean
-
.substitution?(t) ⇒ Boolean
-
.unquoted_text(token) ⇒ Object
-
.unquoted_text?(token) ⇒ Boolean
-
.value(token) ⇒ Object
-
.value?(token) ⇒ Boolean
-
.value_with_type?(t, value_type) ⇒ Boolean
Class Method Details
157
158
159
|
# File 'lib/hocon/impl/tokens.rb', line 157
def self.(t)
t.is_a?(Comment)
end
|
161
162
163
164
165
166
167
|
# File 'lib/hocon/impl/tokens.rb', line 161
def self.(token)
if (token)
token.text
else
raise ConfigBugError, "tried to get comment text from #{token}"
end
end
|
.get_problem_cause(token) ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/hocon/impl/tokens.rb', line 117
def self.get_problem_cause(token)
if token.is_a?(Problem)
token.cause
else
raise Hocon::ConfigError::ConfigBugOrBrokenError.new("tried to get problem cause from #{token}", nil)
end
end
|
.get_problem_message(token) ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/hocon/impl/tokens.rb', line 101
def self.get_problem_message(token)
if token.is_a?(Problem)
token.message
else
raise Hocon::ConfigError::ConfigBugOrBrokenError.new("tried to get problem message from #{token}", nil)
end
end
|
.get_problem_suggest_quotes(token) ⇒ Object
109
110
111
112
113
114
115
|
# File 'lib/hocon/impl/tokens.rb', line 109
def self.get_problem_suggest_quotes(token)
if token.is_a?(Problem)
token.suggest_quotes
else
raise Hocon::ConfigError::ConfigBugOrBrokenError.new("tried to get problem suggest_quotes from #{token}", nil)
end
end
|
.new_boolean(origin, value) ⇒ Object
153
154
155
|
# File 'lib/hocon/impl/tokens.rb', line 153
def self.new_boolean(origin, value)
new_value(ConfigBoolean.new(origin, value))
end
|
133
134
135
|
# File 'lib/hocon/impl/tokens.rb', line 133
def self.(origin, text)
Comment.new(origin, text)
end
|
.new_line(origin) ⇒ Object
125
126
127
|
# File 'lib/hocon/impl/tokens.rb', line 125
def self.new_line(origin)
Line.new(origin)
end
|
.new_long(origin, value, original_text) ⇒ Object
149
150
151
|
# File 'lib/hocon/impl/tokens.rb', line 149
def self.new_long(origin, value, original_text)
new_value(ConfigNumber.new_number(origin, value, original_text))
end
|
.new_problem(origin, what, message, suggest_quotes, cause) ⇒ Object
129
130
131
|
# File 'lib/hocon/impl/tokens.rb', line 129
def self.new_problem(origin, what, message, suggest_quotes, cause)
Problem.new(origin, what, message, suggest_quotes, cause)
end
|
.new_string(origin, value) ⇒ Object
145
146
147
|
# File 'lib/hocon/impl/tokens.rb', line 145
def self.new_string(origin, value)
new_value(ConfigString.new(origin, value))
end
|
.new_unquoted_text(origin, s) ⇒ Object
137
138
139
|
# File 'lib/hocon/impl/tokens.rb', line 137
def self.new_unquoted_text(origin, s)
UnquotedText.new(origin, s)
end
|
.new_value(value) ⇒ Object
141
142
143
|
# File 'lib/hocon/impl/tokens.rb', line 141
def self.new_value(value)
Value.new(value)
end
|
.newline?(t) ⇒ Boolean
201
202
203
|
# File 'lib/hocon/impl/tokens.rb', line 201
def self.newline?(t)
t.is_a?(Line)
end
|
.problem?(t) ⇒ Boolean
205
206
207
|
# File 'lib/hocon/impl/tokens.rb', line 205
def self.problem?(t)
t.is_a?(Problem)
end
|
.substitution?(t) ⇒ Boolean
169
170
171
|
# File 'lib/hocon/impl/tokens.rb', line 169
def self.substitution?(t)
t.is_a?(Substitution)
end
|
.unquoted_text(token) ⇒ Object
177
178
179
180
181
182
183
|
# File 'lib/hocon/impl/tokens.rb', line 177
def self.unquoted_text(token)
if unquoted_text?(token)
token.value
else
raise ConfigBugError, "tried to get unquoted text from #{token}"
end
end
|
.unquoted_text?(token) ⇒ Boolean
173
174
175
|
# File 'lib/hocon/impl/tokens.rb', line 173
def self.unquoted_text?(token)
token.is_a?(UnquotedText)
end
|
.value(token) ⇒ Object
189
190
191
192
193
194
195
|
# File 'lib/hocon/impl/tokens.rb', line 189
def self.value(token)
if token.is_a?(Value)
token.value
else
raise ConfigBugError, "tried to get value of non-value token #{token}"
end
end
|
.value?(token) ⇒ Boolean
185
186
187
|
# File 'lib/hocon/impl/tokens.rb', line 185
def self.value?(token)
token.is_a?(Value)
end
|
.value_with_type?(t, value_type) ⇒ Boolean
197
198
199
|
# File 'lib/hocon/impl/tokens.rb', line 197
def self.value_with_type?(t, value_type)
value?(t) && (value(t).value_type == value_type)
end
|