lib-ruby-parser (C++ bindings)
4.0.1+ruby-3.1.1
C++ bindings for lib-ruby-parser library
|
#include <nodes.hpp>
Public Attributes | |
Bytes | name |
MaybeLoc | begin_l |
MaybeLoc | end_l |
Loc | expression_l |
Represents a plain symbol literal (i.e. :foo
)
Note that :
in { foo: bar }
belongs to a pair
node.
MaybeLoc lib_ruby_parser::Sym::begin_l |
Location of the symbol begin
None
if symbol is a label ({ foo: 1 }
) or a part of the symbols array (i[foo bar baz]
)
MaybeLoc lib_ruby_parser::Sym::end_l |
Location of the symbol end
None
if symbol is not a string label (:foo
) or a part of the symbols array (i[foo bar baz]
)
Loc lib_ruby_parser::Sym::expression_l |
Location of the full expression
Bytes lib_ruby_parser::Sym::name |
Value of the symbol literal
Note that it's a StringValue
, not a String
. The reason is that you can get UTF-8 incompatible strings from a valid UTF-8 source using escape sequences like "\xFF"
These "\", "x", "F", "F" chars are valid separately, but together they construct a char with code = 255 that is invalid for UTF-8.
You can use to_string_lossy
or to_string
methods to get a raw symbol value.