diff --git a/acat/makefile b/acat/makefile index da9eb0476543fc22562f8849bd4e3128c5ebbd32..6ade75d926fa10a667af7fac7d256f6cd41bf1a0 100644 --- a/acat/makefile +++ b/acat/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=acat CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -LDFLAGS= -L../alib/lib -lxml2 -lalib +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/aconvert.automaton/makefile b/aconvert.automaton/makefile new file mode 100644 index 0000000000000000000000000000000000000000..eca1f70d08b0d7b23156b2b070ebfd81cebe43f0 --- /dev/null +++ b/aconvert.automaton/makefile @@ -0,0 +1,20 @@ +CC=g++ +EXECUTIBLE=aconvert.automaton +CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. + +SOURCES=$(shell find src/ -name *cpp) +OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) + +all: $(SOURCES) bin/$(EXECUTIBLE) + +bin/$(EXECUTIBLE): $(OBJECTS) + mkdir -p bin + $(CC) $(LDFLAGS) $(OBJECTS) -o $@ + +obj/%.o: src/%.cpp + mkdir -p $(dir $@) + $(CC) $(CCFLAGS) $< -o $@ + +clean: + $(RM) -r *.o *.d bin obj diff --git a/aconvert.automaton/src/AutomatonParser.cpp b/aconvert.automaton/src/AutomatonParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c672bcbae867608bb796debcf053cb930a8a7e2c --- /dev/null +++ b/aconvert.automaton/src/AutomatonParser.cpp @@ -0,0 +1,75 @@ +#include "AutomatonParser.h" +#include "std/istream.h" +#include <string> +#include <sstream> +#include <vector> +#include <algorithm> + +#include "alphabet/Symbol.h" + +AutomatonParser::AutomatonParser(std::istream& in) : m_In(in) { + +} + +automaton::FSM AutomatonParser::parse() { + automaton::FSM res = automaton::FSM(); + std::string headerLine; + std::getline(m_In, headerLine); + + std::stringstream header(headerLine); + if(!(header >> "NFA") && !(header.clear(), header >> "DFA")) { + throw ParseError(); + } + + std::string alpha; + std::vector<alphabet::Symbol> symbols; + while(header >> alpha) { + if(alpha != "\\eps") { + res.addInputSymbol(alphabet::Symbol(alpha)); + symbols.push_back(alphabet::Symbol(alpha)); + } else { + symbols.push_back(alphabet::Symbol("")); + } + } + + std::string line; + while(std::getline(m_In, line)) { + bool initial = false; + bool final = false; + + std::stringstream linestream(line); + + if(linestream >> ">") initial = true; + else linestream.clear(); + if(linestream >> "<") final = true; + else linestream.clear(); + + std::string from; + linestream >> from; + + if(res.getStates().find(from) == res.getStates().end()) res.addState(from); + if(initial) res.addInitialState(from); + if(final) res.addFinalState(from); + + std::vector<alphabet::Symbol>::const_iterator iter = symbols.begin(); + std::string to; + while(linestream >> to) { + if(iter == symbols.end()) throw ParseError(); + if(to != "-") { + + std::replace(to.begin(), to.end(), '|', ' '); + std::stringstream states(to); + std::string state; + while(states >> state) { + if(res.getStates().find(state) == res.getStates().end()) res.addState(state); + + res.addTransition(from, *iter, state); + } + + } + iter++; + } + } + + return res; +} \ No newline at end of file diff --git a/aconvert.automaton/src/AutomatonParser.h b/aconvert.automaton/src/AutomatonParser.h new file mode 100644 index 0000000000000000000000000000000000000000..599ae24513ba7f4ba4d20f613a37cecc642bcad1 --- /dev/null +++ b/aconvert.automaton/src/AutomatonParser.h @@ -0,0 +1,18 @@ +#ifndef __AUTOMATON_PARSER__ +#define __AUTOMATON_PARSER__ + +#include "automaton/FSM/FSM.h" + +class ParseError { + +}; + +class AutomatonParser { + std::istream& m_In; +public: + AutomatonParser(std::istream&); + automaton::FSM parse(); + +}; + +#endif \ No newline at end of file diff --git a/aconvert.automaton/src/AutomatonPrinter.cpp b/aconvert.automaton/src/AutomatonPrinter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a63c7f867313916a74be434771024d96dd9413c4 --- /dev/null +++ b/aconvert.automaton/src/AutomatonPrinter.cpp @@ -0,0 +1,60 @@ +#include "AutomatonPrinter.h" + +AutomatonPrinter::AutomatonPrinter(std::ostream& out) : m_Out(out) { + +} + +void AutomatonPrinter::printStateSymbolTo(automaton::FSM& automaton, automaton::State from, alphabet::Symbol input) { + bool sign = false; + for(auto iterTransitions = automaton.getTransitions().begin(); iterTransitions != automaton.getTransitions().end(); iterTransitions++) { + if(iterTransitions->getFrom() == from && iterTransitions->getInput() == input) { + m_Out << (sign ? "|" : " ") << iterTransitions->getTo().getName(); + sign = true; + } + } + if(!sign) { + m_Out << " -"; + } +} + +void AutomatonPrinter::print(automaton::FSM& automaton) { + + if(automaton.isDeterministic()) { + m_Out << "DFA"; + } else { + m_Out << "NFA"; + } + + for(auto iterSymbol = automaton.getInputAlphabet().begin(); iterSymbol != automaton.getInputAlphabet().end(); iterSymbol++) { + m_Out << " " << iterSymbol->getSymbol(); + } + + bool isEpsilonFreeSign = automaton.isEpsilonFree(); + if(!isEpsilonFreeSign) { + m_Out << " \\eps"; + } + + m_Out << std::endl; + + for(auto iterState = automaton.getStates().begin(); iterState != automaton.getStates().end(); iterState++) { + if(automaton.getInitialStates().find(*iterState) != automaton.getInitialStates().end()) { + m_Out << ">"; + } + if(automaton.getFinalStates().find(*iterState) != automaton.getFinalStates().end()) { + m_Out << "<"; + } + m_Out << iterState->getName(); + + for(auto iterSymbol = automaton.getInputAlphabet().begin(); iterSymbol != automaton.getInputAlphabet().end(); iterSymbol++) { + printStateSymbolTo(automaton, *iterState, *iterSymbol); + } + + if(!isEpsilonFreeSign) { + printStateSymbolTo(automaton, *iterState, alphabet::Symbol("")); + } + + m_Out << std::endl; + } + +} + diff --git a/aconvert.automaton/src/AutomatonPrinter.h b/aconvert.automaton/src/AutomatonPrinter.h new file mode 100644 index 0000000000000000000000000000000000000000..7f41357fec84bb4d2e76a59f98bcb0e3c8e2fed0 --- /dev/null +++ b/aconvert.automaton/src/AutomatonPrinter.h @@ -0,0 +1,17 @@ +#ifndef AUTOMATON_PRINTER_H_ +#define AUTOMATON_PRINTER_H_ + +#include <iostream> +#include "automaton/FSM/FSM.h" + +class AutomatonPrinter { + std::ostream& m_Out; + + void printStateSymbolTo(automaton::FSM& automaton, automaton::State from, alphabet::Symbol input); + +public: + AutomatonPrinter(std::ostream& out); + void print(automaton::FSM& automaton); +}; + +#endif /* AUTOMATON_PRINTER_H_ */ \ No newline at end of file diff --git a/aconvert.automaton/src/aconvert.automaton.cpp b/aconvert.automaton/src/aconvert.automaton.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2b23de63b686b841c0d5c41e36aca4f392e9da66 --- /dev/null +++ b/aconvert.automaton/src/aconvert.automaton.cpp @@ -0,0 +1,93 @@ +#include <iostream> +#include <fstream> +#include "AutomatonParser.h" +#include "AutomatonPrinter.h" + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <getopt.h> + +#include "automaton/FSM/FSM.h" +#include "automaton/UnknownAutomaton.h" +#include "AutomatonFactory.h" +#include "AlibException.h" + +#define FROM 1 +#define TO 2 + +int fromAutomaton(std::istream& in, std::ostream& out) { + AutomatonParser parser(in); + + automaton::FSM result = parser.parse(); + + out << result; + + return 0; +} + +int toAutomaton(std::istream& in, std::ostream& out) { + + try { + + automaton::UnknownAutomaton automaton = automaton::AutomatonFactory::fromStream(in); + if(!automaton::AutomatonFactory::isFSM(automaton)) { + std::cerr << "Automaton minimize require deterministic finite automaton\n" << std::endl; + return 1; + } + automaton::FSM fsm = automaton::AutomatonFactory::buildFSM(automaton); + AutomatonPrinter printer = AutomatonPrinter(out); + printer.print(fsm); + + } catch (alib::AlibException& e) { + std::cerr << e.getCause() << std::endl; + return 1; + } + return 0; +} + +int main(int argc, char* argv[]) { + + int fromTo = 0; + int c; + + while (1) { + static struct option long_options[] = { + {"from", no_argument, &fromTo, FROM}, + {"to", no_argument, &fromTo, TO}, + {0, 0, 0, 0} + }; + + int option_index = 0; + + c = getopt_long (argc, argv, "", long_options, &option_index); + + if (c == -1) + break; + + switch (c) { + case 0: + break; + default: + optind--; + goto more; + } + } +more: + + std::istream* in = &std::cin; + if(optind != argc) in = new std::ifstream(argv[optind]); + + int res; + if(fromTo == FROM) { + res = fromAutomaton(*in, std::cout); + } else if(fromTo == TO) { + res = toAutomaton(*in, std::cout); + } else { + std::cerr << "error" << std::endl; + res = 1; + } + + if(c != -1) delete in; + return res; +} \ No newline at end of file diff --git a/aconvert.dot/makefile b/aconvert.dot/makefile index 049a23768cbf83376f836898f1d1b90554e72fb1..7fc4f89013930107265b62edcdda4cb4522b8291 100644 --- a/aconvert.dot/makefile +++ b/aconvert.dot/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=aconvert.dot CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -LDFLAGS= -L../alib/lib -lxml2 -lalib +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/aconvert.gastex/makefile b/aconvert.gastex/makefile index 705d1b7bd23c11ab800f69e7582009248d920d0a..e9e21a20b597805f2c4cad282c84fcb0cd883d18 100644 --- a/aconvert.gastex/makefile +++ b/aconvert.gastex/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=aconvert.gastex CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -LDFLAGS= -L../alib/lib -lxml2 -lalib +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/aconvert.regexp/makefile b/aconvert.regexp/makefile index 9474e62121df43e4f44d8b2d3e2d84e751dd4748..39f1798c2c53ab7a3312b861d6a3ef6ca4b72738 100644 --- a/aconvert.regexp/makefile +++ b/aconvert.regexp/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=aconvert.regexp CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -LDFLAGS= -L../alib/lib -lxml2 -lalib +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/adeterminize.fsm/makefile b/adeterminize.fsm/makefile index 2432b04ecddcabda9530338ec0c714747f2e4933..45679895658c79ea38f16e89dfa2d8d5821ef67b 100644 --- a/adeterminize.fsm/makefile +++ b/adeterminize.fsm/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=adeterminize.fsm CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -I../adeterminize/src -LDFLAGS= -L../alib/lib -L../adeterminize/lib -lxml2 -lalib -ladeterminize +LDFLAGS= -L../alib/lib -L../adeterminize/lib -lxml2 -lalib -ladeterminize -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/adiff.automaton/makefile b/adiff.automaton/makefile index 52c27e2a8ca1964d330b235b420f73aaad39523d..112e9e1dbe07a7e80131bc6a62fe0cba3743dd9f 100644 --- a/adiff.automaton/makefile +++ b/adiff.automaton/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=adiff.automaton CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -LDFLAGS= -L../alib/lib -lxml2 -lalib +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/adiff.grammar/makefile b/adiff.grammar/makefile index 63f9acd23302a1aed5644072b073805db17d0fa1..b850e6b828a70d6944f0d4ef40c36280baf90a82 100644 --- a/adiff.grammar/makefile +++ b/adiff.grammar/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=adiff.grammar CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -LDFLAGS= -L../alib/lib -lxml2 -lalib +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/aepsilon/makefile b/aepsilon/makefile new file mode 100644 index 0000000000000000000000000000000000000000..f8ca8f76bdaa7ba23290a17cc46780950d7edc81 --- /dev/null +++ b/aepsilon/makefile @@ -0,0 +1,20 @@ +CC=g++ +EXECUTIBLE=aepsilon +CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. + +SOURCES=$(shell find src/ -name *cpp) +OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) + +all: $(SOURCES) bin/$(EXECUTIBLE) + +bin/$(EXECUTIBLE): $(OBJECTS) + mkdir -p bin + $(CC) $(LDFLAGS) $(OBJECTS) -o $@ + +obj/%.o: src/%.cpp + mkdir -p $(dir $@) + $(CC) $(CCFLAGS) $< -o $@ + +clean: + $(RM) -r *.o *.d bin obj diff --git a/alib/src/AutomatonFactory.cpp b/alib/src/AutomatonFactory.cpp index dd33ac24d45c862ae387df9bfcce6f4005b91a33..9fe20e2ea0e50396167fc125d7cc1c836f2475ff 100644 --- a/alib/src/AutomatonFactory.cpp +++ b/alib/src/AutomatonFactory.cpp @@ -32,10 +32,12 @@ UnknownAutomaton AutomatonFactory::fromString(const string& str) { } UnknownAutomaton AutomatonFactory::fromStdin() { - list<Token> tokens; - string input(istreambuf_iterator<char>(cin), (istreambuf_iterator<char>())); - SaxInterface::parseMemory(input, tokens); - return parse(tokens); + return AutomatonFactory::fromStream(cin); +} + +UnknownAutomaton AutomatonFactory::fromStream(std::istream& in) { + string input(istreambuf_iterator<char>(in), (istreambuf_iterator<char>())); + return AutomatonFactory::fromString(input); } UnknownAutomaton AutomatonFactory::parse(list<Token> tokens) { diff --git a/alib/src/AutomatonFactory.h b/alib/src/AutomatonFactory.h index f0a66216dc60575b842d709b2fc6fc3903af9990..8a987ca94cac44cde0ecb18b34d3f67fc504d445 100644 --- a/alib/src/AutomatonFactory.h +++ b/alib/src/AutomatonFactory.h @@ -43,6 +43,12 @@ public: * @return UnknownAutomaton */ static UnknownAutomaton fromStdin(); + + /** + * Parses the XML from stream and returns UnknownAutomaton. + * @return UnknownAutomaton + */ + static UnknownAutomaton fromStream(std::istream& in); /** * Tries to create specific automaton from UnknownAutomaton. diff --git a/alib/src/GrammarFactory.cpp b/alib/src/GrammarFactory.cpp index 17c29e87af019f4421f84d4c62761fb8768b55e9..40cf81b8179702f2083f70cfdd70492e8c5b9973 100644 --- a/alib/src/GrammarFactory.cpp +++ b/alib/src/GrammarFactory.cpp @@ -27,10 +27,12 @@ UnknownGrammar GrammarFactory::fromString(const string& str) { } UnknownGrammar GrammarFactory::fromStdin() { - list<Token> tokens; - string input(istreambuf_iterator<char>(cin), (istreambuf_iterator<char>())); - SaxInterface::parseMemory(input, tokens); - return parse(tokens); + return GrammarFactory::fromStream(cin); +} + +UnknownGrammar GrammarFactory::fromStream(std::istream& in) { + string input(istreambuf_iterator<char>(in), (istreambuf_iterator<char>())); + return GrammarFactory::fromString(input); } diff --git a/alib/src/GrammarFactory.h b/alib/src/GrammarFactory.h index 34a8bc5f1a94e91af2560d0a6bcf670959890e67..440a70c8c6075b25ac37832d91f0c117daa09217 100644 --- a/alib/src/GrammarFactory.h +++ b/alib/src/GrammarFactory.h @@ -46,6 +46,12 @@ public: * @return UnknownGrammar */ static UnknownGrammar fromStdin(); + + /** + * Parses the XML from stream and returns the UnknownGrammar. + * @return RegExp + */ + static UnknownGrammar fromStream(std::istream& in); /** * Tries to build RightRegularGrammar from any grammar. diff --git a/alib/src/RegExpFactory.cpp b/alib/src/RegExpFactory.cpp index 03a1ff8cf8018e2f358686cbcc90c145ef433bc8..e8d54eaf5f8ce8abbb7976f7639d93e3e55d14fe 100644 --- a/alib/src/RegExpFactory.cpp +++ b/alib/src/RegExpFactory.cpp @@ -26,12 +26,13 @@ RegExp RegExpFactory::fromString(const string& str) { } RegExp RegExpFactory::fromStdin() { - list<Token> tokens; - string input(istreambuf_iterator<char>(cin), (istreambuf_iterator<char>())); - SaxInterface::parseMemory(input, tokens); - return parse(tokens); + return RegExpFactory::fromStream(cin); } +RegExp RegExpFactory::fromStream(std::istream& in) { + string input(istreambuf_iterator<char>(in), (istreambuf_iterator<char>())); + return RegExpFactory::fromString(input); +} RegExp RegExpFactory::parse(list<sax::Token> tokens) { RegExpParser parser; diff --git a/alib/src/RegExpFactory.h b/alib/src/RegExpFactory.h index 4f5c0bdf41f8fec1bda0f295e518afebf8daaa5f..510ddddc1d867800f3824fc8c9cf52ae5a28ef34 100644 --- a/alib/src/RegExpFactory.h +++ b/alib/src/RegExpFactory.h @@ -41,6 +41,12 @@ public: */ static RegExp fromStdin(); + /** + * Parses the XML from stream and returns the RegExp. + * @return RegExp + */ + static RegExp fromStream(std::istream& in); + protected: /** * Parses the RegExp from list of tokens. diff --git a/alib/src/std/istream.cpp b/alib/src/std/istream.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f12a3dceb8d454ea662f3a13b59140ba5661a09d --- /dev/null +++ b/alib/src/std/istream.cpp @@ -0,0 +1,27 @@ +#include "istream.h" + +std::istream& oprr(std::istream& in, const std::string& str, bool start) { + if(str.size() == 0) return in; + char c_str = str[0]; + char c_in = in.peek(); + in.get(); + if(in.good()) { + if(start && (c_in == ' ' || c_in == '\n' || c_in == '\t')) { + oprr(in, str, start); + } else if(c_str == c_in) { + oprr(in, str.substr(1), false); + } else { + in.clear(std::ios::failbit); + } + } + if(in.fail()) { + in.clear(); + in.putback(c_in); + in.clear(std::ios::failbit); + } + return in; +} + +std::istream& operator>>(std::istream& in, const std::string& str) { + return oprr(in, str, true); +} \ No newline at end of file diff --git a/alib/src/std/istream.h b/alib/src/std/istream.h new file mode 100644 index 0000000000000000000000000000000000000000..4b285b3d2b97247be91fd6a0ffdfc5c53a4cde37 --- /dev/null +++ b/alib/src/std/istream.h @@ -0,0 +1,4 @@ +#include <iostream> +#include <string> + +std::istream& operator>>(std::istream& in, const std::string& str); diff --git a/aminimize/makefile b/aminimize/makefile index 0a3b760946feeefd117e22f838655ce68333994f..e9430cbc2d3431a2bda71341538d6b69af1126d9 100644 --- a/aminimize/makefile +++ b/aminimize/makefile @@ -1,7 +1,7 @@ CC=g++ EXECUTIBLE=aminimize CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -LDFLAGS= -L../alib/lib -lxml2 -lalib +LDFLAGS= -L../alib/lib -lxml2 -lalib -Wl,-rpath,. SOURCES=$(shell find src/ -name *cpp) OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) diff --git a/aminimize/src/Minimize.cpp b/aminimize/src/Minimize.cpp index 94834d87b40134778a60245c7244628a56eabe0a..71c6eb173f9960d1b7cc3c3106c03155ab5bdbdf 100644 --- a/aminimize/src/Minimize.cpp +++ b/aminimize/src/Minimize.cpp @@ -24,10 +24,11 @@ automaton::State fromInteger(int number) { automaton::FSM Minimize::minimize(automaton::FSM& fsm) { std::map<automaton::State, std::map<alphabet::Symbol, automaton::State > > refactor; + for(std::set<automaton::State>::const_iterator iter = fsm.getStates().begin(); iter != fsm.getStates().end(); iter++) { + refactor.insert(std::pair<automaton::State, std::map<alphabet::Symbol, automaton::State> >(*iter, std::map<alphabet::Symbol, automaton::State>())); + } + for(std::set<automaton::TransitionFSM>::const_iterator iter = fsm.getTransitions().begin(); iter != fsm.getTransitions().end(); iter++) { - if(refactor.find(iter->getFrom()) == refactor.end()) { - refactor.insert(std::pair<automaton::State, std::map<alphabet::Symbol, automaton::State> >(iter->getFrom(), std::map<alphabet::Symbol, automaton::State>())); - } refactor[iter->getFrom()].insert(std::pair<alphabet::Symbol, automaton::State>(iter->getInput(), iter->getTo())); } @@ -94,7 +95,7 @@ automaton::FSM Minimize::minimize(automaton::FSM& fsm) { } - } while(toEquvivalentStates1 != toEquvivalentStates2); + } while(minimizedTransitionFunction1.size() != minimizedTransitionFunction2.size()); automaton::FSM result; for(auto iter = fsm.getInputAlphabet().begin(); iter != fsm.getInputAlphabet().end(); iter++) { diff --git a/examples/automaton/DFA.txt b/examples/automaton/DFA.txt new file mode 100644 index 0000000000000000000000000000000000000000..4d38ef9168573a69bd3e3054a1cb2db1fbdac706 --- /dev/null +++ b/examples/automaton/DFA.txt @@ -0,0 +1,19 @@ +DFA a b c d +0 1 - - - +1 14 - - - +10 - 2 - - +11 - 8 - - +12 - 7 - - +13 - 16 - - +14 - - 5 12 +15 - - - 13 +<16 - - - - +<17 4 - - - +2 15 - - - +>3 10 9 0 12 +<4 - 11 - - +<5 - 6 5 - +<6 - - 5 - +<7 - - - 12 +8 10 17 0 12 +9 4 - - - diff --git a/examples/automaton/NFA.txt b/examples/automaton/NFA.txt new file mode 100644 index 0000000000000000000000000000000000000000..cdd3d18688d6e0c4223b25e475f2f2fd265320ed --- /dev/null +++ b/examples/automaton/NFA.txt @@ -0,0 +1,32 @@ +NFA a b c d \eps + >0 6|16 21 1|11|26 - 13 + 1 2 - - - - + 2 3 - - - - + 3 - - 4 - - + 4 - 5 - - 5 + <5 - - - - 3 + 6 - 7 - - - + 7 8 - - - - + 8 - - - 9 - + 9 - 10 - - - +<10 - - - - - + 11 12 - - - - + 12 13 - - - - + 13 - - - 14 - + 14 - 15 - - - +<15 - - - - 13 + 16 - 17 - - - + 17 18 - - - - + 18 - - - 19 - + 19 - 20 - - - +<20 - - - - - + 21 22 - - - - + 22 - 23 - - 25 + 23 - 24 - - - + 24 - 25 - - 0 +<25 - - - - - + 26 27 - - - - + 27 28 - - - - + 28 - - 29 - - + 29 - 30 - - - +<30 - - - - - \ No newline at end of file diff --git a/makefile b/makefile index b95fee2c30ccf634fef1c62c28a6c7e6bf8d43a3..474f166440cd4ec1924f25a5a7f6037dbfb5321e 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,9 @@ LIBPATH = /usr/lib/ BINFOLDER = bin SUBDIRS_LIBS = alib adeterminize -SUBDIRS_BINS = acat aconvert aconvert.dot aconvert.gastex aconvert.regexp aminimize adeterminize.fsm adiff adiff.automaton adiff.grammar +SUBDIRS_BINS = acat aconvert aconvert.dot aconvert.gastex aconvert.regexp aconvert.automaton aminimize adeterminize.fsm adiff adiff.automaton adiff.grammar aepsilon + +SUBDIRS_WITH_MAKE = $(dir $(wildcard */makefile)) .PHONY: $(SUBDIRS_LIBS) $(SUBDIRS_BINS) @@ -15,6 +17,11 @@ $(SUBDIRS_LIBS): $(SUBDIRS_BINS): $(MAKE) -C $@ +clean: + for dir in $(SUBDIRS_WITH_MAKE); do \ + $(MAKE) -C $$dir clean; \ + done + copy: mkdir -p $(BINFOLDER) rm -rf $(BINFOLDER)/*