#------------------------------------------------------------------------------- # The grammar for parsing format strings. Intentionally globally visible # to allow the ecosystem to subclass it if necessary grammar Formatter::Syntax { token TOP { ^ * $ } method panic($message, $payload) { my $ex := nqp::newexception(); nqp::setmessage($ex, $message); nqp::setpayload($ex, $payload); nqp::throw($ex); } token statement { [ | [ || <.panic( "'" ~ self.orig.substr(1) ~ "' is not valid in sprintf format sequence '" ~ self.orig ~ "'", nqp::hash( 'BAD_DIRECTIVE', nqp::hash( 'DIRECTIVE', self.orig.substr(1), 'SEQUENCE', self.orig ) ) )> ] | ] } proto token directive { <...> } token directive:sym { '%' ? * ? ? $=<[bB]> } token directive:sym { '%' ? * ? } token directive:sym { '%' ? * ? ? $=<[dDi]> } token directive:sym { '%' ? * ? ? $=<[eE]> } token directive:sym { '%' ? * ? ? $=<[fF]> } token directive:sym { '%' ? * ? ? $=<[gG]> } token directive:sym { '%' ? * ? ? } token directive:sym { '%' ? * ? ? } token directive:sym { '%' ? * ? ? } token directive:sym { '%' ? * ? } token directive:sym { '%' ? * ? ? $=<[xX]> } token directive:sym<%> { '%%' } token literal { <-[%]>+ } token idx { [\d+] '$' } token flags { <[\ +0#-]> } token size { \d* | $='*' ? } token precision { '.' ? } } # vim: expandtab shiftwidth=4