Header lexy/dsl/follow.hpp
The followed_by
and not_followed_by
literal rules.
Literal rule lexy::dsl::followed_by
lexy/dsl/follow.hpp
namespace lexy::dsl
{
constexpr literal-rule auto followed_by(literal-rule lit,
char-class-rule auto cc)
{
return not_followed_by(lit, -cc);
}
constexpr literal-rule auto followed_by(literal-rule lit,
literal-char-class-rule auto cc)
{
return not_followed_by(lit, -cc);
}
}
followed_by
is a literal rule that ensures another literal rule is followed by a char class rule.
It is just syntax sugar for the primary form, lexy::dsl::not_followed_by
.
Literal rule lexy::dsl::not_followed_by
lexy/dsl/follow.hpp
namespace lexy
{
struct follow_restriction
{};
}
namespace lexy::dsl
{
constexpr literal-rule auto not_followed_by(literal-rule lit,
char-class-rule auto cc);
constexpr literal-rule auto not_followed_by(literal-rule lit,
literal-char-class-rule auto cc);
}
not_followed_by
is a literal rule that ensures another literal rule is not followed by a char class rule.
- Requires
lit
is not alexy::dsl::keyword
rule.- Matching
Matches and consumes
lit
. Otherwise, tries to matchcc
without consuming it and fails if it does. Iflit
uses case folding (e.g.lexy::dsl::ascii::case_folding
), it also applies tocc
.- Errors
All errors raised by
lit
when it fails.lexy::follow_restriction
: ifcc
matches; at the position where it matched. The rule then fails.
- Parse tree
The single token node created by
lit
.
Example 1. Match
=
but not ==
Tip | Use lexy::dsl::keyword for the common case of parsing a literal that is not a valid identifier. |