Ruby: include/ruby/internal/intern/parse.h File Reference

Ruby 3.4.7p58 (2025-10-08 revision 7a5688e2a27668e48f8d6ff4af5b2208b98a2f5e)

Functions
parse.h File Reference

Public APIs related to rb_cSymbol. More...

`#include "ruby/internal/attr/const.h"`
`#include "ruby/internal/attr/nonnull.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Functions
ID | rb_id_attrset (ID id)
| Calculates an ID of attribute writer.
int | rb_is_const_id (ID id)
| Classifies the given ID, then sees if it is a constant.
int | rb_is_global_id (ID id)
| Classifies the given ID, then sees if it is a global variable.
int | rb_is_instance_id (ID id)
| Classifies the given ID, then sees if it is an instance variable.
int | rb_is_attrset_id (ID id)
| Classifies the given ID, then sees if it is an attribute writer.
int | rb_is_class_id (ID id)
| Classifies the given ID, then sees if it is a class variable.
int | rb_is_local_id (ID id)
| Classifies the given ID, then sees if it is a local variable.
int | rb_is_junk_id (ID)
| Classifies the given ID, then sees if it is a junk ID.
int | rb_symname_p (const char *str)
| Sees if the passed C string constructs a valid syntactic symbol.
VALUE | rb_backref_get (void)
| Queries the last match, or Regexp.last_match, or the $~.
void | rb_backref_set (VALUE md)
| Updates $~.
VALUE | rb_lastline_get (void)
| Queries the last line, or the $_.
void | rb_lastline_set (VALUE str)
| Updates $_.
VALUE | rb_sym_all_symbols (void)
| Collects every single bits of symbols that have ever interned in the entire history of the current process.

## Detailed Description

Public APIs related to rb_cSymbol.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file parse.h.

## Function Documentation

## ◆ rb_backref_get()

VALUE rb_backref_get | ( | void |  | ) |

Queries the last match, or Regexp.last_match, or the $~.

You don't have to use it, because in reality you can get $~ using rb_gv_get() as usual.

Return values

  RUBY_Qnil | The method has not ran a regular expression.
  otherwise | An instance of rb_cMatch.

Definition at line 1835 of file vm.c.

Referenced by rb_f_global_variables().

## ◆ rb_backref_set()

void rb_backref_set | ( | VALUE | md | ) |

Updates $~.

You don't have to use it, because in reality you can set $~ using rb_gv_set() as usual.

Parameters

  [in] | md | Arbitrary Ruby object.

Postcondition
  The passed object is assigned to $~.

Definition at line 1841 of file vm.c.

Referenced by rb_reg_match2().

## ◆ rb_id_attrset()

ID rb_id_attrset | ( | ID | id | ) |

Calculates an ID of attribute writer.

For instance it returns :foo= when passed :foo.

Parameters

  [in] | id | An id.

Exceptions

  rb_eNameError | `id` is not for attributes (e.g. operator).

Returns
  Calculated name of attribute writer.

Definition at line 122 of file symbol.c.

## ◆ rb_is_attrset_id()

int rb_is_attrset_id | ( | ID | id | ) |

Classifies the given ID, then sees if it is an attribute writer.

An attribute writer is otherwise a local variable, except it ends with =.

Parameters

  [in] | id | An id to classify.

Return values

  1 | It is an attribute writer.
  0 | It isn't.

Definition at line 1088 of file symbol.c.

## ◆ rb_is_class_id()

int rb_is_class_id | ( | ID | id | ) |

Classifies the given ID, then sees if it is a class variable.

A class variable is must start with @@.

Parameters

  [in] | id | An id to classify.

Return values

  1 | It is a class variable.
  0 | It isn't.

Definition at line 1070 of file symbol.c.

## ◆ rb_is_const_id()

int rb_is_const_id | ( | ID | id | ) |

Classifies the given ID, then sees if it is a constant.

In case an ID is in Unicode (likely), its "constant"-ness is determined if its first character is either upper case or title case. Otherwise it is detected if case- folding the first character changes its case or not.

Parameters

  [in] | id | An id to classify.

Return values

  1 | It is a constant.
  0 | It isn't.

Definition at line 1064 of file symbol.c.

Referenced by rb_define_const().

## ◆ rb_is_global_id()

int rb_is_global_id | ( | ID | id | ) |

Classifies the given ID, then sees if it is a global variable.

A global variable must start with $.

Parameters

  [in] | id | An id to classify.

Return values

  1 | It is a global variable.
  0 | It isn't.

Definition at line 1076 of file symbol.c.

## ◆ rb_is_instance_id()

int rb_is_instance_id | ( | ID | id | ) |

Classifies the given ID, then sees if it is an instance variable.

An instance variable must start with @, but not @@.

Parameters

  [in] | id | An id to classify.

Return values

  1 | It is an instance variable.
  0 | It isn't.

Definition at line 1082 of file symbol.c.

## ◆ rb_is_junk_id()

int rb_is_junk_id | ( | ID | id | ) |

Classifies the given ID, then sees if it is a junk ID.

An ID with no special syntactic structure is considered junk. This category includes for instance punctuation.

Parameters

  [in] | id | An id to classify.

Return values

  1 | It is a junk.
  0 | It isn't.

Definition at line 1100 of file symbol.c.

## ◆ rb_is_local_id()

int rb_is_local_id | ( | ID | id | ) |

Classifies the given ID, then sees if it is a local variable.

A local variable starts with a lowercase character, followed by some alphanumeric characters or _, then ends with anything other than !, ?, or =.

Parameters

  [in] | id | An id to classify.

Return values

  1 | It is a local variable.
  0 | It isn't.

Definition at line 1094 of file symbol.c.

## ◆ rb_lastline_get()

VALUE rb_lastline_get | ( | void |  | ) |

Queries the last line, or the $_.

You don't have to use it, because in reality you can get $_ using rb_gv_get() as usual.

Return values

  RUBY_Qnil | There has never been a "line" yet.
  otherwise | The last set $_ value.

Definition at line 1847 of file vm.c.

Referenced by rb_io_print(), and rb_reg_match2().

## ◆ rb_lastline_set()

void rb_lastline_set | ( | VALUE | str | ) |

Updates $_.

You don't have to use it, because in reality you can set $_ using rb_gv_set() as usual.

Parameters

  [in] | str | Arbitrary Ruby object.

Postcondition
  The passed object is assigned to $_.

Definition at line 1853 of file vm.c.

Referenced by rb_gets().

## ◆ rb_sym_all_symbols()

VALUE rb_sym_all_symbols | ( | void |  | ) |

Collects every single bits of symbols that have ever interned in the entire history of the current process.

Returns
  An array that contains all symbols that have ever existed.

Definition at line 1043 of file symbol.c.

## ◆ rb_symname_p()

int rb_symname_p | ( | const char * | str | ) |

Sees if the passed C string constructs a valid syntactic symbol.

Invalid ones for instance includes whitespaces.

Parameters

  [in] | str | A C string to check.

Return values

  1 | It is a valid symbol name.
  0 | It is invalid as a symbol name.

Definition at line 206 of file symbol.c.