4.6.0
Freundlich's C++ toolkit
|
Base class for grammars.
Usually, parsers are mutually recursive. For example, in JSON, the parser for objects depends on the parser for values, and the parser for values depends on the parser for objects. To implement this, it is necessary to have both parsers as elements of a struct, so that they can refer to each other in the constructor. We also refer to these parsers as nonterminals. A struct that "collects" nonterminals and "connects" them in its constructor, is called a "grammar", similar to what a context-free grammar does in computer science.
The base class for grammars gets a special parser, called the start parser. It also gets a skipper, which is shared by all nonterminals.
Public Types | |
using | grammar_base = grammar |
using | result_type = Result |
using | char_type = Ch |
template<typename Type > | |
using | base_type = fcppt::parse::base_unique_ptr<Type, Ch, Skipper> |
Public Member Functions | |
grammar (fcppt::reference< base_type< Result > const >, Skipper &&) | |
~grammar () | |
base_type< Result > const & | start () const |
Skipper const & | skipper () const |
Static Public Member Functions | |
template<typename Parser > | |
static base_type< fcppt::parse::result_of< Parser > > | make_base (Parser &&) |
using fcppt::parse::grammar< Result, Ch, Skipper >::base_type = fcppt::parse::base_unique_ptr<Type, Ch, Skipper> |
using fcppt::parse::grammar< Result, Ch, Skipper >::char_type = Ch |
using fcppt::parse::grammar< Result, Ch, Skipper >::grammar_base = grammar |
using fcppt::parse::grammar< Result, Ch, Skipper >::result_type = Result |
fcppt::parse::grammar< Result, Ch, Skipper >::grammar | ( | fcppt::reference< base_type< Result > const > | , |
Skipper && | ) |
fcppt::parse::grammar< Result, Ch, Skipper >::~grammar | ( | ) |
|
staticnodiscard |
|
nodiscard |
|
nodiscard |