Loading...
Searching...
No Matches
by::stelaSmartDedent Class Reference

Smart dedent handler for indentation-based parsing. More...

#include <stelaSmartDedent.hpp>

Public Member Functions

mecountDown ()
 Decrements the internal count, typically indicating a pending dedent.
 
mecountUp ()
 Increments the internal count, typically indicating a pending dedent.
 
meuseLater ()
 Enables dedent tracking for future parsing, deferring any pending dedents.
 
nint dedent ()
 Generates and returns a dedent token based on the internal count.
 
void rel ()
 
nbool canDedent () const
 
nbool isOn () const
 

Detailed Description

Smart dedent handler for indentation-based parsing.

A class that counts and manages in an array how many leading spaces exist whenever stelaParser creates a scope based on indentation.

For example, when parsing this stela code:

name := "my device"
# position 1
Rich logging support with polymorphic type conversion.
Definition richLog.hpp:34

If the parser is parsing at position 1, smartDedent's internal array is [0, 4, 6]. This means the outermost scope's whitespace count is smartDedent[0] = 0, and the innermost device scope's whitespace count is smartDedent[smartDedent.len() - 1] = 6, meaning 6 leading spaces are required.

Member Function Documentation

◆ countDown()

me & by::stelaSmartDedent::countDown ( )

Decrements the internal count, typically indicating a pending dedent.

Returns
A reference to this stelaSmartDedent instance.

◆ countUp()

me & by::stelaSmartDedent::countUp ( )

Increments the internal count, typically indicating a pending dedent.

Returns
A reference to this stelaSmartDedent instance.

◆ dedent()

nint by::stelaSmartDedent::dedent ( )

Generates and returns a dedent token based on the internal count.

Returns
The token ID for DEDENT, or 0 if no dedent is pending.

◆ useLater()

me & by::stelaSmartDedent::useLater ( )

Enables dedent tracking for future parsing, deferring any pending dedents.

Returns
A reference to this stelaSmartDedent instance.

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