Header lexy/dsl/punctuator.hpp

Predefined punctuators.

lexy/dsl/punctuator.hpp
namespace lexy::dsl
{
    constexpr token-rule auto period       = lit<".">;
    constexpr token-rule auto comma        = lit<",">;
    constexpr token-rule auto colon        = lit<":">;
    constexpr token-rule auto double_colon = lit<"::">;
    constexpr token-rule auto semicolon    = lit<";">;


    constexpr token-rule auto exclamation_mark = lit<"!">;
    constexpr token-rule auto question_mark    = lit<"?">;

    constexpr token-rule auto hyphen      = lit<"-">;
    constexpr token-rule auto slash       = lit<"/">;
    constexpr token-rule auto backslash   = lit<"\\">; // note: single character
    constexpr token-rule auto apostrophe  = lit<"'">;
    constexpr token-rule auto ampersand   = lit<"&">;
    constexpr token-rule auto caret       = lit<"^">;
    constexpr token-rule auto asterisk    = lit<"*">;
    constexpr token-rule auto tilde       = lit<"~">;
    constexpr token-rule auto vbar        = lit<"|">;

    constexpr token-rule auto hash_sign    = lit<"#">;
    constexpr token-rule auto dollar_sign  = lit<"$">;
    constexpr token-rule auto at_sign      = lit<"@">;
    constexpr token-rule auto percent_sign = lit<"%">;
    constexpr token-rule auto equal_sign   = lit<"=">;
}

The various punctuator literal rules are convenience aliases for lexy::dsl::lit .

A punctuator is a token that is used as a delimiter in the grammar without having any actual meaning in the program, like an operator (e.g. +) would. In lexy, they are limited to ASCII punctuation characters that are not only used as operators and aren’t quotation or brackets.

See also