sun::parsing::RegexParser

sun::parsing::RegexParser

class · Source (opens in a new tab)

class sun::parsing::RegexParser

Parses regular expressions into nondeterministic finite automata.

Public Functions

parse

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

DFA sun::parsing::RegexParser::parse(const std::string &r)

Parse and determinize.

DFA states are materialized lazily on first use.

Related: DFA

parseToNFA

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

NFA sun::parsing::RegexParser::parseToNFA(const std::string &r)

Thompson construction only; the caller determinizes.

Related: NFA

Private Functions

consume

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

TokenChar sun::parsing::RegexParser::consume()

Returns the next regular-expression character and advances the cursor.

Related: TokenChar

parseAtom

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

NFA sun::parsing::RegexParser::parseAtom()

Parse a single atom (literal char, ., (, [, escaped char)

Related: NFA

parseCharClass

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

NFA sun::parsing::RegexParser::parseCharClass()

Parse a character class like [a-zA-Z0-9] or [^...] with escapes

Related: NFA

parseConcatenation

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

NFA sun::parsing::RegexParser::parseConcatenation()

Parses consecutive regex terms into a concatenated automaton.

Related: NFA

parsePostfix

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

NFA sun::parsing::RegexParser::parsePostfix()

Handles *, +.

Related: NFA

parseUnion

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

NFA sun::parsing::RegexParser::parseUnion()

Parses regex alternatives into an automaton that accepts any branch.

Related: NFA

peek

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

TokenChar sun::parsing::RegexParser::peek() const

Returns the next regular-expression character without consuming it.

Related: TokenChar

Private Fields

nextGroupId

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

int sun::parsing::RegexParser::nextGroupId = 0

No documentation comment.

pos

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

size_t sun::parsing::RegexParser::pos = 0

No documentation comment.

regex

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

std::string sun::parsing::RegexParser::regex

No documentation comment.