sun::ast::CharLiteralAST

sun::ast::CharLiteralAST

class · Source (opens in a new tab)

class sun::ast::CharLiteralAST : public sun::ast::ExprAST

A character literal ('a', type char) or a byte literal (b'a', type u8).

Both are their own node rather than a flag on NumberExprAST: an integer literal takes its type from context, and these two do not. A char is always a char and b'a' is always a u8, so they must be immune to the literal coercion that keys off ASTNodeType::NUMBER.

Inherits

Public Functions

CharLiteralAST

public · function · Source (opens in a new tab)

sun::ast::CharLiteralAST::CharLiteralAST(uint32_t value, bool isByte)

Creates this syntax node and takes ownership of any supplied child expressions.

dotLabel

public · function · Source (opens in a new tab)

std::string sun::ast::CharLiteralAST::dotLabel() const override

Returns the node label used in syntax-tree graph visualizations.

getType

public · function · Source (opens in a new tab)

ASTNodeType sun::ast::CharLiteralAST::getType() const override

Returns the syntax-node kind used to dispatch tree visitors.

Related: ASTNodeType

getValue

public · function · Source (opens in a new tab)

uint32_t sun::ast::CharLiteralAST::getValue() const

Returns the value represented by this object.

isByte

public · function · Source (opens in a new tab)

bool sun::ast::CharLiteralAST::isByte() const

Reports whether this syntax node represents a byte literal rather than a Unicode character.

toString

public · function · Source (opens in a new tab)

std::string sun::ast::CharLiteralAST::toString() const override

A readable spelling for diagnostics and the AST dump.

The formatter does not use this — it reprints literals verbatim from the source.

Private Fields

isByte_

private · variable · Source (opens in a new tab)

bool sun::ast::CharLiteralAST::isByte_

No documentation comment.

value_

private · variable · Source (opens in a new tab)

uint32_t sun::ast::CharLiteralAST::value_

No documentation comment.