tcalc 0.2.0
 
Loading...
Searching...
No Matches
tcalc::ast::ParserContext Class Reference

Wrapper around the tokenizer to provide a context for parsing. More...

#include <parser.hpp>

Public Member Functions

TCALC_INLINE auto & tokenizer () const noexcept
 Get tokenizer.
 
TCALC_INLINE auto & current () const noexcept
 Get current token.
 
error::Result< void > eat (token::TokenType type)
 Eat the current token and get the next one.
 
error::Result< void > eat ()
 Eat the current token and get the next one.
 

Static Public Member Functions

static error::Result< ParserContextcreate (std::string_view input)
 Create a new parser context.
 

Detailed Description

Wrapper around the tokenizer to provide a context for parsing.

Member Function Documentation

◆ create()

error::Result< ParserContext > tcalc::ast::ParserContext::create ( std::string_view  input)
static

Create a new parser context.

Parameters
inputThe input string to parse.
Returns
error::Result<ParserContext> The parser context result.

◆ current()

TCALC_INLINE auto & tcalc::ast::ParserContext::current ( ) const
inlinenoexcept

Get current token.

Returns
const token::Token& The current token.

◆ eat() [1/2]

error::Result< void > tcalc::ast::ParserContext::eat ( )

Eat the current token and get the next one.

Returns
error::Result<void> The result of the operation.

◆ eat() [2/2]

error::Result< void > tcalc::ast::ParserContext::eat ( token::TokenType  type)

Eat the current token and get the next one.

Parameters
typeThe type of token to eat.
Returns
error::Result<void> The result of the operation.

◆ tokenizer()

TCALC_INLINE auto & tcalc::ast::ParserContext::tokenizer ( ) const
inlinenoexcept

Get tokenizer.

Returns
const token::Tokenizer& The tokenizer.

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