Ruby  3.4.0dev (2024-11-05 revision e440268d51fe02b303e3817a7a733a0dac1c5091)
Data Fields
pm_lex_callback_t Struct Reference

When you are lexing through a file, the lexer needs all of the information that the parser additionally provides (for example, the local table). More...

#include <parser.h>

Data Fields

void * data
 This opaque pointer is used to provide whatever information the user deemed necessary to the callback. More...
 
void(* callback )(void *data, pm_parser_t *parser, pm_token_t *token)
 This is the callback that is called when a token is lexed. More...
 

Detailed Description

When you are lexing through a file, the lexer needs all of the information that the parser additionally provides (for example, the local table).

So if you want to properly lex Ruby, you need to actually lex it in the context of the parser. In order to provide this functionality, we optionally allow a struct to be attached to the parser that calls back out to a user-provided callback when each token is lexed.

Definition at line 506 of file parser.h.

Field Documentation

◆ callback

void(* pm_lex_callback_t::callback) (void *data, pm_parser_t *parser, pm_token_t *token)

This is the callback that is called when a token is lexed.

It is passed the opaque data pointer, the parser, and the token that was lexed.

Definition at line 518 of file parser.h.

◆ data

void* pm_lex_callback_t::data

This opaque pointer is used to provide whatever information the user deemed necessary to the callback.

In our case we use it to pass the array that the tokens get appended into.

Definition at line 512 of file parser.h.

Referenced by pm_serialize_lex(), and pm_serialize_parse_lex().


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