lib-ruby-parser (C++ bindings)  4.0.1+ruby-3.1.1
C++ bindings for lib-ruby-parser library
lib_ruby_parser::Sym Class Reference

#include <nodes.hpp>

Public Attributes

Bytes name
 
MaybeLoc begin_l
 
MaybeLoc end_l
 
Loc expression_l
 

Detailed Description

Represents a plain symbol literal (i.e. :foo)

Note that : in { foo: bar } belongs to a pair node.

Member Data Documentation

◆ begin_l

MaybeLoc lib_ruby_parser::Sym::begin_l

Location of the symbol begin

:foo
^

None if symbol is a label ({ foo: 1 }) or a part of the symbols array (i[foo bar baz])

◆ end_l

MaybeLoc lib_ruby_parser::Sym::end_l

Location of the symbol end

{ 'foo': 1 }
^

None if symbol is not a string label (:foo) or a part of the symbols array (i[foo bar baz])

◆ expression_l

Loc lib_ruby_parser::Sym::expression_l

Location of the full expression

:foo
^^^^
{ foo: 1 }
^^^^
%i[foo]
^^^

◆ name

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.


The documentation for this class was generated from the following file: