Header lexy/dsl/follow.hpp
The followed_by and not_followed_by literal rules.
Literal rule lexy::dsl::followed_by
lexy/dsl/follow.hppnamespace 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.hppnamespace 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
litis not alexy::dsl::keywordrule.- Matching
Matches and consumes
lit. Otherwise, tries to matchccwithout consuming it and fails if it does. Iflituses case folding (e.g.lexy::dsl::ascii::case_folding), it also applies tocc.- Errors
All errors raised by
litwhen it fails.lexy::follow_restriction: ifccmatches; 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. |