Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
alib2str
src
grammar
string
Unrestricted
ContextPreservingUnrestrictedGrammar.h
Go to the documentation of this file.
1
6
#pragma once
7
8
#include <
grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h
>
9
#include <
core/stringApi.hpp
>
10
11
#include <
grammar/GrammarFromStringLexer.h
>
12
13
#include <
grammar/string/common/GrammarFromStringParserCommon.h
>
14
#include <
grammar/string/common/GrammarToStringComposerCommon.h
>
15
16
namespace
core
{
17
18
template
<
class
SymbolType >
19
struct
stringApi
<
grammar
::ContextPreservingUnrestrictedGrammar < SymbolType > > {
20
static
grammar::ContextPreservingUnrestrictedGrammar < SymbolType >
parse (
ext::istream
& input );
21
static
bool
first (
ext::istream
& input );
22
static
void
compose (
ext::ostream
& output,
const
grammar::ContextPreservingUnrestrictedGrammar < SymbolType >
&
grammar
);
23
};
24
25
template
<
class
SymbolType >
26
grammar::ContextPreservingUnrestrictedGrammar < SymbolType >
stringApi < grammar::ContextPreservingUnrestrictedGrammar < SymbolType >
>::parse (
ext::istream
& input ) {
27
grammar::GrammarFromStringLexer::Token token =
grammar::GrammarFromStringLexer::next
(input);
28
if
(token.type !=
grammar::GrammarFromStringLexer::TokenType::CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR
)
29
throw
exception::CommonException
(
"Unrecognised ContextPreservingUnrestrictedGrammar token."
);
30
31
return
grammar::GrammarFromStringParserCommon::parsePreservingCSLikeGrammar < grammar::ContextPreservingUnrestrictedGrammar < SymbolType > > ( input );
32
}
33
34
template
<
class
SymbolType >
35
bool
stringApi < grammar::ContextPreservingUnrestrictedGrammar < SymbolType >
>::first (
ext::istream
& input ) {
36
grammar::GrammarFromStringLexer::Token token =
grammar::GrammarFromStringLexer::next
( input );
37
bool
res
= token.type ==
grammar::GrammarFromStringLexer::TokenType::CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR
;
38
grammar::GrammarFromStringLexer::putback
( input, token );
39
return
res
;
40
}
41
42
template
<
class
SymbolType >
43
void
stringApi < grammar::ContextPreservingUnrestrictedGrammar < SymbolType >
>::compose (
ext::ostream
& output,
const
grammar::ContextPreservingUnrestrictedGrammar < SymbolType >
&
grammar
) {
44
output <<
"CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR"
;
45
grammar::GrammarToStringComposerCommon::composePreservingCSLikeGrammar
( output,
grammar
);
46
}
47
48
}
/* namespace core */
49
GrammarFromStringLexer.h
GrammarFromStringParserCommon.h
GrammarToStringComposerCommon.h
ContextPreservingUnrestrictedGrammar.h
exception::CommonException
Basic exception from which all other exceptions are derived.
Definition:
CommonException.h:21
ext::Lexer< GrammarFromStringLexer >::putback
static void putback(ext::istream &input, const Token &token)
Definition:
lexer.hpp:61
ext::istream
Definition:
istream.h:32
ext::ostream
Definition:
ostream.h:14
grammar::ContextPreservingUnrestrictedGrammar
Context preserving unrestricted grammar. Type 0 in Chomsky hierarchy. Generates recursively enumerabl...
Definition:
ContextPreservingUnrestrictedGrammar.h:64
grammar::GrammarFromStringLexer::next
static Token next(ext::istream &input)
Definition:
GrammarFromStringLexer.cpp:10
grammar::GrammarFromStringLexer::TokenType::CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR
@ CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR
grammar::GrammarToStringComposerCommon::composePreservingCSLikeGrammar
static void composePreservingCSLikeGrammar(ext::ostream &output, const T &grammar)
Definition:
GrammarToStringComposerCommon.h:136
automaton::simplify::res
return res
Definition:
MinimizeByPartitioning.h:145
core
Definition:
normalize.hpp:10
grammar
Definition:
ToAutomaton.h:24
stringApi.hpp
core::stringApi
Definition:
stringApi.hpp:26
Generated on Mon Dec 27 2021 10:21:55 for Algorithms Library Toolkit by
1.9.2