Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Concepts
IsFITDefinition.h
Go to the documentation of this file.
1
6#pragma once
7
8namespace grammar {
9
10namespace properties {
11
13public:
14 /*
15 * Checks whether grammar satisfies rule about S->\eps from FIT definitions.
16 */
17 template < class T >
18 static bool isFITDefinition ( const T & grammar );
19};
20
21template < class T >
23 if ( ! grammar.getGeneratesEpsilon( ) )
24 return true;
25
26 auto rawRules = grammar::RawRules::getRawRules ( grammar );
27 for ( const auto & rule : rawRules )
28 for ( const auto & rhs : rule.second )
29 if ( std::find ( rhs.begin ( ), rhs.end ( ), grammar.getInitialSymbol ( ) ) != rhs.end ( ) )
30 return false;
31
32 return true;
33}
34
35} /* namespace properties */
36
37} /* namespace grammar */
38
static ext::map< NonterminalSymbolType, ext::set< ext::vector< ext::variant< TerminalSymbolType, NonterminalSymbolType > > > > getRawRules(const LG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: RawRules.h:92
Definition: IsFITDefinition.h:12
static bool isFITDefinition(const T &grammar)
Definition: IsFITDefinition.h:22
Definition: ToAutomaton.h:24