Header lexy/dsl/sign.hpp
The plus_sign, minus_sign and sign rules.
Tag types
lexy/dsl/sign.hppnamespace lexy
{
struct plus_sign
{
constexpr operator int() const
{
return +1;
}
};
struct minus_sign
{
constexpr operator int() const
{
return -1;
}
};
}The tag types plus_sign and minus_sign indicate a plus/minus sign.
They are implicitly convertible to the integer +1/-1.
Tip | The callback lexy::as_integer accepts an optional plus_sign/minus_sign object followed by an integer and returns the correctly signed integer. |
Rule lexy::dsl::plus_sign
lexy/dsl/sign.hppnamespace lexy::dsl
{
constexpr rule auto plus_sign;
}plus_sign is a rule that parses an optional + sign.
- Parsing
Tries to match and consume
lexy::dsl::lit_c<'+'>. If that fails, succeeds without consuming anything.- Errors
None.
- Values
If it matched a
+, an object of typelexy::plus_sign. Otherwise, no values.
Rule lexy::dsl::minus_sign
lexy/dsl/sign.hppnamespace lexy::dsl
{
constexpr rule auto minus_sign;
}minus_sign is a rule that parses an optional - sign.
- Parsing
Tries to match and consume
lexy::dsl::lit_c<'-'>. If that fails, succeeds without consuming anything.- Errors
None.
- Values
If it matched a
-, an object of typelexy::minus_sign. Otherwise, no values.
Rule lexy::dsl::sign
lexy/dsl/sign.hppnamespace lexy::dsl
{
constexpr rule auto sign;
}sign is a rule that parses an optional sign.
- Parsing
Tries to match and consume
lexy::dsl::lit_c<'+'>orlexy::dsl::lit_c<'-'>. If both fail, succeeds without consuming anything.- Errors
None.
- Values
If it matched a
+, an object of typelexy::plus_sign. If it matched a-, an object of typelexy::minus_sign. Otherwise, no values.