src/Control/ directory

Command line and input file parsing and grammars for all executables.


This directory contains parsing-related functionality for all executables. It has multiple grammar definitions for

  • command line parsers for all executables, in subdirectories src/Control/<executable>/CmdLine, and
  • input file parsers for those executables that take an input file, in subdirectories src/Control/<executable>/InputDeck.

Grammar definitions are defined using the Parsing Expression Grammar Template Library (PEGTL) according to Parsing Expression Grammar (PEG). As the PEGTL documentation describes

Grammars are written as regular C++ code, created with template programming (not template meta programming), i.e. nested template instantiations that naturally correspond to the inductive definition of PEGs (and other parser-combinator approaches).

Grammars are thus written purely in C++ and the compiler generates the parsers using PEGTL.

Files src/Control/<executable>/Components.h store the number of scalar components for systems of equations integrated, by e.g., Inciter.

CommonGrammar.h defines the smallest building blocks of all grammars. It contains generic functions that are reused among multiple command line and input file grammars.

The state (or stack) of the grammar is a tagged tuple (tk::tuple::tagged_tuple), a hierarchical heterogeneous data structure that stores all information parsed. Files src/Control/<executable>/Types.h declare the types of the components of a grammar's state. The components are usually also tuples to nest multiple levels of hierarchies, to group related information together.

Control.h defines a generic base class, tk::Control, used as grammar states, It defines helper functions, used to store a variety of data parsed.

Tags.h defines empty structs that are used as labels during compile time. These labels are used to index into tagged tuples.

Keywords.h defines all keywords accepted by all parsers together with their documentation.

Toggle.h defines a generic switch with multiple states, from which specialized switches derive. Directories src/Control/Options and <executable>/Options define specific switches, specializing a tk::Toggle. The former directory defines switches that are used by multiple executables, while the latter define those that are specific to a given <executable>, e.g., UnitTest.


directory Inciter/
Types, options, command line parsing, and grammar for Inciter
directory MeshConv/
Types, command line parsing, and grammar for MeshConv
directory Options/
Options for multiple executables.
directory UnitTest/
Types, command line parsing, and grammar for UnitTest


file CommonGrammar.hpp
Generic, low-level grammar, re-used by specific grammars.
file FileParser.cpp
File parser base class definition.
file FileParser.hpp
File parser base class declaration.
file HelpFactory.hpp
Command-line and input deck help factory.
file Keyword.hpp
Generic definition of a keyword.
file Keywords.hpp
Definition of all keywords.
file StatCtr.hpp
Types and associated functions to deal with moments and PDFs.
file StringParser.cpp
String parser base class definition.
file StringParser.hpp
String parser base class declaration.
file SystemComponents.hpp
Operations on numbers of scalar components of systems of equations.
file Tags.hpp
file Toggle.hpp
Toggle is the base for an Option, doing generic searches.