GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
rust-parse.c File Reference
#include "defs.h"
#include "block.h"
#include "charset.h"
#include "cp-support.h"
#include "gdbsupport/gdb_obstack.h"
#include "gdbsupport/gdb_regex.h"
#include "rust-lang.h"
#include "parser-defs.h"
#include "gdbsupport/selftest.h"
#include "value.h"
#include "gdbarch.h"
#include "rust-exp.h"

Go to the source code of this file.

Classes

struct  typed_val_int
 
struct  typed_val_float
 
struct  token_info
 
struct  rust_parser
 
struct  rust_parser::current_string_val
 
struct  rustop_item
 

Macros

#define FLOAT_TYPE1   3
 
#define FLOAT_TYPE2   4
 
#define INT_TEXT   5
 
#define INT_TYPE   6
 
#define NUM_SUBEXPRESSIONS   8
 
#define ALL_OPS
 
#define ASSIGN_PREC   0
 
#define OPERATION(TOKEN, PRECEDENCE, TYPE)
 
#define OPERATION(TOKEN, PRECEDENCE, TYPE)
 

Enumerations

enum  token_type : int {
  GDBVAR = 256 , IDENT , COMPLETE , INTEGER ,
  DECIMAL_INTEGER , STRING , BYTESTRING , FLOAT ,
  COMPOUND_ASSIGN , KW_AS , KW_IF , KW_TRUE ,
  KW_FALSE , KW_SUPER , KW_SELF , KW_MUT ,
  KW_EXTERN , KW_CONST , KW_FN , KW_SIZEOF ,
  DOTDOT , DOTDOTEQ , OROR , ANDAND ,
  EQEQ , NOTEQ , LTEQ , GTEQ ,
  LSH , RSH , COLONCOLON , ARROW
}
 

Functions

static void munge_name_and_block (const char **name, const struct block **block)
 
static uint32_t lex_multibyte_char (const char *text, int *len)
 
static int starts_raw_string (const char *str)
 
static bool ends_raw_string (const char *str, int n)
 
static bool space_then_number (const char *string)
 
static bool rust_identifier_start_p (char c)
 
void _initialize_rust_exp ()
 

Variables

static const char number_regex_text []
 
static regex_t number_regex
 
static const struct token_info identifier_tokens []
 
static const struct token_info operator_tokens []
 

Macro Definition Documentation

◆ ALL_OPS

#define ALL_OPS
Value:
OPERATION ('*', 10, mul_operation) \
OPERATION ('/', 10, div_operation) \
OPERATION ('%', 10, rem_operation) \
OPERATION ('@', 9, repeat_operation) \
OPERATION ('+', 8, add_operation) \
OPERATION ('-', 8, sub_operation) \
OPERATION (LSH, 7, lsh_operation) \
OPERATION (RSH, 7, rsh_operation) \
OPERATION ('&', 6, bitwise_and_operation) \
OPERATION ('^', 5, bitwise_xor_operation) \
OPERATION ('|', 4, bitwise_ior_operation) \
OPERATION (EQEQ, 3, equal_operation) \
OPERATION (NOTEQ, 3, notequal_operation) \
OPERATION ('<', 3, less_operation) \
OPERATION (LTEQ, 3, leq_operation) \
OPERATION ('>', 3, gtr_operation) \
OPERATION (GTEQ, 3, geq_operation) \
OPERATION (ANDAND, 2, logical_and_operation) \
OPERATION (OROR, 1, logical_or_operation)
#define OPERATION(TOKEN, PRECEDENCE, TYPE)
@ OROR
Definition rust-parse.c:113
@ EQEQ
Definition rust-parse.c:115
@ ANDAND
Definition rust-parse.c:114
@ RSH
Definition rust-parse.c:120
@ NOTEQ
Definition rust-parse.c:116
@ LTEQ
Definition rust-parse.c:117
@ LSH
Definition rust-parse.c:119
@ GTEQ
Definition rust-parse.c:118

◆ ASSIGN_PREC

#define ASSIGN_PREC   0

◆ FLOAT_TYPE1

#define FLOAT_TYPE1   3

◆ FLOAT_TYPE2

#define FLOAT_TYPE2   4

◆ INT_TEXT

#define INT_TEXT   5

◆ INT_TYPE

#define INT_TYPE   6

◆ NUM_SUBEXPRESSIONS

#define NUM_SUBEXPRESSIONS   8

Definition at line 76 of file rust-parse.c.

Referenced by rust_parser::lex_number(), ui_file_style::parse(), and skip_ansi_escape().

◆ OPERATION [1/2]

#define OPERATION ( TOKEN,
PRECEDENCE,
TYPE )
Value:
case TOKEN: \
precedence = PRECEDENCE; \
lex (); \
break;

◆ OPERATION [2/2]

#define OPERATION ( TOKEN,
PRECEDENCE,
TYPE )
Value:
case TOKEN: \
lhs.op = make_operation<TYPE> (std::move (lhs.op), \
std::move (rhs.op)); \
break;

Enumeration Type Documentation

◆ token_type

enum token_type : int
Enumerator
GDBVAR 
IDENT 
COMPLETE 
INTEGER 
DECIMAL_INTEGER 
STRING 
BYTESTRING 
FLOAT 
COMPOUND_ASSIGN 
KW_AS 
KW_IF 
KW_TRUE 
KW_FALSE 
KW_SUPER 
KW_SELF 
KW_MUT 
KW_EXTERN 
KW_CONST 
KW_FN 
KW_SIZEOF 
DOTDOT 
DOTDOTEQ 
OROR 
ANDAND 
EQEQ 
NOTEQ 
LTEQ 
GTEQ 
LSH 
RSH 
COLONCOLON 
ARROW 

Definition at line 84 of file rust-parse.c.

Function Documentation

◆ _initialize_rust_exp()

void _initialize_rust_exp ( )

Definition at line 2421 of file rust-parse.c.

Referenced by initialize_all_files().

◆ ends_raw_string()

static bool ends_raw_string ( const char * str,
int n )
static

Definition at line 673 of file rust-parse.c.

Referenced by rust_parser::lex_string().

◆ lex_multibyte_char()

static uint32_t lex_multibyte_char ( const char * text,
int * len )
static

◆ munge_name_and_block()

static void munge_name_and_block ( const char ** name,
const struct block ** block )
static

Definition at line 417 of file rust-parse.c.

References name, and block::static_block().

Referenced by rust_parser::lookup_symbol(), and rust_parser::rust_lookup_type().

◆ rust_identifier_start_p()

static bool rust_identifier_start_p ( char c)
static

◆ space_then_number()

static bool space_then_number ( const char * string)
static

Definition at line 760 of file rust-parse.c.

Referenced by rust_parser::lex_identifier().

◆ starts_raw_string()

static int starts_raw_string ( const char * str)
static

Definition at line 655 of file rust-parse.c.

Referenced by rust_parser::lex_one_token(), and rust_parser::lex_string().

Variable Documentation

◆ identifier_tokens

const struct token_info identifier_tokens[]
static
Initial value:
=
{
{ "as", KW_AS, OP_NULL },
{ "false", KW_FALSE, OP_NULL },
{ "if", 0, OP_NULL },
{ "mut", KW_MUT, OP_NULL },
{ "const", KW_CONST, OP_NULL },
{ "self", KW_SELF, OP_NULL },
{ "super", KW_SUPER, OP_NULL },
{ "true", KW_TRUE, OP_NULL },
{ "extern", KW_EXTERN, OP_NULL },
{ "fn", KW_FN, OP_NULL },
{ "sizeof", KW_SIZEOF, OP_NULL },
}
@ KW_TRUE
Definition rust-parse.c:100
@ KW_SIZEOF
Definition rust-parse.c:108
@ KW_EXTERN
Definition rust-parse.c:105
@ KW_FALSE
Definition rust-parse.c:101
@ KW_SELF
Definition rust-parse.c:103
@ KW_MUT
Definition rust-parse.c:104
@ KW_CONST
Definition rust-parse.c:106
@ KW_FN
Definition rust-parse.c:107
@ KW_AS
Definition rust-parse.c:98
@ KW_SUPER
Definition rust-parse.c:102

Definition at line 152 of file rust-parse.c.

Referenced by rust_parser::lex_identifier().

◆ number_regex

regex_t number_regex
static

Definition at line 80 of file rust-parse.c.

Referenced by rust_parser::lex_number().

◆ number_regex_text

const char number_regex_text[]
static
Initial value:
=
"^("
"[0-9][0-9_]*\\.[0-9][0-9_]*([eE][-+]?[0-9][0-9_]*)?(f32|f64)?"
#define FLOAT_TYPE1
"|"
#define FLOAT_TYPE2
"[0-9][0-9_]*[eE][-+]?[0-9][0-9_]*(f32|f64)?"
"|"
"[0-9][0-9_]*\\."
"|"
#define INT_TEXT
#define INT_TYPE
"(0x[a-fA-F0-9_]+|0o[0-7_]+|0b[01_]+|[0-9][0-9_]*)"
"([iu](size|8|16|32|64|128))?"
")"

Definition at line 40 of file rust-parse.c.

◆ operator_tokens

const struct token_info operator_tokens[]
static
Initial value:
=
{
{ ">>=", COMPOUND_ASSIGN, BINOP_RSH },
{ "<<=", COMPOUND_ASSIGN, BINOP_LSH },
{ "<<", LSH, OP_NULL },
{ ">>", RSH, OP_NULL },
{ "&&", ANDAND, OP_NULL },
{ "||", OROR, OP_NULL },
{ "==", EQEQ, OP_NULL },
{ "!=", NOTEQ, OP_NULL },
{ "<=", LTEQ, OP_NULL },
{ ">=", GTEQ, OP_NULL },
{ "+=", COMPOUND_ASSIGN, BINOP_ADD },
{ "-=", COMPOUND_ASSIGN, BINOP_SUB },
{ "*=", COMPOUND_ASSIGN, BINOP_MUL },
{ "/=", COMPOUND_ASSIGN, BINOP_DIV },
{ "%=", COMPOUND_ASSIGN, BINOP_REM },
{ "&=", COMPOUND_ASSIGN, BINOP_BITWISE_AND },
{ "|=", COMPOUND_ASSIGN, BINOP_BITWISE_IOR },
{ "^=", COMPOUND_ASSIGN, BINOP_BITWISE_XOR },
{ "..=", DOTDOTEQ, OP_NULL },
{ "::", COLONCOLON, OP_NULL },
{ "..", DOTDOT, OP_NULL },
{ "->", ARROW, OP_NULL }
}
@ ARROW
Definition rust-parse.c:122
@ COMPOUND_ASSIGN
Definition rust-parse.c:95
@ DOTDOTEQ
Definition rust-parse.c:112
@ DOTDOT
Definition rust-parse.c:111
@ COLONCOLON
Definition rust-parse.c:121

Definition at line 169 of file rust-parse.c.

Referenced by rust_parser::lex_operator().