FE 0.16.1
Fast, Effecient FrontEnds
Loading...
Searching...
No Matches
fe::Token Concept Reference

What fe::Parser needs of its Token type: a Tag and a Loc, copied in and out of the lookahead by value. More...

#include <fe/parser.h>

Concept definition

template<class Tok, class Tag>
concept Token = requires(const Tok tok) {
Tag::Nil;
{ tok.tag() } -> std::convertible_to<Tag>;
{ tok.loc() } -> std::convertible_to<Loc>;
requires std::equality_comparable<Tag>;
requires std::semiregular<Tok>;
requires std::constructible_from<bool, Tok>;
requires !requires { std::bool_constant<Tok().tag() == Tag::Nil>(); } || Tok().tag() == Tag::Nil;
}
What fe::Parser needs of its Token type: a Tag and a Loc, copied in and out of the lookahead by value...
Definition parser.h:23

Detailed Description

What fe::Parser needs of its Token type: a Tag and a Loc, copied in and out of the lookahead by value.

Parser::accept and Parser::expect indicate failure by returning a default-constructed Token, so Tok() must be falsy and tagged Tag::Nil. That sentinel is only checkable here if Tok() is usable in a constant expression - Parser::init asserts it. The probe for that yields a bool, as MSVC mistypes an enum as the non-type argument of a template.

Definition at line 23 of file parser.h.