tk::grm namespace

Toolkit general purpose grammar definition.

Contents

Classes

template<typename Rule>
struct action
template<typename... As>
struct call
Helper for calling action::apply for multiple actions.
template<class rule, class... actions>
struct act
Rule used to trigger action(s) for a rule.
template<class rule, class... actions>
struct action<act<rule, actions...>>
template<MsgType, MsgKey>
struct msg
Rule used to trigger action.
template<MsgType type, MsgKey key>
struct action<msg<type, key>>
template<typename tag, typename... tags>
struct Store
Rule used to trigger action.
template<typename tag, typename... tags>
struct action<Store<tag, tags...>>
template<typename... tags>
struct Invert_switch
Rule used to trigger action.
template<typename... tags>
struct action<Invert_switch<tags...>>
struct helpkw
Rule used to trigger action.
template<>
struct action<helpkw>
Find keyword among all keywords and if found, store the keyword and its info on which help was requested behind tag::helpkw in Stack.
template<class keyword, typename tag, typename... tags>
struct check_lower_bound
Rule used to trigger action.
template<class keyword, typename tag, typename... tags>
struct action<check_lower_bound<keyword, tag, tags...>>
Check if value is larger than lower bound.
template<class keyword, typename tag, typename... tags>
struct check_upper_bound
Rule used to trigger action.
template<class keyword, typename tag, typename... tags>
struct action<check_upper_bound<keyword, tag, tags...>>
Check if value is lower than upper bound.
template<class token, class erased>
struct trim
Read 'token' until 'erased' trimming, i.e., not consuming, 'erased'.
template<MsgType type, MsgKey key>
struct unknown
Match unknown keyword and handle error.
template<class keyword>
struct alias
template<class keyword>
struct verbose
template<class token>
struct readkw
Read keyword 'token' padded by blank at left and space at right.
template<class keyword, typename = void>
struct readcmd
template<class keyword>
struct readcmd<keyword, typename if_<false, typename keyword::info::alias>::type>
template<class keyword, class... actions>
struct scan
Scan input padded by blank at left and space at right and if it matches 'keyword', apply 'actions'.
struct number
Parse a number: an optional sign followed by digits.
template<template<class> class use, class keyword, class insert, class kw_type, class tag, class... tags>
struct process_cmd
Process command line 'keyword' and call its 'insert' action if matches 'kw_type'.
template<template<class> class use, class keyword, typename tag, typename... tags>
struct process_cmd_switch
struct charmarg
Process but ignore Charm++'s charmrun arguments starting with '+'.
template<typename keywords>
struct read_string
Generic string parser entry point: parse 'keywords' until end of string.
template<typename keyword, typename pool>
struct use
Ensure that a grammar only uses keywords from a pool of pre-defined keywords.
struct CaseInsensitiveCharLess
Case-insensitive character comparison functor.

Enums

enum MsgType { ERROR =0, WARNING }
C-style enum indicating warning or error (used as template argument)
enum class MsgKey: uint8_t { KEYWORD, MOMENT, QUOTED, LIST, ALIAS, MISSING, PREMATURE, UNSUPPORTED, NOOPTION, NOINIT, NOPROBLEM, NOCOEFF, NOTSELECTED, NOSOLVE, NOTALPHA, POINTEXISTS, BADPRECISION, BOUNDS, PRECISIONBOUNDS, UNFINISHED, CHARMARG, OPTIONAL }
Parser error types.

Functions

template<class Stack, MsgType type, MsgKey key, class Input>
static void Message(Stack& stack, const Input& in)

Variables

Print g_print
static const std::map<MsgKey, std::string> message
Associate parser errors to error messages.
static std::set<char, CaseInsensitiveCharLess> depvars
Parser-lifetime storage for dependent variables selected.

Enum documentation

enum class tk::grm::MsgKey: uint8_t

Parser error types.

Enumerators
KEYWORD

Unknown keyword.

MOMENT

Unknown Term in a Moment.

QUOTED

String must be double-quoted.

LIST

Unknown value in list.

ALIAS

Alias keyword too long.

MISSING

Required field missing.

PREMATURE

Premature end of line.

UNSUPPORTED

Option not supported.

NOOPTION

Option does not exist.

NOINIT

No (or too many) initialization policy selected.

NOPROBLEM

No test problem type selected.

NOCOEFF

No coefficients policy selected.

NOTSELECTED

Option not selected upstream.

NOSOLVE

Dependent variable to solve for has not been spec'd.

NOTALPHA

Variable must be alphanumeric.

POINTEXISTS

Point identifier already defined.

BADPRECISION

Floating point precision specification incorrect.

BOUNDS

Specified value out of bounds.

PRECISIONBOUNDS

Floating point precision spec out of bounds.

UNFINISHED

Unfinished block.

CHARMARG

Argument inteded for the Charm++ runtime system.

OPTIONAL

Function documentation

template<class Stack, MsgType type, MsgKey key, class Input>
static void tk::grm::Message(Stack& stack, const Input& in)

Parameters
stack in/out Grammar stack (a tagged tuple) to operate on
in in Last parsed PEGTL input token (can be empty, depending on what context this function gets called.

Parser error and warning message handler.

This function is used to associated and dispatch an error or a warning during parsing. After finding the error message corresponding to a key, it pushes back the message to a std::vector of std::string, which then will be diagnosed later by tk::FileParser::diagnostics. The template arguments define (1) the grammar stack (Stack, a tagged tuple) to operate on, (2) the message type (error or warning), and (3) the message key used to look up the error message associated with the key.

Variable documentation

Print tk::grm::g_print

Parser's printer: this should be defined once per library in global-scope (still in namespace, of course) by a parser. It is defined in Control/[executable]/CmdLine/Parser.C, since every executable has at least a command line parser.

static std::set<char, CaseInsensitiveCharLess> tk::grm::depvars

Parser-lifetime storage for dependent variables selected.

Used to track the dependent variable of differential equations (i.e., models) assigned during parsing. It needs to be case insensitive since we only care about whether the variable is selected or not and not whether it denotes a full variable (upper case) or a fluctuation (lower case). This is true for both inserting variables into the set as well as at matching terms of products in parsing requested statistics.