4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt::parse::grammar< Result, Ch, Skipper > Class Template Reference

Detailed Description

template<typename Result, typename Ch, typename Skipper>
class fcppt::parse::grammar< Result, Ch, Skipper >

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 &&)
 

Member Typedef Documentation

◆ base_type

template<typename Result , typename Ch , typename Skipper >
template<typename Type >
using fcppt::parse::grammar< Result, Ch, Skipper >::base_type = fcppt::parse::base_unique_ptr<Type, Ch, Skipper>

◆ char_type

template<typename Result , typename Ch , typename Skipper >
using fcppt::parse::grammar< Result, Ch, Skipper >::char_type = Ch

◆ grammar_base

template<typename Result , typename Ch , typename Skipper >
using fcppt::parse::grammar< Result, Ch, Skipper >::grammar_base = grammar

◆ result_type

template<typename Result , typename Ch , typename Skipper >
using fcppt::parse::grammar< Result, Ch, Skipper >::result_type = Result

Constructor & Destructor Documentation

◆ grammar()

template<typename Result , typename Ch , typename Skipper >
fcppt::parse::grammar< Result, Ch, Skipper >::grammar ( fcppt::reference< base_type< Result > const > ,
Skipper &&  )

◆ ~grammar()

template<typename Result , typename Ch , typename Skipper >
fcppt::parse::grammar< Result, Ch, Skipper >::~grammar ( )

Member Function Documentation

◆ make_base()

template<typename Result , typename Ch , typename Skipper >
template<typename Parser >
static base_type< fcppt::parse::result_of< Parser > > fcppt::parse::grammar< Result, Ch, Skipper >::make_base ( Parser && )
staticnodiscard

◆ skipper()

template<typename Result , typename Ch , typename Skipper >
Skipper const & fcppt::parse::grammar< Result, Ch, Skipper >::skipper ( ) const
nodiscard

◆ start()

template<typename Result , typename Ch , typename Skipper >
base_type< Result > const & fcppt::parse::grammar< Result, Ch, Skipper >::start ( ) const
nodiscard