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, IgnoredWhitespace, Line, Problem, Substitution, UnquotedText, Value
Constant Summary
collapse
- Token =
Hocon::Impl::Token
- TokenType =
Hocon::Impl::TokenType
- ConfigNumber =
Hocon::Impl::ConfigNumber
- ConfigInt =
Hocon::Impl::ConfigInt
- ConfigDouble =
Hocon::Impl::ConfigDouble
- ConfigString =
Hocon::Impl::ConfigString
- ConfigNull =
Hocon::Impl::ConfigNull
- ConfigBoolean =
Hocon::Impl::ConfigBoolean
- ResolveStatus =
Hocon::Impl::ResolveStatus
- ConfigBugOrBrokenError =
Hocon::ConfigError::ConfigBugOrBrokenError
- 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
-
.get_problem_what(token) ⇒ Object
-
.get_substitution_optional(token) ⇒ Object
-
.get_substitution_path_expression(token) ⇒ Object
-
.ignored_whitespace?(token) ⇒ Boolean
-
.new_boolean(origin, value) ⇒ Object
-
.new_comment_double_slash(origin, text) ⇒ Object
-
.new_comment_hash(origin, text) ⇒ Object
-
.new_double(origin, value, orig_text) ⇒ Object
-
.new_ignored_whitespace(origin, s) ⇒ Object
-
.new_int(origin, value, orig_text) ⇒ Object
-
.new_line(origin) ⇒ Object
-
.new_long(origin, value, orig_text) ⇒ Object
-
.new_null(origin) ⇒ Object
-
.new_problem(origin, what, message, suggest_quotes, cause) ⇒ Object
-
.new_string(origin, value, orig_text) ⇒ Object
-
.new_substitution(origin, optional, expression) ⇒ Object
-
.new_unquoted_text(origin, s) ⇒ Object
-
.new_value(value, orig_text = nil) ⇒ Object
-
.newline?(t) ⇒ Boolean
-
.problem?(t) ⇒ Boolean
-
.substitution?(token) ⇒ 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
346
347
348
|
# File 'lib/hocon/impl/tokens.rb', line 346
def self.(t)
t.is_a?(Comment)
end
|
350
351
352
353
354
355
356
|
# File 'lib/hocon/impl/tokens.rb', line 350
def self.(token)
if (token)
token.text
else
raise ConfigBugOrBrokenError, "tried to get comment text from #{token}"
end
end
|
.get_problem_cause(token) ⇒ Object
338
339
340
341
342
343
344
|
# File 'lib/hocon/impl/tokens.rb', line 338
def self.get_problem_cause(token)
if token.is_a?(Problem)
token.cause
else
raise ConfigBugOrBrokenError.new("tried to get problem cause from #{token}")
end
end
|
.get_problem_message(token) ⇒ Object
322
323
324
325
326
327
328
|
# File 'lib/hocon/impl/tokens.rb', line 322
def self.get_problem_message(token)
if token.is_a?(Problem)
token.message
else
raise ConfigBugOrBrokenError.new("tried to get problem message from #{token}")
end
end
|
.get_problem_suggest_quotes(token) ⇒ Object
330
331
332
333
334
335
336
|
# File 'lib/hocon/impl/tokens.rb', line 330
def self.get_problem_suggest_quotes(token)
if token.is_a?(Problem)
token.suggest_quotes
else
raise ConfigBugOrBrokenError.new("tried to get problem suggest_quotes from #{token}")
end
end
|
.get_problem_what(token) ⇒ Object
314
315
316
317
318
319
320
|
# File 'lib/hocon/impl/tokens.rb', line 314
def self.get_problem_what(token)
if token.is_a?(Problem)
token.what
else
raise ConfigBugOrBrokenError, "tried to get problem what from #{token}"
end
end
|
.get_substitution_optional(token) ⇒ Object
386
387
388
389
390
391
392
|
# File 'lib/hocon/impl/tokens.rb', line 386
def self.get_substitution_optional(token)
if token.is_a?(Substitution)
token.optional?
else
raise ConfigBugOrBrokenError, "tried to get substitution optionality from #{token}"
end
end
|
.get_substitution_path_expression(token) ⇒ Object
378
379
380
381
382
383
384
|
# File 'lib/hocon/impl/tokens.rb', line 378
def self.get_substitution_path_expression(token)
if token.is_a?(Substitution)
token.value
else
raise ConfigBugOrBrokenError, "tried to get substitution from #{token}"
end
end
|
.ignored_whitespace?(token) ⇒ Boolean
370
371
372
|
# File 'lib/hocon/impl/tokens.rb', line 370
def self.ignored_whitespace?(token)
token.is_a?(IgnoredWhitespace)
end
|
.new_boolean(origin, value) ⇒ Object
457
458
459
|
# File 'lib/hocon/impl/tokens.rb', line 457
def self.new_boolean(origin, value)
new_value(ConfigBoolean.new(origin, value), value.to_s)
end
|
417
418
419
|
# File 'lib/hocon/impl/tokens.rb', line 417
def self.(origin, text)
Comment::HashComment.new(origin, text)
end
|
.new_double(origin, value, orig_text) ⇒ Object
445
446
447
|
# File 'lib/hocon/impl/tokens.rb', line 445
def self.new_double(origin, value, orig_text)
new_value(ConfigNumber.new_number(origin, value, orig_text), orig_text)
end
|
.new_ignored_whitespace(origin, s) ⇒ Object
425
426
427
|
# File 'lib/hocon/impl/tokens.rb', line 425
def self.new_ignored_whitespace(origin, s)
IgnoredWhitespace.new(origin, s)
end
|
.new_int(origin, value, orig_text) ⇒ Object
441
442
443
|
# File 'lib/hocon/impl/tokens.rb', line 441
def self.new_int(origin, value, orig_text)
new_value(ConfigNumber.new_number(origin, value, orig_text), orig_text)
end
|
.new_line(origin) ⇒ Object
405
406
407
|
# File 'lib/hocon/impl/tokens.rb', line 405
def self.new_line(origin)
Line.new(origin)
end
|
.new_long(origin, value, orig_text) ⇒ Object
449
450
451
|
# File 'lib/hocon/impl/tokens.rb', line 449
def self.new_long(origin, value, orig_text)
new_value(ConfigNumber.new_number(origin, value, orig_text), orig_text)
end
|
.new_null(origin) ⇒ Object
453
454
455
|
# File 'lib/hocon/impl/tokens.rb', line 453
def self.new_null(origin)
new_value(ConfigNull.new(origin), "null")
end
|
.new_problem(origin, what, message, suggest_quotes, cause) ⇒ Object
409
410
411
|
# File 'lib/hocon/impl/tokens.rb', line 409
def self.new_problem(origin, what, message, suggest_quotes, cause)
Problem.new(origin, what, message, suggest_quotes, cause)
end
|
.new_string(origin, value, orig_text) ⇒ Object
437
438
439
|
# File 'lib/hocon/impl/tokens.rb', line 437
def self.new_string(origin, value, orig_text)
new_value(ConfigString::Quoted.new(origin, value), orig_text)
end
|
.new_substitution(origin, optional, expression) ⇒ Object
429
430
431
|
# File 'lib/hocon/impl/tokens.rb', line 429
def self.new_substitution(origin, optional, expression)
Substitution.new(origin, optional, expression)
end
|
.new_unquoted_text(origin, s) ⇒ Object
421
422
423
|
# File 'lib/hocon/impl/tokens.rb', line 421
def self.new_unquoted_text(origin, s)
UnquotedText.new(origin, s)
end
|
.new_value(value, orig_text = nil) ⇒ Object
433
434
435
|
# File 'lib/hocon/impl/tokens.rb', line 433
def self.new_value(value, orig_text = nil)
Value.new(value, orig_text)
end
|
.newline?(t) ⇒ Boolean
306
307
308
|
# File 'lib/hocon/impl/tokens.rb', line 306
def self.newline?(t)
t.is_a?(Line)
end
|
.problem?(t) ⇒ Boolean
310
311
312
|
# File 'lib/hocon/impl/tokens.rb', line 310
def self.problem?(t)
t.is_a?(Problem)
end
|
.substitution?(token) ⇒ Boolean
374
375
376
|
# File 'lib/hocon/impl/tokens.rb', line 374
def self.substitution?(token)
token.is_a?(Substitution)
end
|
.unquoted_text(token) ⇒ Object
362
363
364
365
366
367
368
|
# File 'lib/hocon/impl/tokens.rb', line 362
def self.unquoted_text(token)
if unquoted_text?(token)
token.value
else
raise ConfigBugOrBrokenError, "tried to get unquoted text from #{token}"
end
end
|
.unquoted_text?(token) ⇒ Boolean
358
359
360
|
# File 'lib/hocon/impl/tokens.rb', line 358
def self.unquoted_text?(token)
token.is_a?(UnquotedText)
end
|
.value(token) ⇒ Object
294
295
296
297
298
299
300
|
# File 'lib/hocon/impl/tokens.rb', line 294
def self.value(token)
if token.is_a?(Value)
token.value
else
raise ConfigBugOrBrokenError, "tried to get value of non-value token #{token}"
end
end
|
.value?(token) ⇒ Boolean
290
291
292
|
# File 'lib/hocon/impl/tokens.rb', line 290
def self.value?(token)
token.is_a?(Value)
end
|
.value_with_type?(t, value_type) ⇒ Boolean
302
303
304
|
# File 'lib/hocon/impl/tokens.rb', line 302
def self.value_with_type?(t, value_type)
value?(t) && (value(t).value_type == value_type)
end
|