diff --git a/.gitignore b/.gitignore index 4c68c8596d33674a2555a02dee72af3e4fc3ea53..bb9705ccce4f3164e6dc8e6535476e60bfcbb4d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ # Eclipse workspace data .metadata/ **/Debug +**/Debug* **/Release +**/Release* # Compiled Object files *.slo diff --git a/adiff/.cproject b/adiff/.cproject index 76c4eeef6a20bc25298289a8b95590f352920d67..5e208af5152cf7fed583417b544545909330e959 100644 --- a/adiff/.cproject +++ b/adiff/.cproject @@ -2,7 +2,7 @@ <?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> <storageModule moduleId="org.eclipse.cdt.core.settings"> <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1389902454"> - <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1389902454" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1389902454" moduleId="org.eclipse.cdt.core.settings" name="Debug [main]"> <externalSettings/> <extensions> <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> @@ -14,11 +14,11 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1389902454" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1389902454" name="Debug [main]" parent="cdt.managedbuild.config.gnu.exe.debug" postbuildStep=""> <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1389902454." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.454626149" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.812693871" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> - <builder buildPath="${workspace_loc:/aconvert}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.2059924356" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> + <builder buildPath="${workspace_loc:/adiff}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.2059924356" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> <tool id="cdt.managedbuild.tool.gnu.archiver.base.782713060" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.452059746" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.321734892" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> @@ -54,7 +54,7 @@ </toolChain> </folderInfo> <sourceEntries> - <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + <entry excluding="GrammarDiff.cpp|adiff.grammar.cpp|adiff.automaton.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> </sourceEntries> </configuration> </storageModule> @@ -108,6 +108,124 @@ </storageModule> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> </cconfiguration> + <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1389902454.965616874"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1389902454.965616874" moduleId="org.eclipse.cdt.core.settings" name="Debug [automaton]"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}.automaton" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1389902454.965616874" name="Debug [automaton]" parent="cdt.managedbuild.config.gnu.exe.debug"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1389902454.965616874." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.2083764015" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.2080037221" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> + <builder buildPath="${workspace_loc:/aconvert}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.1134251805" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.313650043" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.819469318" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> + <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.618382310" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> + <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.788271673" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option id="gnu.cpp.compiler.option.include.paths.1140157650" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/alib/src}""/> + <listOptionValue builtIn="false" value="/usr/include/libxml2"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.626820840" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.660633095" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.613789914" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.debug.option.debugging.level.369156856" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1287158091" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.222891700" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1403108847" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> + <option id="gnu.cpp.link.option.paths.1786368721" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/alib/Debug}""/> + </option> + <option id="gnu.cpp.link.option.libs.785792972" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="alib"/> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="xml2"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1727014311" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1746981636" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1556789424" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + <sourceEntries> + <entry excluding="GrammarDiff.cpp|adiff.cpp|adiff.grammar.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1389902454.1764668668"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1389902454.1764668668" moduleId="org.eclipse.cdt.core.settings" name="Debug [grammar]"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}.grammar" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1389902454.1764668668" name="Debug [grammar]" parent="cdt.managedbuild.config.gnu.exe.debug"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1389902454.1764668668." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1502870079" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1352110876" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> + <builder buildPath="${workspace_loc:/aconvert}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.1538179891" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.1058037401" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.341542549" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> + <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1667071802" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> + <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1926295146" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option id="gnu.cpp.compiler.option.include.paths.800939457" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/alib/src}""/> + <listOptionValue builtIn="false" value="/usr/include/libxml2"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1853502376" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.140132023" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.911900346" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.debug.option.debugging.level.1951781068" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.101116692" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1481312073" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.735817716" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> + <option id="gnu.cpp.link.option.paths.101527995" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/alib/Debug}""/> + </option> + <option id="gnu.cpp.link.option.libs.809173244" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="alib"/> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="xml2"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.582003490" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1472458704" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.2122650519" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + <sourceEntries> + <entry excluding="adiff.cpp|adiff.automaton.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> <project id="aconvert.cdt.managedbuild.target.gnu.exe.1109212462" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/> @@ -132,9 +250,13 @@ <configuration configurationName="Release"> <resource resourceType="PROJECT" workspacePath="/adiff"/> </configuration> - <configuration configurationName="Debug"> + <configuration configurationName="Debug [main]"> <resource resourceType="PROJECT" workspacePath="/adiff"/> + </configuration> + <configuration configurationName="Debug"> <resource resourceType="PROJECT" workspacePath="/acat"/> + <resource resourceType="PROJECT" workspacePath="/adiff"/> </configuration> </storageModule> + <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> </cproject> diff --git a/adiff/src/Diff.cpp b/adiff/src/AutomatonDiff.cpp similarity index 70% rename from adiff/src/Diff.cpp rename to adiff/src/AutomatonDiff.cpp index b4915bc201344243c121637b84a330895b57fadd..12842cb19d69d659940c1ac8b32235bde06103b5 100644 --- a/adiff/src/Diff.cpp +++ b/adiff/src/AutomatonDiff.cpp @@ -1,11 +1,11 @@ /* - * DotConverter.cpp + * AutomatonDiff.cpp * * Created on: Apr 1, 2013 * Author: martin */ -#include "Diff.h" +#include "AutomatonDiff.h" #include "automaton/State.h" #include "automaton/Automaton.h" @@ -22,7 +22,7 @@ using namespace std; using namespace automaton; -bool Diff::testDiff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b) { +bool AutomatonDiff::testDiff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b) { return a.getBlankSymbol() == b.getBlankSymbol() && a.getFinalStates() == b.getFinalStates() && a.getInitialStates() == b.getInitialStates() && @@ -34,7 +34,7 @@ bool Diff::testDiff(const automaton::UnknownAutomaton& a, const automaton::Unkno a.getTransitions() == b.getTransitions() ; } -template <class T> void Diff::setDiff(const set<T> a, const set<T> b) { +template <class T> void AutomatonDiff::setDiff(const set<T> a, const set<T> b) { set<T> aMinusB; set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(aMinusB, aMinusB.begin())); @@ -50,7 +50,7 @@ template <class T> void Diff::setDiff(const set<T> a, const set<T> b) { } } -template <class T> void Diff::listDiff(const list<T> a, const list<T> b) { +template <class T> void AutomatonDiff::listDiff(const list<T> a, const list<T> b) { list<T> aMinusB; set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(aMinusB, aMinusB.begin())); @@ -66,7 +66,7 @@ template <class T> void Diff::listDiff(const list<T> a, const list<T> b) { } } -void Diff::printDiff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b) { +void AutomatonDiff::printDiff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b) { cout << "AutomataDiffer" << endl; if(a.getBlankSymbol() != b.getBlankSymbol()) { @@ -80,52 +80,52 @@ void Diff::printDiff(const automaton::UnknownAutomaton& a, const automaton::Unkn if(a.getFinalStates() != b.getFinalStates()){ cout << "FinalStates" << endl; - Diff::setDiff(a.getFinalStates(), b.getFinalStates()); + AutomatonDiff::setDiff(a.getFinalStates(), b.getFinalStates()); } if(a.getInitialStates() != b.getInitialStates()){ cout << "InitialStates" << endl; - Diff::setDiff(a.getInitialStates(), b.getInitialStates()); + AutomatonDiff::setDiff(a.getInitialStates(), b.getInitialStates()); } if(a.getInputAlphabet() != b.getInputAlphabet()) { cout << "InputAlphabet" << endl; - Diff::setDiff(a.getInputAlphabet(), b.getInputAlphabet()); + AutomatonDiff::setDiff(a.getInputAlphabet(), b.getInputAlphabet()); } if(a.getStackAlphabet() != b.getStackAlphabet()) { cout << "StackAlphabet" << endl; - Diff::setDiff(a.getStackAlphabet(), b.getStackAlphabet()); + AutomatonDiff::setDiff(a.getStackAlphabet(), b.getStackAlphabet()); } if(a.getStartSymbols() != b.getStartSymbols()) { cout << "StartSymbols" << endl; - Diff::listDiff(a.getStartSymbols(), b.getStartSymbols()); + AutomatonDiff::listDiff(a.getStartSymbols(), b.getStartSymbols()); } if(a.getStates() != b.getStates()) { cout << "States" << endl; - Diff::setDiff(a.getStates(), b.getStates()); + AutomatonDiff::setDiff(a.getStates(), b.getStates()); } if(a.getTapeAlphabet() != b.getTapeAlphabet()) { cout << "TapeAlphabet" << endl; - Diff::setDiff(a.getTapeAlphabet(), b.getTapeAlphabet()); + AutomatonDiff::setDiff(a.getTapeAlphabet(), b.getTapeAlphabet()); } if(a.getTransitions() != b.getTransitions()) { cout << "Transitions" << endl; - Diff::setDiff(a.getTransitions(), b.getTransitions()); + AutomatonDiff::setDiff(a.getTransitions(), b.getTransitions()); } } -void Diff::diff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b) { - if(!Diff::testDiff(a, b)) Diff::printDiff(a, b); +void AutomatonDiff::diff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b) { + if(!AutomatonDiff::testDiff(a, b)) AutomatonDiff::printDiff(a, b); } diff --git a/adiff/src/Diff.h b/adiff/src/AutomatonDiff.h similarity index 83% rename from adiff/src/Diff.h rename to adiff/src/AutomatonDiff.h index 9422f649b90adcd05c44dd8b566fbf41576fae09..9c06544d84a8391e0f547e3b65d3acccedc54dd0 100644 --- a/adiff/src/Diff.h +++ b/adiff/src/AutomatonDiff.h @@ -1,12 +1,12 @@ /* - * Diff.h + * AutomatonDiff.h * * Created on: Apr 1, 2013 * Author: honza */ -#ifndef DIFF_H_ -#define DIFF_H_ +#ifndef AUTOMATON_DIFF_H_ +#define AUTOMATON_DIFF_H_ #include <ostream> @@ -14,7 +14,7 @@ #include <map> #include <utility> -class Diff { +class AutomatonDiff { static bool testDiff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b); static void printDiff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b); @@ -24,4 +24,4 @@ public: static void diff(const automaton::UnknownAutomaton& a, const automaton::UnknownAutomaton& b); }; -#endif /* DOTCONVERTER_H_ */ +#endif /* AUTOMATON_DIFF_H_ */ diff --git a/adiff/src/GrammarDiff.cpp b/adiff/src/GrammarDiff.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a1195dbe1d407e33435d890048f9d6e0e3bd3990 --- /dev/null +++ b/adiff/src/GrammarDiff.cpp @@ -0,0 +1,94 @@ +/* + * GrammarDiff.cpp + * + * Created on: Apr 1, 2013 + * Author: honza + */ + +#include "GrammarDiff.h" + +#include <set> +#include <map> +#include <list> +#include <utility> +#include <vector> +#include <typeinfo> +#include <iostream> +#include <algorithm> + +using namespace std; +using namespace grammar; + +bool GrammarDiff::testDiff(const grammar::UnknownGrammar& a, const grammar::UnknownGrammar& b) { + return a.getNonTerminalSymbols() == b.getNonTerminalSymbols() && + a.getRules() == b.getRules() && + a.getStartSymbol() == b.getStartSymbol() && + a.getTerminalSymbols() == b.getTerminalSymbols() ; +} + +template <class T> void GrammarDiff::setDiff(const set<T> a, const set<T> b) { + set<T> aMinusB; + set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(aMinusB, aMinusB.begin())); + + set<T> bMinusA; + set_difference(b.begin(), b.end(), a.begin(), a.end(), std::inserter(bMinusA, bMinusA.begin())); + + for(typename set<T>::const_iterator iter = aMinusB.begin(); iter != aMinusB.end(); iter++) { + cout << "< " << *iter << endl; + } + cout << "---" << endl; + for(typename set<T>::const_iterator iter = bMinusA.begin(); iter != bMinusA.end(); iter++) { + cout << "> " << *iter << endl; + } +} + +template <class T> void GrammarDiff::listDiff(const list<T> a, const list<T> b) { + list<T> aMinusB; + set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(aMinusB, aMinusB.begin())); + + list<T> bMinusA; + set_difference(b.begin(), b.end(), a.begin(), a.end(), std::inserter(bMinusA, bMinusA.begin())); + + for(typename list<T>::const_iterator iter = aMinusB.begin(); iter != aMinusB.end(); iter++) { + cout << "< " << *iter << endl; + } + cout << "---" << endl; + for(typename list<T>::const_iterator iter = bMinusA.begin(); iter != bMinusA.end(); iter++) { + cout << "> " << *iter << endl; + } +} + +void GrammarDiff::printDiff(const grammar::UnknownGrammar& a, const grammar::UnknownGrammar& b) { + cout << "GrammarDiffer" << endl; + + if(a.getNonTerminalSymbols() != b.getNonTerminalSymbols()) { + cout << "Nonterminal symbols" << endl; + + GrammarDiff::setDiff(a.getNonTerminalSymbols(), b.getNonTerminalSymbols()); + } + + if(a.getRules() != b.getRules()){ + cout << "Rules" << endl; + + GrammarDiff::setDiff(a.getRules(), b.getRules()); + } + + if(a.getStartSymbol() != b.getStartSymbol()){ + cout << "Start symbol" << endl; + + cout << "< " << a.getStartSymbol() << endl; + cout << "---" << endl; + cout << "> " << b.getStartSymbol() << endl; + } + + if(a.getTerminalSymbols() != b.getTerminalSymbols()) { + cout << "Terminal symbols" << endl; + + GrammarDiff::setDiff(a.getTerminalSymbols(), b.getTerminalSymbols()); + } + +} + +void GrammarDiff::diff(const grammar::UnknownGrammar& a, const grammar::UnknownGrammar& b) { + if(!GrammarDiff::testDiff(a, b)) GrammarDiff::printDiff(a, b); +} diff --git a/adiff/src/GrammarDiff.h b/adiff/src/GrammarDiff.h new file mode 100644 index 0000000000000000000000000000000000000000..4f99f1e8aa10060aa38beadea880905fc167a59e --- /dev/null +++ b/adiff/src/GrammarDiff.h @@ -0,0 +1,27 @@ +/* + * GrammarDiff.h + * + * Created on: Apr 1, 2013 + * Author: honza + */ + +#ifndef GRAMMAR_DIFF_H_ +#define GRAMMAR_DIFF_H_ + +#include <ostream> + +#include <grammar/UnknownGrammar.h> +#include <map> +#include <utility> + +class GrammarDiff { + static bool testDiff(const grammar::UnknownGrammar& a, const grammar::UnknownGrammar& b); + static void printDiff(const grammar::UnknownGrammar& a, const grammar::UnknownGrammar& b); + + template <class T> static void setDiff(const std::set<T> a, const std::set<T> b); + template <class T> static void listDiff(const std::list<T> a, const std::list<T> b); +public: + static void diff(const grammar::UnknownGrammar& a, const grammar::UnknownGrammar& b); +}; + +#endif /* GRAMMAR_DIFF_H_ */ diff --git a/adiff/src/adiff.automaton.cpp b/adiff/src/adiff.automaton.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c95000b3584098e76016db1ad02500bc2fb8362 --- /dev/null +++ b/adiff/src/adiff.automaton.cpp @@ -0,0 +1,43 @@ +//============================================================================ +// Name : adiff.cpp +// Author : Honza +// Version : +// Copyright : +// Description : +//============================================================================ + +#include <iostream> + +#include "automaton/UnknownAutomaton.h" +#include "AutomatonFactory.h" +#include "AlibException.h" + +using namespace std; +using namespace automaton; +using namespace alib; + +#include "AutomatonDiff.h" + +int main(int argc, char** argv) { + + UnknownAutomaton automaton1; + UnknownAutomaton automaton2; + + try { + + if (argc == 2 && string("-h").compare(argv[1]) == 0) { + cout << "Automaton diff.\nUsage: adiff automaton.xml automaton.xml\n"; + return -1; + } + + if (argc == 3) { + automaton1 = AutomatonFactory::fromFile(argv[1]); + automaton2 = AutomatonFactory::fromFile(argv[2]); + } + + AutomatonDiff::diff(automaton1, automaton2); + } catch (AlibException& e) { + cout << e.getCause() << endl; + return 0; + } +} diff --git a/adiff/src/adiff.cpp b/adiff/src/adiff.cpp index fd7398f41ad38fdd560a40d4cb2bd619fa0fcd04..05631489bad30368483c3c0e5c0f290d2eb10894 100644 --- a/adiff/src/adiff.cpp +++ b/adiff/src/adiff.cpp @@ -1,43 +1,62 @@ -//============================================================================ -// Name : aconvert.cpp -// Author : Martin Zak -// Version : -// Copyright : -// Description : -//============================================================================ - -#include <iostream> - -#include "automaton/UnknownAutomaton.h" -#include "AutomatonFactory.h" -#include "AlibException.h" - -using namespace std; -using namespace automaton; -using namespace alib; - -#include "Diff.h" - -int main(int argc, char** argv) { - - UnknownAutomaton automaton1; - UnknownAutomaton automaton2; - - try { - - if (argc == 2 && string("-h").compare(argv[1]) == 0) { - cout << "Automaton diff.\nUsage: adiff automaton.xml automaton.xml\n"; - return -1; - } +/* + * diff + * + * Usage: diff [-V] [-t difftype] [diff-options] input1 input2 + * + * Authors: + * + */ + +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <err.h> +#include <stdlib.h> + +#define PROGNAME "adiff.%s" +#define VERSION "0.0.1" + +int main(int argc, char *argv[]) { + if (argc == 2 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) { + char* program_name = argv[0]; + char* p = NULL; + if ((p = strrchr(program_name, '/')) != NULL) + program_name = p + 1; + + printf("%s (%s)\n", program_name, VERSION); + exit(EXIT_SUCCESS); + } - if (argc == 3) { - automaton1 = AutomatonFactory::fromFile(argv[1]); - automaton2 = AutomatonFactory::fromFile(argv[2]); + char* difftype = NULL; + int i, verbose = 0; + + while ((i = getopt(argc, argv, "Vt:")) != -1) + switch (i) { + case 'V': + verbose = 1; + break; + case 't': + difftype = optarg; + break; + default: + optind--; + goto more; } - - Diff::diff(automaton1, automaton2); - } catch (AlibException& e) { - cout << e.getCause() << endl; - return 0; +more: + + if (optind == argc || difftype == NULL) { + fprintf(stderr, "Usage: adiff [-V] -t difftype [diff-options] input1 input2"); + return EXIT_FAILURE; + } else { + char* program_name = (char*) malloc(sizeof(PROGNAME) - 2 + strlen(difftype) + 1); + sprintf(program_name, PROGNAME, difftype); + if (verbose) + argv[--optind] = (char*) "-V"; + + argv[--optind] = program_name; + + execvp(program_name, argv + optind); + perror(program_name); + return EXIT_FAILURE; } } diff --git a/adiff/src/adiff.grammar.cpp b/adiff/src/adiff.grammar.cpp new file mode 100644 index 0000000000000000000000000000000000000000..85151541f652ddf80af98c11c39fa6ef91662e13 --- /dev/null +++ b/adiff/src/adiff.grammar.cpp @@ -0,0 +1,43 @@ +//============================================================================ +// Name : aconvert.cpp +// Author : Martin Zak +// Version : +// Copyright : +// Description : +//============================================================================ + +#include <iostream> + +#include "grammar/UnknownGrammar.h" +#include "GrammarFactory.h" +#include "AlibException.h" + +using namespace std; +using namespace grammar; +using namespace alib; + +#include "GrammarDiff.h" + +int main(int argc, char** argv) { + + UnknownGrammar grammar1; + UnknownGrammar grammar2; + + try { + + if (argc == 2 && string("-h").compare(argv[1]) == 0) { + cout << "Grammar diff.\nUsage: adiff grammar1.xml grammar2.xml\n"; + return -1; + } + + if (argc == 3) { + grammar1 = GrammarFactory::fromFile(argv[1]); + grammar2 = GrammarFactory::fromFile(argv[2]); + } + + GrammarDiff::diff(grammar1, grammar2); + } catch (AlibException& e) { + cout << e.getCause() << endl; + return 0; + } +} diff --git a/alib/src/automaton/FSM/FSM.cpp b/alib/src/automaton/FSM/FSM.cpp index 6a90f060c6d6654ba7559976eb6b174bd2505943..5d5804ecce35d8a5c013d1d0696632862b9e7f38 100644 --- a/alib/src/automaton/FSM/FSM.cpp +++ b/alib/src/automaton/FSM/FSM.cpp @@ -132,4 +132,8 @@ bool FSM::isDeterministic() const { return true; } +bool FSM::isTotal() const { + return isDeterministic() && transitions.size() == inputAlphabet.size() * states.size(); +} + } /* namespace automaton */ diff --git a/alib/src/automaton/FSM/FSM.h b/alib/src/automaton/FSM/FSM.h index 0e43b41cde89daa1cdae3a8c17cdf2ab08b9d438..9cbafba41637ebe358be9b1d62b4966ceefea941 100644 --- a/alib/src/automaton/FSM/FSM.h +++ b/alib/src/automaton/FSM/FSM.h @@ -83,6 +83,8 @@ public: */ bool isDeterministic() const; + bool isTotal() const; + /** * @copydoc Automaton::toXML(ostream&) const */