# Every generator feature once, compiled with -Wall -Wextra -Werror by the
# features test and run against expected.txt.
$MODULE features
$NAMESPACE test :: features
$INCLUDE "user.hh"
$INCLUDE <iomanip>
$USING std::string
$LANGUAGE en
# --- languages: the most specific name wins, the default is the fallback
$STRING ENABLE
$MESSAGE Pick
"default"
[C.utf8]
"C.utf8 text"
[C]
"C text"
# --- escapes, octal bytes, '??', quotes of the other kind, continuation
$MESSAGE Escapes
'single: \'q\' "dq" {$not_a_macro} \\ \t|'
|bar: 'sq' "dq" \{$literal} caf\303\251 ?? end\
| joined
"dq: \"q\" 'sq' \101\x42"
# --- macros and formats; the format must not leak into the next number
$MESSAGE Formatted
@ value double
@ count int
"[{$value;std::fixed;precision(2)}] [{$count;std::setw(4);fill('*')}] [{$count}] [{$ std::string{ "br{}ace" } }]"
# --- streamable class with a parent, MEMBER AS on it
$STRING DISABLE
$STREAMABLE ENABLE
$STREAMABLE INHERITED PUBLIC test::Printable
$STRING ENABLE MEMBER AS text
$STRING NOPOSTFIX
$MESSAGE Point
@ x int
@ y int
"({$x}, {$y})"
# --- $ERROR / $THROW / $SYSLOG MEMBER AS: members of the streamable class
$STRING DISABLE
$ERROR ENABLE MEMBER AS fail
$ERROR NOPOSTFIX
$ERROR EXIT throw 1
$THROW ENABLE NONCONST MEMBER AS raise
$THROW NOPREFIX
$SYSLOG ENABLE MEMBER AS log
$SYSLOG NOPREFIX
$STREAMABLE NOPOSTFIX
$MESSAGE Pair
@ first int
@ second int
"<{$first}|{$second}>"
# --- a message without text still compiles (and gets a warning)
$ERROR DISABLE
$THROW DISABLE
$SYSLOG DISABLE
$MESSAGE Nothing
@ unused int
$STREAMABLE POSTFIX Streamable
# --- MEMBER OF a user class; $ERROR with a custom EXIT; $SYSLOG MEMBER OF.
# C++ lets a member be defined only in a namespace enclosing its class:
# the class is declared in the $NAMESPACE (or a namespace nested in it).
$STREAMABLE DISABLE
$STRING ENABLE NONCONST MEMBER OF Reporter
$STRING PREFIX say
$ERROR ENABLE POSTFIX Error
$ERROR MEMBER OF Reporter
$ERROR EXIT throw 42;
$SYSLOG ENABLE PREFIX Log FACILITY LOCAL3 LEVEL WARNING
$SYSLOG CONST MEMBER OF Reporter
$MESSAGE Report
@ what string const &
"report: {$what}"
# --- exception only via $THROW, whose locale overload needs the exception's
# locale constructor even though $EXCEPTION LOCALE EXTRA is off
$STRING DISABLE
$ERROR DISABLE
$SYSLOG DISABLE
$EXCEPTION LOCALE EXTRA DISABLE INHERITED std::exception
$THROW ENABLE NONMEMBER PREFIX Throw
$MESSAGE Failure
@ code int
"failure {$code}"
[C.utf8]
"C.utf8 failure {$code}"
# --- no parameters at all, no locale overload
$THROW LOCALE EXTRA DISABLE
$MESSAGE Plain
"plain"
# --- per-message artefacts: only a string function here, although $THROW
# (and so the exception class) is still enabled
$STRING NONMEMBER NOPREFIX POSTFIX Str
$MESSAGE Just : STRING
"just a string"