buffalo
Loading...
Searching...
No Matches
bf::Grammar< G > Class Template Reference

#include <buffalo.h>

Public Member Functions

bool HasNonTerminal (NonTerminal< G > &non_terminal) const
 
bool NonTerminalHasFollow (NonTerminal< G > &non_terminal, Terminal< G > &terminal) const
 
bool NonTerminalHasFirst (NonTerminal< G > &non_terminal, Terminal< G > &terminal) const
 
void GenerateFirstSet ()
 
void GenerateFollowSet ()
 
void RegisterSymbols (NonTerminal< G > *nonterminal)
 
 Grammar (NonTerminal< G > &start)
 
 Grammar ()=delete
 

Public Attributes

NonTerminal< G > & root
 

Protected Attributes

std::unique_ptr< Terminal< G > > EOS
 
std::set< NonTerminal< G > * > nonterminals_
 
std::set< Terminal< G > * > terminals_
 
std::map< NonTerminal< G > *, std::set< Terminal< G > * > > first_
 
std::map< NonTerminal< G > *, std::set< Terminal< G > * > > follow_
 
std::vector< std::pair< NonTerminal< G > *, ProductionRule< G > > > production_rules_
 List of all production rules along with their respective NonTerminal.
 

Friends

class Parser< G >
 
class SLRParser< G >
 

Detailed Description

template<IGrammar G>
class bf::Grammar< G >

Definition at line 444 of file buffalo.h.

Constructor & Destructor Documentation

◆ Grammar() [1/2]

template<IGrammar G>
bf::Grammar< G >::Grammar ( NonTerminal< G > &  start)
inline

Definition at line 621 of file buffalo.h.

◆ Grammar() [2/2]

template<IGrammar G>
bf::Grammar< G >::Grammar ( )
delete

Member Function Documentation

◆ GenerateFirstSet()

template<IGrammar G>
void bf::Grammar< G >::GenerateFirstSet ( )
inline

Simple, but somewhat inefficient algorithm for generating FIRST sets. The FIRST set is the set of all Terminals that a NonTerminal can begin with.

Definition at line 487 of file buffalo.h.

◆ GenerateFollowSet()

template<IGrammar G>
void bf::Grammar< G >::GenerateFollowSet ( )
inline

Simple, but somewhat inefficient algorithm for generating FOLLOW sets. The FOLLOW set is the set of all Terminals that can follow a NonTerminal.

Definition at line 528 of file buffalo.h.

◆ HasNonTerminal()

template<IGrammar G>
bool bf::Grammar< G >::HasNonTerminal ( NonTerminal< G > &  non_terminal) const
inline

Definition at line 468 of file buffalo.h.

◆ NonTerminalHasFirst()

template<IGrammar G>
bool bf::Grammar< G >::NonTerminalHasFirst ( NonTerminal< G > &  non_terminal,
Terminal< G > &  terminal 
) const
inline

Definition at line 478 of file buffalo.h.

◆ NonTerminalHasFollow()

template<IGrammar G>
bool bf::Grammar< G >::NonTerminalHasFollow ( NonTerminal< G > &  non_terminal,
Terminal< G > &  terminal 
) const
inline

Definition at line 473 of file buffalo.h.

◆ RegisterSymbols()

template<IGrammar G>
void bf::Grammar< G >::RegisterSymbols ( NonTerminal< G > *  nonterminal)
inline

Definition at line 585 of file buffalo.h.

Friends And Related Symbol Documentation

◆ Parser< G >

template<IGrammar G>
friend class Parser< G >
friend

Definition at line 434 of file buffalo.h.

◆ SLRParser< G >

template<IGrammar G>
friend class SLRParser< G >
friend

Definition at line 434 of file buffalo.h.

Member Data Documentation

◆ EOS

template<IGrammar G>
std::unique_ptr<Terminal<G> > bf::Grammar< G >::EOS
protected

Unique pointer to an EOS terminal for this grammar. This allows the grammar to be moved while still retaining the ability to perform pointer comparison on the EOS terminal.

Definition at line 454 of file buffalo.h.

◆ first_

template<IGrammar G>
std::map<NonTerminal<G>*, std::set<Terminal<G>*> > bf::Grammar< G >::first_
protected

Definition at line 459 of file buffalo.h.

◆ follow_

template<IGrammar G>
std::map<NonTerminal<G>*, std::set<Terminal<G>*> > bf::Grammar< G >::follow_
protected

Definition at line 460 of file buffalo.h.

◆ nonterminals_

template<IGrammar G>
std::set<NonTerminal<G>*> bf::Grammar< G >::nonterminals_
protected

Definition at line 456 of file buffalo.h.

◆ production_rules_

template<IGrammar G>
std::vector<std::pair<NonTerminal<G>*, ProductionRule<G> > > bf::Grammar< G >::production_rules_
protected

List of all production rules along with their respective NonTerminal.

Definition at line 463 of file buffalo.h.

◆ root

template<IGrammar G>
NonTerminal<G>& bf::Grammar< G >::root

Definition at line 466 of file buffalo.h.

◆ terminals_

template<IGrammar G>
std::set<Terminal<G>*> bf::Grammar< G >::terminals_
protected

Definition at line 457 of file buffalo.h.


The documentation for this class was generated from the following file: