slang::parsing::ParserBase class

Base class for the Parser, which contains helpers and language-agnostic parsing routines.

Mostly this helps keep the main Parser smaller and more focused.

Protected types

class Window
Helper class that maintains a sliding window of tokens, with lookahead.

Protected functions

template<typename TParserFunc, typename TResult = decltype(std::declval<typename std::decay<TParserFunc>::type&>()())>
auto parseGroupOrSkip(TokenKind startKind, TokenKind endKind, TParserFunc&& parseItem) -> std::tuple<Token, Token, TResult>
Generalized helper method for parsing a group of things that are bookended by known token kinds.
template<bool(*)(TokenKind) IsExpected, bool(*)(TokenKind) IsEnd, typename TParserFunc>
void parseList(TokenKind openKind, TokenKind closeKind, TokenKind separatorKind, Token& openToken, std::span<syntax::TokenOrSyntax>& list, Token& closeToken, RequireItems requireItems, DiagCode code, TParserFunc&& parseItem, AllowEmpty allowEmpty = {})
This is a generalized method for parsing a delimiter separated list of things with bookend tokens in a way that robustly handles bad tokens.

Function documentation

template<typename TParserFunc, typename TResult = decltype(std::declval<typename std::decay<TParserFunc>::type&>()())>
std::tuple<Token, Token, TResult> slang::parsing::ParserBase::parseGroupOrSkip(TokenKind startKind, TokenKind endKind, TParserFunc&& parseItem) protected

Generalized helper method for parsing a group of things that are bookended by known token kinds.

The point of wrapping it in a function is that if the starting token is missing, we don't even bother trying to parse the rest of the group.