diff --git a/acat/.cproject b/acat/.cproject new file mode 100644 index 0000000000000000000000000000000000000000..2f9bd199bc464ec0893026f41111a6dcba2dadfa --- /dev/null +++ b/acat/.cproject @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?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.1339773719"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1339773719" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <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"/> + </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.1339773719" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1339773719." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.972126435" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1736116871" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> + <builder buildPath="${workspace_loc:/acat}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.680984553" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.238852067" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.630705360" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> + <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1136510560" 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.1288948074" 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.1161046096" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/alib/src}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1348541393" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1358211615" 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.386220769" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.debug.option.debugging.level.1373749157" 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.841290958" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.733383257" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1272321488" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> + <option id="gnu.cpp.link.option.libs.146254674" 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> + <option id="gnu.cpp.link.option.paths.1024007423" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/alib/Debug}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1001844195" 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.818973707" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1191652594" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + <sourceEntries> + <entry 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.release.1729012467"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1729012467" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <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"/> + </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.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1729012467" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.release.1729012467." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.764536354" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.157215254" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> + <builder buildPath="${workspace_loc:/acat}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.1947495443" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.1445783848" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.771295474" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"> + <option id="gnu.cpp.compiler.exe.release.option.optimization.level.1053839837" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="gnu.cpp.compiler.exe.release.option.debugging.level.380137052" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1505096080" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1034004551" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1449918516" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.release.option.debugging.level.1888530997" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.174670010" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1731159666" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1225000214" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.687502089" 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.release.1111729612" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.326565661" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + <sourceEntries> + <entry 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="acat.cdt.managedbuild.target.gnu.exe.1183027156" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1729012467;cdt.managedbuild.config.gnu.exe.release.1729012467.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.771295474;cdt.managedbuild.tool.gnu.cpp.compiler.input.1505096080"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1339773719;cdt.managedbuild.config.gnu.exe.debug.1339773719.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1358211615;cdt.managedbuild.tool.gnu.c.compiler.input.841290958"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1729012467;cdt.managedbuild.config.gnu.exe.release.1729012467.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1034004551;cdt.managedbuild.tool.gnu.c.compiler.input.174670010"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1339773719;cdt.managedbuild.config.gnu.exe.debug.1339773719.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.630705360;cdt.managedbuild.tool.gnu.cpp.compiler.input.1348541393"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/acat"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/acat"/> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> +</cproject> diff --git a/acat/.project b/acat/.project new file mode 100644 index 0000000000000000000000000000000000000000..7b9e2374fc6c29b7e2287bb7a579289a6e03246e --- /dev/null +++ b/acat/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>acat</name> + <comment></comment> + <projects> + <project>alib</project> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/acat/.settings/org.eclipse.cdt.codan.core.prefs b/acat/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..77386c23cbe3d3828b719e46914e7d33ce67f7a5 --- /dev/null +++ b/acat/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,67 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} diff --git a/acat/src/acat.cpp b/acat/src/acat.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b335bbb22aff77eb329cd749a99db2f59f6f1db1 --- /dev/null +++ b/acat/src/acat.cpp @@ -0,0 +1,38 @@ +//============================================================================ +// Name : acat.cpp +// Author : Martin Zak +//============================================================================ + +#include <iostream> +#include <string> +#include <set> + +#include "AutomatonFactory.h" +#include "AlibException.h" + +using namespace std; +using namespace automaton; +using namespace sax; + +int main(int argc, char** argv) { + Automaton* automaton; + + try { + if (argc > 1) { + if (string("-h").compare(argv[1]) == 0) { + cout << "Automaton parsing.\nUsage: catPDA [automaton.xml]\n"; + return -1; + } + automaton = AutomatonFactory::fromFile(argv[1]); + } else { + string input(istreambuf_iterator<char>(cin), (istreambuf_iterator<char>())); + automaton = AutomatonFactory::fromString(input); + } + automaton->toXML(cout); + } catch (AlibException& e) { + cout << e.toString() << endl; + return 0; + } + + cout.flush(); +} diff --git a/aconvert/.cproject b/aconvert/.cproject new file mode 100644 index 0000000000000000000000000000000000000000..c7d39d0249e704d66e848957bfbf5e9b1a52d980 --- /dev/null +++ b/aconvert/.cproject @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?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"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <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"/> + </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"> + <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"/> + <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"/> + <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1415246353" 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.2073574774" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/alib/src}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1656337932" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1115594717" 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.1539673145" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.debug.option.debugging.level.766263807" 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.2117920585" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1240065093" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1385250618" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> + <option id="gnu.cpp.link.option.paths.128536543" 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.88373145" 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.1779546704" 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.295789707" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.132473088" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + <sourceEntries> + <entry 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.release.2111257635"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.2111257635" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <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"/> + </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.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.2111257635" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.release.2111257635." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.827624498" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.882598890" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> + <builder buildPath="${workspace_loc:/aconvert}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.1272738146" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.324375521" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1207678972" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"> + <option id="gnu.cpp.compiler.exe.release.option.optimization.level.1925326928" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="gnu.cpp.compiler.exe.release.option.debugging.level.33064772" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.764767250" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1173822661" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1245639446" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.release.option.debugging.level.548864709" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1359867868" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1157405154" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1898429834" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.174029232" 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.release.500953211" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1087716091" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + <sourceEntries> + <entry 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"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1389902454;cdt.managedbuild.config.gnu.exe.debug.1389902454.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1115594717;cdt.managedbuild.tool.gnu.c.compiler.input.2117920585"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.2111257635;cdt.managedbuild.config.gnu.exe.release.2111257635.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1173822661;cdt.managedbuild.tool.gnu.c.compiler.input.1359867868"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1389902454;cdt.managedbuild.config.gnu.exe.debug.1389902454.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.452059746;cdt.managedbuild.tool.gnu.cpp.compiler.input.1656337932"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.2111257635;cdt.managedbuild.config.gnu.exe.release.2111257635.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1207678972;cdt.managedbuild.tool.gnu.cpp.compiler.input.764767250"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope"/> +</cproject> diff --git a/aconvert/.project b/aconvert/.project new file mode 100644 index 0000000000000000000000000000000000000000..a07090e5940ae47bddda50be143fb73f30bc4d3a --- /dev/null +++ b/aconvert/.project @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>aconvert</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/aconvert/src/DotConverter.cpp b/aconvert/src/DotConverter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d30035e88a67c6ee77a831c079347e3d94232b48 --- /dev/null +++ b/aconvert/src/DotConverter.cpp @@ -0,0 +1,215 @@ +/* + * DotConverter.cpp + * + * Created on: Apr 1, 2013 + * Author: martin + */ + +#include "DotConverter.h" +#include "automaton/State.h" + +#include "automaton/Automaton.h" + +#include <set> +#include <map> +#include <list> +#include <utility> +#include <vector> +#include <typeinfo> + +using namespace std; +using namespace automaton; + +void DotConverter::convert(const automaton::Automaton& a, std::ostream& out) { + out << "digraph automaton {\n"; + out << "rankdir=LR;\n"; + int cnt = 1; + + //Map states to indices + map<State, int> states; + for (set<State>::iterator it = a.getStates().begin(); it != a.getStates().end(); it++) { + states.insert(pair<State, int>((*it), cnt++)); + } + + //Print final states + for (set<State>::const_iterator fsi = a.getFinalStates().begin(); fsi != a.getFinalStates().end(); fsi++) { + out << "node [shape = doublecircle, label=\"" << fsi->getName() << "\"]; " << states.find(*fsi)->second + << ";\n"; + } + + //Print nonfinal states + for (map<State, int>::const_iterator it = states.begin(); it != states.end(); it++) { + if (a.getFinalStates().find(it->first) == a.getFinalStates().end()) { + out << "node [shape = circle, label=\"" << it->first.getName() << "\" ]; " << it->second << ";\n"; + } + } + + //Mark initial states + out << "node [shape = plaintext, label=\"start\"]; 0; \n"; + for (set<State>::const_iterator it = a.getInitialStates().begin(); it != a.getInitialStates().end(); it++) { + out << "0 -> " << states.find(*it)->second << ";\n"; + } + + try { + const FSM& fsm = dynamic_cast<const FSM&>(a); + transitions(fsm, states, out); + out << "}"; + return; + } catch (const std::bad_cast& e) { + } + + try { + const PDA& pda = dynamic_cast<const PDA&>(a); + transitions(pda, states, out); + out << "}"; + return; + } catch (const std::bad_cast& e) { + } + + try { + const TM& tm = dynamic_cast<const TM&>(a); + transitions(tm, states, out); + out << "}"; + return; + } catch (const std::bad_cast& e) { + } + +} + +void DotConverter::transitions(const automaton::FSM& fsm, const std::map<automaton::State, int>& states, + std::ostream& out) { + + map<pair<int, int>, string> transitions; + const set<automaton::TransitionFSM>& t = fsm.getTransitions(); + + //put transitions from automaton to "transitions" + set<automaton::TransitionFSM>::const_iterator it = t.begin(); + while (it != t.end()) { + string symbol; + if (it->getInput().getSymbol().compare("") == 0) { + symbol = "ε"; + } else { + symbol = it->getInput().getSymbol(); + } + + pair<int, int> key(states.find(it->getCurrent())->second, states.find(it->getNext())->second); + map<pair<int, int>, string>::iterator mapit = transitions.find(key); + + if (mapit == transitions.end()) { + transitions.insert(pair<pair<int, int>, string>(key, symbol)); + } else { + mapit->second += "," + symbol; + } + + it++; + } + + //print the map + map<pair<int, int>, string>::iterator it2 = transitions.begin(); + while (it2 != transitions.end()) { + out << it2->first.first << " -> " << it2->first.second; + out << "[label=\"" << it2->second << "\"]\n"; + it2++; + } +} +void DotConverter::transitions(const automaton::PDA& pda, const std::map<automaton::State, int>& states, + std::ostream& out) { + map<pair<int, int>, string> transitions; + const set<automaton::TransitionPDA>& t = pda.getTransitions(); + + //put transitions from automaton to "transitions" + set<automaton::TransitionPDA>::const_iterator it = t.begin(); + while (it != t.end()) { + string symbol; + + //input symbol + if (it->getInput().getSymbol().compare("") == 0) { + symbol = "ε"; + } else { + symbol = it->getInput().getSymbol(); + } + + symbol += ","; + + //Pop part + if (it->getPop().size() == 0) { + symbol += " ε"; + } else { + for (list<Symbol>::const_iterator symb = it->getPop().begin(); symb != it->getPop().end(); symb++) { + symbol += " " + symb->getSymbol(); + } + + } + + symbol += "/"; + + //Push part + if (it->getPush().size() == 0) { + symbol += "ε"; + } else { + for (list<Symbol>::const_iterator symb = it->getPush().begin(); symb != it->getPush().end(); symb++) { + symbol += symb->getSymbol() + " "; + } + + } + + //Insert into map + pair<int, int> key(states.find(it->getCurrent())->second, states.find(it->getNext())->second); + map<pair<int, int>, string>::iterator mapit = transitions.find(key); + + if (mapit == transitions.end()) { + transitions.insert(pair<pair<int, int>, string>(key, symbol)); + } else { + mapit->second += "\\n" + symbol; + } + + it++; + } + + //print the map + map<pair<int, int>, string>::iterator it2 = transitions.begin(); + while (it2 != transitions.end()) { + out << it2->first.first << " -> " << it2->first.second; + out << "[label=\"" << it2->second << "\"]\n"; + it2++; + } +} + +void DotConverter::transitions(const automaton::TM& tm, const std::map<automaton::State, int>& states, + std::ostream& out) { + map<pair<int, int>, string> transitions; + const set<automaton::TransitionTM>& t = tm.getTransitions(); + + //put transitions from automaton to "transitions" + set<automaton::TransitionTM>::const_iterator it = t.begin(); + while (it != t.end()) { + string symbol; + + //input symbol + symbol = it->getInput().getSymbol(); + symbol += "/"; + symbol += it->getOutput().getSymbol(); + symbol += " "; + symbol += (std::string[] ) { "←", "→", "×" } [it->getShift()]; + + //Insert into map + pair<int, int> key(states.find(it->getCurrent())->second, states.find(it->getNext())->second); + map<pair<int, int>, string>::iterator mapit = transitions.find(key); + + if (mapit == transitions.end()) { + transitions.insert(pair<pair<int, int>, string>(key, symbol)); + } else { + mapit->second += "\\n" + symbol; + } + + it++; + } + + //print the map + map<pair<int, int>, string>::iterator it2 = transitions.begin(); + while (it2 != transitions.end()) { + out << it2->first.first << " -> " << it2->first.second; + out << "[label=\"" << it2->second << "\"]\n"; + it2++; + } +} diff --git a/aconvert/src/DotConverter.h b/aconvert/src/DotConverter.h new file mode 100644 index 0000000000000000000000000000000000000000..63cebef764966b1c7e1e275ed921d8e84424ffb0 --- /dev/null +++ b/aconvert/src/DotConverter.h @@ -0,0 +1,28 @@ +/* + * DotConverter.h + * + * Created on: Apr 1, 2013 + * Author: martin + */ + +#ifndef DOTCONVERTER_H_ +#define DOTCONVERTER_H_ + +#include<ostream> + +#include <automaton/FSM/FSM.h> +#include <automaton/PDA/PDA.h> +#include <automaton/TM/TM.h> +#include <map> +#include <utility> + +class DotConverter { +protected: + static void transitions(const automaton::FSM& fsm, const std::map<automaton::State, int>& states, std::ostream& out); + static void transitions(const automaton::PDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); + static void transitions(const automaton::TM& tm, const std::map<automaton::State, int>& states, std::ostream& out); +public: + static void convert(const automaton::Automaton& a, std::ostream& out); +}; + +#endif /* DOTCONVERTER_H_ */ diff --git a/aconvert/src/aconvert.cpp b/aconvert/src/aconvert.cpp new file mode 100644 index 0000000000000000000000000000000000000000..923790e8876b84b920b301adcf72b3281098bae4 --- /dev/null +++ b/aconvert/src/aconvert.cpp @@ -0,0 +1,43 @@ +//============================================================================ +// Name : aconvert.cpp +// Author : Martin Zak +// Version : +// Copyright : +// Description : +//============================================================================ + +#include <iostream> + +#include "AutomatonFactory.h" +#include "AlibException.h" + +using namespace std; +using namespace automaton; + +#include "DotConverter.h" + +int main(int argc, char** argv) { + + Automaton* automaton; + + try { + + if (argc > 1) { + if (string("-h").compare(argv[1]) == 0) { + cout << "Automaton parsing.\nUsage: catPDA [automaton.xml]\n"; + return -1; + } + + automaton = AutomatonFactory::fromFile(argv[1]); + } else { + string input(istreambuf_iterator<char>(cin), (istreambuf_iterator<char>())); + automaton = AutomatonFactory::fromString(input); + } + } catch (AlibException& e) { + cout << e.toString() << endl; + return 0; + } + + DotConverter::convert(*automaton,cout); + //DotConverter::ConvertFSM(*fsm, std::cout); +} diff --git a/alib/.cproject b/alib/.cproject new file mode 100644 index 0000000000000000000000000000000000000000..2d1eb54860a5ea75d9451bc7a8096dc952ccfdb6 --- /dev/null +++ b/alib/.cproject @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?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.so.debug.768984509"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.so.debug.768984509" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings> + <externalSetting> + <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/alib"/> + <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/alib/Debug"/> + <entry flags="RESOLVED" kind="libraryFile" name="alib" srcPrefixMapping="" srcRootPath=""/> + </externalSetting> + </externalSettings> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <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"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" 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.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.so.debug.768984509" name="Debug" parent="cdt.managedbuild.config.gnu.so.debug"> + <folderInfo id="cdt.managedbuild.config.gnu.so.debug.768984509." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.so.debug.1067625866" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.so.debug"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.so.debug.827095317" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.so.debug"/> + <builder buildPath="${workspace_loc:/alib/Debug}" id="cdt.managedbuild.target.gnu.builder.so.debug.426687989" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.so.debug"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.1643390113" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.2036943508" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug"> + <option id="gnu.cpp.compiler.so.debug.option.optimization.level.920123652" name="Optimization Level" superClass="gnu.cpp.compiler.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> + <option id="gnu.cpp.compiler.so.debug.option.debugging.level.692681082" name="Debug Level" superClass="gnu.cpp.compiler.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option id="gnu.cpp.compiler.option.other.pic.1811026235" name="Position Independent Code (-fPIC)" superClass="gnu.cpp.compiler.option.other.pic" value="true" valueType="boolean"/> + <option id="gnu.cpp.compiler.option.include.paths.1670765613" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.62684000" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.so.debug.44664480" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.so.debug.option.optimization.level.2042928958" name="Optimization Level" superClass="gnu.c.compiler.so.debug.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.so.debug.option.debugging.level.2111938067" name="Debug Level" superClass="gnu.c.compiler.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1764989242" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.so.debug.860500774" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.debug"> + <option defaultValue="true" id="gnu.c.link.so.debug.option.shared.1407213603" name="Shared (-shared)" superClass="gnu.c.link.so.debug.option.shared" valueType="boolean"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.1999227198" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.debug"> + <option defaultValue="true" id="gnu.cpp.link.so.debug.option.shared.564227071" name="Shared (-shared)" superClass="gnu.cpp.link.so.debug.option.shared" valueType="boolean"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1254427525" 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.so.debug.1388120330" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.debug"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.209891175" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + <cconfiguration id="cdt.managedbuild.config.gnu.so.release.337532063"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.so.release.337532063" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings> + <externalSetting> + <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/alib"/> + <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/alib/Release"/> + <entry flags="RESOLVED" kind="libraryFile" name="alib" srcPrefixMapping="" srcRootPath=""/> + </externalSetting> + </externalSettings> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <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"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.so.release.337532063" name="Release" parent="cdt.managedbuild.config.gnu.so.release"> + <folderInfo id="cdt.managedbuild.config.gnu.so.release.337532063." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.so.release.804782292" name="Linux GCC" resourceTypeBasedDiscovery="true" superClass="cdt.managedbuild.toolchain.gnu.so.release"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.so.release.507490243" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.so.release"/> + <builder buildPath="${workspace_loc:/alib/Release}" id="cdt.managedbuild.target.gnu.builder.so.release.75486599" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.so.release"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.1620715757" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1510496158" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release"> + <option id="gnu.cpp.compiler.so.release.option.optimization.level.1892306879" name="Optimization Level" superClass="gnu.cpp.compiler.so.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="gnu.cpp.compiler.so.release.option.debugging.level.1345463924" name="Debug Level" superClass="gnu.cpp.compiler.so.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> + <option id="gnu.cpp.compiler.option.other.pic.1416857244" name="Position Independent Code (-fPIC)" superClass="gnu.cpp.compiler.option.other.pic" value="true" valueType="boolean"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.805019171" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.so.release.178329725" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.so.release.option.optimization.level.1510146540" name="Optimization Level" superClass="gnu.c.compiler.so.release.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.so.release.option.debugging.level.1353109764" name="Debug Level" superClass="gnu.c.compiler.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2005479384" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.so.release.843706875" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.release"> + <option defaultValue="true" id="gnu.c.link.so.release.option.shared.1815504037" name="Shared (-shared)" superClass="gnu.c.link.so.release.option.shared" valueType="boolean"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.240094523" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.release"> + <option defaultValue="true" id="gnu.cpp.link.so.release.option.shared.354496193" name="Shared (-shared)" superClass="gnu.cpp.link.so.release.option.shared" valueType="boolean"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.468094556" 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.so.release.717884044" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.release"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.2071065454" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="alib.cdt.managedbuild.target.gnu.so.571644847" name="Shared Library" projectType="cdt.managedbuild.target.gnu.so"/> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/alib"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/alib"/> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.release.337532063"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.debug.768984509;cdt.managedbuild.config.gnu.so.debug.768984509.;cdt.managedbuild.tool.gnu.c.compiler.so.debug.44664480;cdt.managedbuild.tool.gnu.c.compiler.input.1764989242"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.debug.768984509;cdt.managedbuild.config.gnu.so.debug.768984509.;cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.2036943508;cdt.managedbuild.tool.gnu.cpp.compiler.input.62684000"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.release.337532063;cdt.managedbuild.config.gnu.so.release.337532063.;cdt.managedbuild.tool.gnu.c.compiler.so.release.178329725;cdt.managedbuild.tool.gnu.c.compiler.input.2005479384"> + <autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.release.337532063;cdt.managedbuild.config.gnu.so.release.337532063.;cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1510496158;cdt.managedbuild.tool.gnu.cpp.compiler.input.805019171"> + <autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> +</cproject> diff --git a/alib/.project b/alib/.project new file mode 100644 index 0000000000000000000000000000000000000000..bdd01a8bcd38400abb60b5bf8fd65a3d8211fcd8 --- /dev/null +++ b/alib/.project @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>alib</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.codan.core.codanBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + <nature>org.eclipse.cdt.codan.core.codanNature</nature> + </natures> +</projectDescription> diff --git a/alib/.settings/language.settings.xml b/alib/.settings/language.settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..4186e525b4590432cb6088fe9c50d6e9b3b52fc4 --- /dev/null +++ b/alib/.settings/language.settings.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<project> + <configuration id="cdt.managedbuild.config.gnu.so.debug.768984509" name="Debug"> + <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> + <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/> + </extension> + </configuration> + <configuration id="cdt.managedbuild.config.gnu.so.release.337532063" name="Release"> + <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> + <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/> + <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/> + </extension> + </configuration> +</project> diff --git a/alib/.settings/org.eclipse.cdt.codan.core.prefs b/alib/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..4b525170528437142fe3c4d8895239c2aa2871d4 --- /dev/null +++ b/alib/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,68 @@ +eclipse.preferences.version=1 +onBuild=true +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} diff --git a/alib/src/AlibException.cpp b/alib/src/AlibException.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8817a168770312a2016ddd098143e0f940fa2368 --- /dev/null +++ b/alib/src/AlibException.cpp @@ -0,0 +1,16 @@ +/* + * AlibException.cpp + * + * Created on: Apr 1, 2013 + * Author: martin + */ + +#include "AlibException.h" + +namespace automaton { + +AlibException::~AlibException() throw (){ + +} + +} /* namespace automaton */ diff --git a/alib/src/AlibException.h b/alib/src/AlibException.h new file mode 100644 index 0000000000000000000000000000000000000000..21d96ab59dd6944cd4df027ce3555626da90b001 --- /dev/null +++ b/alib/src/AlibException.h @@ -0,0 +1,23 @@ +/* + * AlibException.h + * + * Created on: Apr 1, 2013 + * Author: martin + */ + +#ifndef ALIBEXCEPTION_H_ +#define ALIBEXCEPTION_H_ + +#include <exception> +#include <string> + +namespace automaton { + +class AlibException: public std::exception { +public: + virtual std::string toString() const = 0; + virtual ~AlibException() throw(); +}; + +} /* namespace automaton */ +#endif /* ALIBEXCEPTION_H_ */ diff --git a/alib/src/AutomatonFactory.cpp b/alib/src/AutomatonFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dada3bdf19fa7f2950116b5f260048cdfaabe092 --- /dev/null +++ b/alib/src/AutomatonFactory.cpp @@ -0,0 +1,46 @@ +/* + * AutomatonFactory.cpp + * + * Created on: Apr 23, 2013 + * Author: martin + */ + +#include "AutomatonFactory.h" + +#include "sax/Token.h" + +namespace automaton { + +using namespace sax; + +Automaton* AutomatonFactory::fromFile(const std::string& filename) { + std::list<Token> tokens; + SaxInterface::parseFile(filename, tokens); + return parse(tokens); +} + +Automaton* AutomatonFactory::fromString(const std::string& str) { + std::list<Token> tokens; + SaxInterface::parseMemory(str, tokens); + return parse(tokens); +} + +Automaton* AutomatonFactory::parse(std::list<sax::Token> tokens) { + if(tokens.front().getData() == "FSM") { + FSM* fsm = new FSM(); + ParserFSM::parse(tokens, *fsm); + return fsm; + } else if(tokens.front().getData() == "PDA") { + PDA* pda = new PDA(); + ParserPDA::parse(tokens, *pda); + return pda; + } else if(tokens.front().getData() == "TM") { + TM* tm = new TM(); + ParserTM::parse(tokens, *tm); + return tm; + } else { + return 0; + } +} + +} /* namespace automaton */ diff --git a/alib/src/AutomatonFactory.h b/alib/src/AutomatonFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..ec803108d8a2d4748ca19ce220efa81697bcb633 --- /dev/null +++ b/alib/src/AutomatonFactory.h @@ -0,0 +1,31 @@ +/* + * AutomatonFactory.h + * + * Created on: Apr 23, 2013 + * Author: martin + */ + +#ifndef AUTOMATONFACTORY_H_ +#define AUTOMATONFACTORY_H_ + +#include <string> +#include "sax/Token.h" +#include "automaton/Automaton.h" +#include "automaton/FSM/ParserFSM.h" +#include "automaton/PDA/ParserPDA.h" +#include "automaton/TM/ParserTM.h" + +namespace automaton { + +class AutomatonFactory { +public: + static Automaton* fromFile(const std::string& filename); + static Automaton* fromString(const std::string& str); + +protected: + static Automaton* parse(std::list<sax::Token> tokens); +}; + +} /* namespace automaton */ +#endif /* AUTOMATONFACTORY_H_ */ + diff --git a/alib/src/automaton/Automaton.cpp b/alib/src/automaton/Automaton.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9c12c57df9264d457a4f6944c3076f0ba05754e9 --- /dev/null +++ b/alib/src/automaton/Automaton.cpp @@ -0,0 +1,72 @@ +/* + * Automaton.cpp + * + * Created on: Apr 16, 2013 + * Author: martin + */ + +#include "Automaton.h" + +#include <set> +#include "exception/AutomatonException.h" + +namespace automaton { + +Automaton::~Automaton() { + +} + +void Automaton::addState(const State& state) { + std::pair<std::set<State>::iterator, bool> ret = states.insert(state); + if (!ret.second) + throw AutomatonException("State \"" + state.getName() + "\" already exists."); +} + +const std::set<State>& Automaton::getStates() const { + return states; +} + +void Automaton::addInputSymbol(const Symbol& symbol) { + std::pair<std::set<Symbol>::iterator, bool> ret = inputAlphabet.insert(symbol); + if (!ret.second) + throw AutomatonException("Input symbol \"" + symbol.getSymbol() + "\" already exists."); +} + +const std::set<Symbol>& Automaton::getInputAlphabet() const { + return inputAlphabet; +} + +void Automaton::addInitialState(const State& state) { + std::pair<std::set<State>::iterator, bool> ret = initialStates.insert(state); + if (!ret.second) + throw AutomatonException("State \"" + state.getName() + "\" is already initial state."); +} + +void Automaton::removeInitialState(const State& state) { + int removed = initialStates.erase(state); + if (!removed) + throw AutomatonException("State \"" + state.getName() + "\" isn't initial state."); + +} + +const std::set<State>& Automaton::getInitialStates() const { + return initialStates; +} + +void Automaton::addFinalState(const State& state) { + std::pair<std::set<State>::iterator, bool> ret = finalStates.insert(state); + if (!ret.second) + throw AutomatonException("State \"" + state.getName() + "\" is already final state."); +} + +void Automaton::removeFinalState(const State& state) { + int removed = finalStates.erase(state); + if (!removed) + throw AutomatonException("State \"" + state.getName() + "\" isn't final state."); +} + +const std::set<State>& Automaton::getFinalStates() const { + return finalStates; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/Automaton.h b/alib/src/automaton/Automaton.h new file mode 100644 index 0000000000000000000000000000000000000000..8413151d2fed0de3036fc3932e021ccf2f4825f4 --- /dev/null +++ b/alib/src/automaton/Automaton.h @@ -0,0 +1,47 @@ +/* + * Automaton.h + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#ifndef AUTOMATON_H_ +#define AUTOMATON_H_ + +#include <ostream> +#include <set> +#include "State.h" +#include "Symbol.h" + +namespace automaton { + +class Automaton { +protected: + std::set<State> states; + std::set<Symbol> inputAlphabet; + std::set<State> initialStates; + std::set<State> finalStates; +public: + virtual ~Automaton(); + + void addState(const State& state); + virtual void removeState(const State& state) = 0; + const std::set<State>& getStates() const; + + virtual void addInputSymbol(const Symbol& symbol); + virtual void removeInputSymbol(const Symbol& symbol) = 0; + const std::set<Symbol>& getInputAlphabet() const; + + void addInitialState(const State& state); + void removeInitialState(const State& state); + const std::set<State>& getInitialStates() const; + + void addFinalState(const State& state); + void removeFinalState(const State& state); + const std::set<State>& getFinalStates() const; + + virtual void toXML(std::ostream& out) const = 0; +}; + +} /* namespace automaton */ +#endif /* AUTOMATON_H_ */ diff --git a/alib/src/automaton/FSM/FSM.cpp b/alib/src/automaton/FSM/FSM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b177726f3e48262d193a477468bf8ec29cb401a3 --- /dev/null +++ b/alib/src/automaton/FSM/FSM.cpp @@ -0,0 +1,113 @@ +/* + * FSM.cpp + * + * Created on: Mar 25, 2013 + * Author: martin + */ + +#include "FSM.h" +#include "../exception/AutomatonException.h" +#include <ostream> + +namespace automaton { + +using namespace std; + +FSM::~FSM() { + +} + +void FSM::removeState(const State& state) { + for (set<TransitionFSM>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { + if (state == t->getCurrent() || state == t->getNext()) + throw AutomatonException("State \"" + state.getName() + "\" is used."); + } + + int removed = states.erase(state); + if (!removed) + throw AutomatonException("State \"" + state.getName() + "\" doesn't exist."); +} +void FSM::removeInputSymbol(const Symbol& symbol) { + for (set<TransitionFSM>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { + if (symbol == t->getInput()) + throw AutomatonException("Input symbol \"" + symbol.getSymbol() + "\" is used."); + } + + int removed = inputAlphabet.erase(symbol); + if (!removed) + throw AutomatonException("Input symbol \"" + symbol.getSymbol() + "\" doesn't exist."); + +} +void FSM::addTransition(const State& current, const Symbol& input, const State& next) { + if (states.find(current) == states.end()) + throw AutomatonException("State \"" + current.getName() + "\" doesn't exist."); + + if (input.getSymbol() != "") { + set<Symbol>::const_iterator input_a = inputAlphabet.find(input); + if (input_a == inputAlphabet.end()) + throw AutomatonException("Input symbol \"" + input.getSymbol() + "\" doesn't exist."); + } + + set<State>::const_iterator next_a = states.find(next); + if (next_a == states.end()) + throw AutomatonException("State \"" + next.getName() + "\" doesn't exist."); + + pair<set<TransitionFSM>::iterator, bool> ret = transitions.insert(TransitionFSM(current, input, next)); + if (!ret.second) + throw AutomatonException( + "Transition (\"" + current.getName() + "\", \"" + input.getSymbol() + "\") -> \"" + next.getName() + + "\" already exists."); +} + +void FSM::addTransition(const TransitionFSM& transition) { + addTransition(transition.getCurrent(), transition.getInput(), transition.getNext()); +} + +void FSM::removeTransition(const TransitionFSM& transition) { + int removed = transitions.erase(transition); + if (!removed) + throw AutomatonException( + "Transition (\"" + transition.getCurrent().getName() + "\", \"" + transition.getInput().getSymbol() + + "\") -> \"" + transition.getNext().getName() + "\" doesn't exist."); + +} + +const set<TransitionFSM>& FSM::getTransitions() const { + return transitions; +} + +void FSM::toXML(ostream& out) const { + out << "<FSM>\n"; + out << "\t<states>\n"; + for (set<State>::const_iterator st = states.begin(); st != states.end(); st++) { + st->toXML(out, "\t\t"); + } + out << "\t</states>\n"; + + out << "\t<inputAlphabet>\n"; + for (set<Symbol>::const_iterator alpha = inputAlphabet.begin(); alpha != inputAlphabet.end(); alpha++) { + alpha->toXML(out, "\t\t"); + } + out << "\t</inputAlphabet>\n"; + + out << "\t<transitions>\n"; + for (set<TransitionFSM>::const_iterator tr = transitions.begin(); tr != transitions.end(); tr++) { + tr->toXML(out, "\t\t"); + } + out << "\t</transitions>\n"; + + out << "\t<initialStates>\n"; + for (set<State>::const_iterator ist = initialStates.begin(); ist != initialStates.end(); ist++) { + ist->toXML(out, "\t\t"); + } + out << "\t</initialStates>\n"; + + out << "\t<finalStates>\n"; + for (set<State>::const_iterator fst = finalStates.begin(); fst != finalStates.end(); fst++) { + fst->toXML(out, "\t\t"); + } + out << "\t</finalStates>\n"; + out << "</FSM>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/FSM/FSM.h b/alib/src/automaton/FSM/FSM.h new file mode 100644 index 0000000000000000000000000000000000000000..a8541f8aad3b28345f0a82e4844d020880a28392 --- /dev/null +++ b/alib/src/automaton/FSM/FSM.h @@ -0,0 +1,36 @@ +/* + * FSM.h + * + * Created on: Mar 25, 2013 + * Author: martin + */ + +#ifndef FSM_H_ +#define FSM_H_ + +#include <set> +#include "../Automaton.h" +#include "../State.h" +#include "../Symbol.h" +#include "TransitionFSM.h" + +namespace automaton { + +class FSM: public Automaton { +protected: + std::set<TransitionFSM> transitions; +public: + ~FSM(); + + void addTransition(const State& current, const Symbol& input, const State& next); + void addTransition(const TransitionFSM& transition); + void removeTransition(const TransitionFSM& transition); + const std::set<TransitionFSM>& getTransitions() const; + + virtual void removeState(const State& state); + virtual void removeInputSymbol(const Symbol& symbol); + virtual void toXML(std::ostream& out) const; +}; + +} /* namespace automaton */ +#endif /* FSM_H_ */ diff --git a/alib/src/automaton/FSM/ParserFSM.cpp b/alib/src/automaton/FSM/ParserFSM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a1d8bcd6c44a011b3ff9bad01f97702bca8f7646 --- /dev/null +++ b/alib/src/automaton/FSM/ParserFSM.cpp @@ -0,0 +1,77 @@ +/* + * ParseAutomaton.cpp + * + * Created on: 9.8.2012 + * Author: martin + */ + +#include "ParserFSM.h" +#include "TransitionFSM.h" +#include "../Symbol.h" +#include "../../sax/ParserException.h" + +#include <exception> + +namespace automaton { + +using namespace sax; + +void ParserFSM::parse(std::list<Token> &in, automaton::FSM &automaton) { + popToken(in, Token::START_ELEMENT, "FSM"); + states(in, automaton); + inputAlphabet(in, automaton); + transitions(in, automaton); + initialStates(in, automaton); + finalStates(in, automaton); + popToken(in, Token::END_ELEMENT, "FSM"); + +} + +void ParserFSM::transitions(std::list<Token> &in, automaton::FSM &automaton) { + popToken(in, Token::START_ELEMENT, "transitions"); + while (isToken(in, Token::START_ELEMENT, "transition")) { + automaton.addTransition(parseTransition(in)); + } + popToken(in, Token::END_ELEMENT, "transitions"); +} + +TransitionFSM ParserFSM::parseTransition(std::list<Token> &in) { + std::string from, symbol, to; + + in.pop_front(); + popToken(in, Token::START_ELEMENT, "current"); + if (in.front().getType() == Token::CHARACTER) { + from = in.front().getData(); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } + popToken(in, Token::END_ELEMENT, "current"); + + popToken(in, Token::START_ELEMENT, "input"); + if (in.front().getType() == Token::CHARACTER) { + symbol = in.front().getData(); + in.pop_front(); + } else if (in.front().getType() == Token::START_ELEMENT) { + popToken(in, Token::START_ELEMENT, "eps"); + popToken(in, Token::END_ELEMENT, "eps"); + symbol = ""; + } else { + symbol = ""; + } + + popToken(in, Token::END_ELEMENT, "input"); + + popToken(in, Token::START_ELEMENT, "next"); + if (in.front().getType() == Token::CHARACTER) { + to = in.front().getData(); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } + popToken(in, Token::END_ELEMENT, "next"); + popToken(in, Token::END_ELEMENT, "transition"); + + return TransitionFSM(from, symbol, to); +} +} /* namespace automaton */ diff --git a/alib/src/automaton/FSM/ParserFSM.h b/alib/src/automaton/FSM/ParserFSM.h new file mode 100644 index 0000000000000000000000000000000000000000..4accb13df133d1c4d1c37ca99255bf24e5c76754 --- /dev/null +++ b/alib/src/automaton/FSM/ParserFSM.h @@ -0,0 +1,26 @@ +/* + * ParseAutomaton.h + * + * Created on: 9.8.2012 + * Author: martin + */ + +#ifndef PARSEAUTOMATON_H_ +#define PARSEAUTOMATON_H_ + +#include <list> +#include "../Parser.h" +#include "FSM.h" +#include "../../sax/SaxInterface.h" + +namespace automaton { +class ParserFSM : public Parser{ +public: + static void parse(std::list<sax::Token> &input, automaton::FSM &automaton); +protected: + static void transitions(std::list<sax::Token> &in, automaton::FSM &automaton); + static TransitionFSM parseTransition(std::list<sax::Token> &in); +}; + +} /* namespace automaton */ +#endif /* PARSEAUTOMATON_H_ */ diff --git a/alib/src/automaton/FSM/TransitionFSM.cpp b/alib/src/automaton/FSM/TransitionFSM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dd356d6918ac1727838f1edbadacb77f41fa1421 --- /dev/null +++ b/alib/src/automaton/FSM/TransitionFSM.cpp @@ -0,0 +1,43 @@ +/* + * TransitionFSM.cpp + * + * Created on: Mar 26, 2013 + * Author: martin + */ + +#include "TransitionFSM.h" + +namespace automaton { +TransitionFSM::TransitionFSM(const State& current,const Symbol& input,const State& next) : Transition(current, input, next) { +} + +bool TransitionFSM::operator < (const TransitionFSM& other) const { + if(current != other.current) { + return current < other.current; + } else if(input != other.input) { + return input < other.input; + } else { + return next < other.next; + } +} + +bool TransitionFSM::operator == (const TransitionFSM& other) const { + return current == other.current && input == other.input && next == other.next; +} +bool TransitionFSM::operator != (const TransitionFSM& other) const { + return current != other.current || input != other.input || next != other.next; +} + +void TransitionFSM::toXML(std::ostream& out, const std::string& indent) const { + out << indent << "<transition>\n"; + out << indent << "\t" << "<current>" << current.getName() << "</current>\n"; + if(input.getSymbol() == "") { + out << indent << "\t" << "<input>" << "<eps/>" << "</input>\n"; + } else { + out << indent << "\t" << "<input>" << input.getSymbol() << "</input>\n"; + } + out << indent << "\t" << "<next>" << next.getName() << "</next>\n"; + out << indent << "</transition>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/FSM/TransitionFSM.h b/alib/src/automaton/FSM/TransitionFSM.h new file mode 100644 index 0000000000000000000000000000000000000000..33bbb33956bbd8bbafd8fa03b38e9016ae347f2f --- /dev/null +++ b/alib/src/automaton/FSM/TransitionFSM.h @@ -0,0 +1,27 @@ +/* + * TransitionFSM.h + * + * Created on: Mar 26, 2013 + * Author: martin + */ + +#ifndef TRANSITIONFSM_H_ +#define TRANSITIONFSM_H_ + +#include "../Transition.h" +#include <ostream> + +namespace automaton { + +class TransitionFSM : public Transition { +public: + TransitionFSM(const State& current,const Symbol& input,const State& next); + bool operator <(const TransitionFSM& other) const; + bool operator ==(const TransitionFSM& other) const; + bool operator !=(const TransitionFSM& other) const; + + void toXML(std::ostream& out, const std::string& indent) const; +}; + +} /* namespace automaton */ +#endif /* TRANSITIONFSM_H_ */ diff --git a/alib/src/automaton/PDA/PDA.cpp b/alib/src/automaton/PDA/PDA.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6dd0e5bd36cd8e5d4084e4c73d9cda72bc8b9cd1 --- /dev/null +++ b/alib/src/automaton/PDA/PDA.cpp @@ -0,0 +1,179 @@ +/* + * PDA.cpp + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#include "PDA.h" +#include "../exception/AutomatonException.h" + +#include <algorithm> + +namespace automaton { + +using namespace std; + +PDA::PDA() { + +} + +void PDA::removeState(const State& state) { + for (set<TransitionPDA>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { + if (state == t->getCurrent() || state == t->getNext()) + throw AutomatonException("State \"" + state.getName() + "\" is used."); + } + + int removed = states.erase(state); + if (!removed) + throw AutomatonException("State \"" + state.getName() + "\" doesn't exist."); + +} +void PDA::removeInputSymbol(const Symbol& symbol) { + + for (set<TransitionPDA>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { + if (symbol == t->getInput()) + throw AutomatonException("Symbol \"" + symbol.getSymbol() + "\" is used."); + } + int removed = inputAlphabet.erase(symbol); + if (!removed) + throw AutomatonException("Symbol \"" + symbol.getSymbol() + "\" doesn't exist."); +} + +void PDA::addStackSymbol(const Symbol& symbol) { + pair<set<Symbol>::iterator, bool> ret = stackAlphabet.insert(symbol); + if (!ret.second) + throw AutomatonException("Stack symbol \"" + symbol.getSymbol() + "\" already exists."); +} +void PDA::removeStackSymbol(const Symbol& symbol) { + for (set<TransitionPDA>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { + for (list<Symbol>::const_iterator pop_it = t->getPop().begin(); pop_it != t->getPop().end(); pop_it++) { + if (symbol == (*pop_it)) + throw AutomatonException("Stack symbol \"" + symbol.getSymbol() + "\" is used."); + } + for (list<Symbol>::const_iterator push_it = t->getPush().begin(); push_it != t->getPush().end(); push_it++) { + if (symbol == (*push_it)) + throw AutomatonException("Stack symbol \"" + symbol.getSymbol() + "\" is used."); + } + } + + int removed = stackAlphabet.erase(symbol); + if (!removed) + throw AutomatonException("Stack symbol \"" + symbol.getSymbol() + "\" doesn't exist."); + +} +const set<Symbol>& PDA::getStackAlphabet() const { + return stackAlphabet; +} +void PDA::addTransition(const TransitionPDA& transition) { + if (states.find(transition.getCurrent()) == states.end()) { + //TODO throw exception - state doesn't exists + throw AutomatonException(""); + } + + if (transition.getInput().getSymbol().compare("") != 0) { + if (inputAlphabet.find(transition.getInput()) == inputAlphabet.end()) { + //TODO throw exception - inputSymbol doesn't exists + throw AutomatonException(""); + } + } + + if (states.find(transition.getNext()) == states.end()) { + //TODO throw exception - state doesn't exists + throw AutomatonException(""); + } + + list<Symbol>::const_iterator pop_it = transition.getPop().begin(); + while (pop_it != transition.getPop().end()) { + if (stackAlphabet.find(*pop_it) == stackAlphabet.end()) { + //TODO throw exception - stack symbol doesn't exists + throw AutomatonException(""); + } + pop_it++; + } + + list<Symbol>::const_iterator push_it = transition.getPush().begin(); + while (push_it != transition.getPush().end()) { + if (stackAlphabet.find(*push_it) == stackAlphabet.end()) { + //TODO throw exception - stack symbol doesn't exists + throw AutomatonException(""); + } + push_it++; + } + + pair<set<TransitionPDA>::iterator, bool> ret = transitions.insert(transition); + if (!ret.second) { + //TODO throw exception - transition already exists + throw AutomatonException(""); + } +} +void PDA::removeTransition(const TransitionPDA& transition) { + int removed = transitions.erase(transition); + if (!removed) { + //TODO throw exception - transition doesn't exists + throw AutomatonException(""); + } +} +const set<TransitionPDA>& PDA::getTransitions() const { + return transitions; +} +void PDA::setStartSymbols(const list<Symbol>& start) { + list<Symbol>::const_iterator symbols = start.begin(); + while (symbols != start.end()) { + if (stackAlphabet.find(*symbols) == stackAlphabet.end()) { + //TODO throw exception - stack symbol doesn't exists + throw AutomatonException(""); + } + symbols++; + } +} +const list<Symbol>& PDA::getStartSymbols() const { + return startSymbols; +} +void PDA::toXML(ostream& out) const { + out << "<PDA>\n"; + out << "\t<states>\n"; + for (set<State>::const_iterator st = states.begin(); st != states.end(); st++) { + st->toXML(out, "\t\t"); + } + out << "\t</states>\n"; + + out << "\t<inputAlphabet>\n"; + for (set<Symbol>::const_iterator alpha = inputAlphabet.begin(); alpha != inputAlphabet.end(); alpha++) { + alpha->toXML(out, "\t\t"); + } + out << "\t</inputAlphabet>\n"; + + out << "\t<stackAlphabet>\n"; + for (set<Symbol>::const_iterator alpha = stackAlphabet.begin(); alpha != stackAlphabet.end(); alpha++) { + alpha->toXML(out, "\t\t"); + } + out << "\t</stackAlphabet>\n"; + + out << "\t<transitions>\n"; + for (set<TransitionPDA>::const_iterator tr = transitions.begin(); tr != transitions.end(); tr++) { + tr->toXML(out, "\t\t"); + } + out << "\t</transitions>\n"; + + out << "\t<initialStates>\n"; + for (set<State>::const_iterator ist = initialStates.begin(); ist != initialStates.end(); ist++) { + ist->toXML(out, "\t\t"); + } + out << "\t</initialStates>\n"; + + out << "\t<startSymbols>\n"; + for (list<Symbol>::const_iterator ss = startSymbols.begin(); ss != startSymbols.end(); ss++) { + ss->toXML(out, "\t\t"); + } + out << "\t</startSymbols>\n"; + + out << "\t<finalStates>\n"; + for (set<State>::const_iterator fst = finalStates.begin(); fst != finalStates.end(); fst++) { + fst->toXML(out, "\t\t"); + } + out << "\t</finalStates>\n"; + out << "</PDA>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/PDA/PDA.h b/alib/src/automaton/PDA/PDA.h new file mode 100644 index 0000000000000000000000000000000000000000..6eb993bf7b9552bfec21cd17734e3f0172e4fdcc --- /dev/null +++ b/alib/src/automaton/PDA/PDA.h @@ -0,0 +1,46 @@ +/* + * PDA.h + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#ifndef PDA_H_ +#define PDA_H_ + +#include <set> +#include <list> +#include "../Automaton.h" +#include "../State.h" +#include "../Symbol.h" +#include "TransitionPDA.h" + +namespace automaton { + +class PDA: public Automaton { +protected: + std::set<Symbol> stackAlphabet; + std::set<TransitionPDA> transitions; + std::list<Symbol> startSymbols; +public: + PDA(); + + void addStackSymbol(const Symbol& symbol); + void removeStackSymbol(const Symbol& symbol); + const std::set<Symbol>& getStackAlphabet() const; + + void addTransition(const TransitionPDA& transition); + void removeTransition(const TransitionPDA& transition); + const std::set<TransitionPDA>& getTransitions() const; + + void setStartSymbols(const std::list<Symbol>& start); + const std::list<Symbol>& getStartSymbols() const; + + + virtual void removeState(const State& state); + virtual void removeInputSymbol(const Symbol& symbol); + void toXML(std::ostream& out) const; +}; + +} /* namespace automaton */ +#endif /* PDA_H_ */ diff --git a/alib/src/automaton/PDA/ParserPDA.cpp b/alib/src/automaton/PDA/ParserPDA.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1257b576251be55d024c804ef8f3bb2e2d04fdb5 --- /dev/null +++ b/alib/src/automaton/PDA/ParserPDA.cpp @@ -0,0 +1,116 @@ +/* + * ParserPDA.cpp + * + * Created on: Apr 23, 2013 + * Author: martin + */ + +#include "ParserPDA.h" +#include "../../sax/ParserException.h" + +namespace automaton { + +using namespace std; +using namespace sax; + +void ParserPDA::parse(list<Token> &in, PDA& automaton) { + popToken(in, Token::START_ELEMENT, "PDA"); + states(in, automaton); + inputAlphabet(in, automaton); + stackAlphabet(in, automaton); + transitions(in, automaton); + initialStates(in, automaton); + startSymbols(in, automaton); + finalStates(in, automaton); + popToken(in, Token::END_ELEMENT, "PDA"); +} +void ParserPDA::transitions(std::list<sax::Token> &in, automaton::PDA &automaton) { + popToken(in, Token::START_ELEMENT, "transitions"); + while(isToken(in, Token::START_ELEMENT, "transition")){ + automaton.addTransition(parseTransition(in)); + } + popToken(in, Token::END_ELEMENT, "transitions"); + +} +void ParserPDA::stackAlphabet(std::list<sax::Token> &in, automaton::PDA &automaton) { + popToken(in, Token::START_ELEMENT, "stackAlphabet"); + + while (isToken(in, Token::START_ELEMENT, "symbol")) { + automaton.addStackSymbol(parseSymbol(in)); + } + popToken(in, Token::END_ELEMENT, "stackAlphabet"); + +} +void ParserPDA::startSymbols(std::list<sax::Token> &in, automaton::PDA &automaton) { + popToken(in, Token::START_ELEMENT, "startSymbols"); + list<Symbol> startSymbols; + while (isToken(in, Token::START_ELEMENT, "symbol")) { + startSymbols.push_back(parseSymbol(in)); + } + automaton.setStartSymbols(startSymbols); + popToken(in, Token::END_ELEMENT, "startSymbols"); +} + +TransitionPDA ParserPDA::parseTransition(std::list<sax::Token> &in) { + std::string from, symbol, to; + + in.pop_front(); + popToken(in, Token::START_ELEMENT, "current"); + if (in.front().getType() == Token::CHARACTER) { + from = in.front().getData(); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER),in.front()); + } + popToken(in, Token::END_ELEMENT, "current"); + + popToken(in, Token::START_ELEMENT, "input"); + if (in.front().getType() == Token::CHARACTER) { + symbol = in.front().getData(); + in.pop_front(); + } else if (in.front().getType() == Token::START_ELEMENT) { + popToken(in, Token::START_ELEMENT, "eps"); + popToken(in, Token::END_ELEMENT, "eps"); + symbol = ""; + } else { + symbol = ""; + } + + popToken(in, Token::END_ELEMENT, "input"); + + popToken(in, Token::START_ELEMENT, "next"); + if (in.front().getType() == Token::CHARACTER) { + to = in.front().getData(); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER),in.front()); + } + popToken(in, Token::END_ELEMENT, "next"); + + list<Symbol> pop; + //Pop + if(isToken(in,Token::START_ELEMENT, "pop")) { + in.pop_front(); + + while(isToken(in,Token::START_ELEMENT, "symbol")){ + pop.push_back(parseSymbol(in)); + } + popToken(in, Token::END_ELEMENT, "pop"); + } + + list<Symbol> push; + //Push + if(isToken(in,Token::START_ELEMENT, "push")) { + in.pop_front(); + + while(isToken(in,Token::START_ELEMENT, "symbol")){ + push.push_back(parseSymbol(in)); + } + popToken(in, Token::END_ELEMENT, "push"); + } + + popToken(in, Token::END_ELEMENT, "transition"); + return TransitionPDA(State(from),Symbol(symbol),State(to),pop, push); +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/PDA/ParserPDA.h b/alib/src/automaton/PDA/ParserPDA.h new file mode 100644 index 0000000000000000000000000000000000000000..adde2dec52fdff8ceeaf09c9a8622ce6d9217429 --- /dev/null +++ b/alib/src/automaton/PDA/ParserPDA.h @@ -0,0 +1,30 @@ +/* + * ParserPDA.h + * + * Created on: Apr 23, 2013 + * Author: martin + */ + +#ifndef PARSERPDA_H_ +#define PARSERPDA_H_ + +#include <list> +#include "../Parser.h" +#include "PDA.h" +#include "../../sax/Token.h" + +namespace automaton { + +class ParserPDA : public Parser { + public: + static void parse(std::list<sax::Token> &input, automaton::PDA& automaton); + protected: + static void transitions(std::list<sax::Token> &in, automaton::PDA &automaton); + static void stackAlphabet(std::list<sax::Token> &in, automaton::PDA &automaton); + static void startSymbols(std::list<sax::Token> &in, automaton::PDA &automaton); + + static TransitionPDA parseTransition(std::list<sax::Token> &in); +}; + +} /* namespace automaton */ +#endif /* PARSERPDA_H_ */ diff --git a/alib/src/automaton/PDA/TransitionPDA.cpp b/alib/src/automaton/PDA/TransitionPDA.cpp new file mode 100644 index 0000000000000000000000000000000000000000..595e66439296a9d1d3e57069df99fcde507aa9dc --- /dev/null +++ b/alib/src/automaton/PDA/TransitionPDA.cpp @@ -0,0 +1,147 @@ +/* + * TransitionPDA.cpp + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#include "TransitionPDA.h" + +namespace automaton { + +TransitionPDA::TransitionPDA(const State& current, const Symbol& input, const State& next, const std::list<Symbol>& pop, + const std::list<Symbol>& push) : + Transition(current, input, next), pop(pop), push(push) { + +} + +void TransitionPDA::setPop(const std::list<Symbol>& pop) { + this->pop = pop; +} + +const std::list<Symbol>& TransitionPDA::getPop() const { + return pop; +} + +void TransitionPDA::setPush(const std::list<Symbol>& push) { + this->push = push; +} + +const std::list<Symbol>& TransitionPDA::getPush() const { + return push; +} + +bool TransitionPDA::operator <(const TransitionPDA& other) const { + if (current != other.current) { + return current < other.current; + } else if (input != other.input) { + return input < other.input; + } else if (next != next) { + return next < other.next; + } + + std::list<Symbol>::const_iterator it; + std::list<Symbol>::const_iterator it2; + + //compare pop size + if (pop.size() != other.pop.size()) + return pop.size() < other.pop.size(); + + //compare pop content + it = pop.begin(); + it2 = other.pop.begin(); + while (it != pop.end()) { + if ((*it) != (*it2)) + return (*it) < (*it2); + it++; + it2++; + } + + //compare push size + if (push.size() != other.push.size()) + return push.size() < other.push.size(); + + //compare push content + it = push.begin(); + it2 = other.push.begin(); + while (it != push.end()) { + if ((*it) != (*it2)) + return (*it) < (*it2); + it++; + it2++; + } + + return false; +} + +bool TransitionPDA::operator ==(const TransitionPDA& other) const { + if (current == other.current && input == other.input && next == other.next) { + + //compare pop size + if (pop.size() != other.pop.size()) + return false; + //compare push size + if (push.size() != other.push.size()) + return false; + + std::list<Symbol>::const_iterator it; + std::list<Symbol>::const_iterator it2; + + //compare pop content + it = pop.begin(); + it2 = other.pop.begin(); + while (it != pop.end()) { + if ((*it) != (*it2)) + return false; + it++; + it2++; + } + + //compare push content + it = push.begin(); + it2 = other.push.begin(); + while (it != push.end()) { + if ((*it) != (*it2)) + return false; + it++; + it2++; + } + return true; + } else { + return false; + } +} + +bool TransitionPDA::operator !=(const TransitionPDA& other) const { + return !((*this) == other); +} + +void TransitionPDA::toXML(std::ostream& out, const std::string& indent) const { + out << indent << "<transition>\n"; + out << indent << "\t" << "<current>" << current.getName() << "</current>\n"; + if (input.getSymbol() == "") { + out << indent << "\t" << "<input>" << "<eps/>" << "</input>\n"; + } else { + out << indent << "\t" << "<input>" << input.getSymbol() << "</input>\n"; + } + out << indent << "\t" << "<next>" << next.getName() << "</next>\n"; + + out << indent << "\t" << "<pop>\n"; + std::list<Symbol>::const_iterator it = pop.begin(); + while (it != pop.end()) { + (*it).toXML(out, indent + "\t\t"); + it++; + } + out << indent << "\t" << "</pop>\n"; + + out << indent << "\t" << "<push>\n"; + it = push.begin(); + while (it != push.end()) { + (*it).toXML(out, indent + "\t\t"); + it++; + } + out << indent << "\t" << "</push>\n"; + out << indent << "</transition>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/PDA/TransitionPDA.h b/alib/src/automaton/PDA/TransitionPDA.h new file mode 100644 index 0000000000000000000000000000000000000000..5a7e27ee5aa97cc690c0e7d14e46c52c7cb0e424 --- /dev/null +++ b/alib/src/automaton/PDA/TransitionPDA.h @@ -0,0 +1,37 @@ +/* + * TransitionPDA.h + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#ifndef TRANSITIONPDA_H_ +#define TRANSITIONPDA_H_ + +#include "../Transition.h" +#include <list> +namespace automaton { + +class TransitionPDA: public Transition { +protected: + std::list<Symbol> pop; + std::list<Symbol> push; + +public: + TransitionPDA(const State& current, const Symbol& input, const State& next, const std::list<Symbol>& pop, + const std::list<Symbol>& push); + + void setPop(const std::list<Symbol>& pop); + const std::list<Symbol>& getPop() const; + void setPush(const std::list<Symbol>& push); + const std::list<Symbol>& getPush() const; + + bool operator <(const TransitionPDA& other) const; + bool operator ==(const TransitionPDA& other) const; + bool operator !=(const TransitionPDA& other) const; + + void toXML(std::ostream& out, const std::string& indent) const; +}; + +} /* namespace automaton */ +#endif /* TRANSITIONPDA_H_ */ diff --git a/alib/src/automaton/Parser.cpp b/alib/src/automaton/Parser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c0fc8e93bd41f0fd8da4c63257e1058645e83308 --- /dev/null +++ b/alib/src/automaton/Parser.cpp @@ -0,0 +1,94 @@ +/* + * Parser.cpp + * + * Created on: Apr 23, 2013 + * Author: martin + */ + +#include "Parser.h" + +#include "../sax/ParserException.h" + +namespace automaton { +using namespace sax; + +bool Parser::isToken(std::list<Token>& input, Token::TokenType type, std::string data) { + return input.front().getType() == type && input.front().getData() == data; +} + +void Parser::popToken(std::list<Token>& input, Token::TokenType type, std::string data) { + if (isToken(input, type, data)) { + input.pop_front(); + } else { + throw sax::ParserException(sax::Token(data, type), input.front()); + } +} + +State Parser::parseState(std::list<sax::Token> &in) { + //pop <State> + in.pop_front(); + + if (in.front().getType() == Token::CHARACTER) { + State st(in.front().getData()); + in.pop_front(); + popToken(in, Token::END_ELEMENT, "state"); + return st; + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } +} + +Symbol Parser::parseSymbol(std::list<sax::Token> &in) { + //pop <Symbol> + in.pop_front(); + + if (in.front().getType() == Token::CHARACTER) { + Symbol symbol(in.front().getData()); + in.pop_front(); + popToken(in, Token::END_ELEMENT, "symbol"); + return symbol; + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } +} + +void Parser::states(std::list<Token>& in, automaton::Automaton& automaton) { + popToken(in, Token::START_ELEMENT, "states"); + + while (isToken(in, Token::START_ELEMENT, "state")) { + automaton.addState(parseState(in)); + } + + popToken(in, Token::END_ELEMENT, "states"); +} + +void Parser::inputAlphabet(std::list<Token> &in, automaton::Automaton &automaton) { + + popToken(in, Token::START_ELEMENT, "inputAlphabet"); + + while (isToken(in, Token::START_ELEMENT, "symbol")) { + automaton.addInputSymbol(parseSymbol(in)); + } + + popToken(in, Token::END_ELEMENT, "inputAlphabet"); +} + +void Parser::initialStates(std::list<Token> &in, automaton::Automaton &automaton) { + popToken(in, Token::START_ELEMENT, "initialStates"); + + while (isToken(in, Token::START_ELEMENT, "state")) { + automaton.addInitialState(parseState(in)); + } + + popToken(in, Token::END_ELEMENT, "initialStates"); +} + +void Parser::finalStates(std::list<Token> &in, automaton::Automaton &automaton) { + popToken(in, Token::START_ELEMENT, "finalStates"); + while (isToken(in, Token::START_ELEMENT, "state")) { + automaton.addFinalState(parseState(in)); + } + popToken(in, Token::END_ELEMENT, "finalStates"); +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/Parser.h b/alib/src/automaton/Parser.h new file mode 100644 index 0000000000000000000000000000000000000000..2339b9c9fd3199175d08cd8a1041994c19395a10 --- /dev/null +++ b/alib/src/automaton/Parser.h @@ -0,0 +1,32 @@ +/* + * Parser.h + * + * Created on: Apr 23, 2013 + * Author: martin + */ + +#ifndef PARSER_H_ +#define PARSER_H_ + +#include <list> +#include "Automaton.h" +#include "../sax/Token.h" + +namespace automaton { + +class Parser { +protected: + bool static isToken(std::list<sax::Token> &in, sax::Token::TokenType type, std::string data); + void static popToken(std::list<sax::Token> &in, sax::Token::TokenType type, std::string data); + + static State parseState(std::list<sax::Token> &in); + static Symbol parseSymbol(std::list<sax::Token> &in); + + void static states(std::list<sax::Token> &in, automaton::Automaton &automaton); + void static inputAlphabet(std::list<sax::Token> &in, automaton::Automaton &automaton); + void static initialStates(std::list<sax::Token> &in, automaton::Automaton &automaton); + void static finalStates(std::list<sax::Token> &in, automaton::Automaton &automaton); +}; + +} /* namespace automaton */ +#endif /* PARSER_H_ */ diff --git a/alib/src/automaton/State.cpp b/alib/src/automaton/State.cpp new file mode 100644 index 0000000000000000000000000000000000000000..520f5c3e0cfd3fff12dde39b962cec20d14a32cb --- /dev/null +++ b/alib/src/automaton/State.cpp @@ -0,0 +1,35 @@ +/* + * State.cpp + * + * Created on: Mar 26, 2013 + * Author: martin + */ + +#include "State.h" + +namespace automaton { + +State::State(const std::string& name) { + this->name = name; +} + +const std::string& State::getName() const { + return name; +} + +bool State::operator < (const State& other) const { + return name < other.name; +} + +bool State::operator == (const State& other) const { + return name == other.name; +} +bool State::operator != (const State& other) const{ + return name != other.name; +} + +void State::toXML(std::ostream& out, const std::string& indent) const { + out << indent << "<state>" << name << "</state>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/State.h b/alib/src/automaton/State.h new file mode 100644 index 0000000000000000000000000000000000000000..4828c5fbcfaa64625d30ddf9264503acd49301de --- /dev/null +++ b/alib/src/automaton/State.h @@ -0,0 +1,31 @@ +/* + * StateFSM.h + * + * Created on: Mar 26, 2013 + * Author: martin + */ + +#ifndef STATEFSM_H_ +#define STATEFSM_H_ + +#include <string> +#include <ostream> + +namespace automaton { + +class State { +private: + std::string name; +public: + State(const std::string& name); + const std::string& getName() const; + + bool operator < (const State& other) const; + bool operator == (const State& other) const; + bool operator != (const State& other) const; + + void toXML(std::ostream& out, const std::string& indent) const; +}; + +} /* namespace automaton */ +#endif /* STATEFSM_H_ */ diff --git a/alib/src/automaton/Symbol.cpp b/alib/src/automaton/Symbol.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a631a4ee7e4df83c5ec1c3fe8e976006d6a5ac57 --- /dev/null +++ b/alib/src/automaton/Symbol.cpp @@ -0,0 +1,35 @@ +/* + * Symbol.cpp + * + * Created on: Mar 26, 2013 + * Author: martin + */ + +#include "Symbol.h" + +namespace automaton { + +Symbol::Symbol(const std::string& symbol) { + this->symbol = symbol; +} + +const std::string& Symbol::getSymbol() const { + return symbol; +} + +bool Symbol::operator < (const Symbol& other) const { + return symbol < other.symbol; +} + +bool Symbol::operator == (const Symbol& other) const { + return symbol == other.symbol; +} +bool Symbol::operator != (const Symbol& other) const { + return symbol != other.symbol; +} + +void Symbol::toXML(std::ostream& out, const std::string& indent) const { + out << indent << "<symbol>" << symbol << "</symbol>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/Symbol.h b/alib/src/automaton/Symbol.h new file mode 100644 index 0000000000000000000000000000000000000000..ec4b93052dd7e8d161b91f0e13fc6b3efc196a03 --- /dev/null +++ b/alib/src/automaton/Symbol.h @@ -0,0 +1,31 @@ +/* + * Symbol.h + * + * Created on: Mar 26, 2013 + * Author: martin + */ + +#ifndef SYMBOL_H_ +#define SYMBOL_H_ + +#include <string> +#include <ostream> + +namespace automaton { + +class Symbol { +protected: + std::string symbol; +public: + Symbol(const std::string& symbol); + const std::string& getSymbol() const; + + bool operator <(const Symbol& other) const; + bool operator ==(const Symbol& other) const; + bool operator !=(const Symbol& other) const; + + void toXML(std::ostream& out, const std::string& indent) const; + +}; +} +#endif /* SYMBOL_H_ */ diff --git a/alib/src/automaton/TM/ParserTM.cpp b/alib/src/automaton/TM/ParserTM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b9dbb445404c3675bb10edbe9ac4f463889259dc --- /dev/null +++ b/alib/src/automaton/TM/ParserTM.cpp @@ -0,0 +1,123 @@ +/* + * ParserTM.cpp + * + * Created on: Apr 24, 2013 + * Author: martin + */ + +#include "ParserTM.h" +#include "../../sax/Token.h" +#include "../../sax/ParserException.h" + +namespace automaton { + +using namespace std; +using namespace sax; + +void ParserTM::parse(list<Token> &in, TM& automaton) { + popToken(in, Token::START_ELEMENT, "TM"); + states(in, automaton); + tapeAlphabet(in, automaton); + inputAlphabet(in, automaton); + transitions(in, automaton); + initialStates(in, automaton); + blankSymbol(in, automaton); + finalStates(in, automaton); + popToken(in, Token::END_ELEMENT, "TM"); +} + +void ParserTM::tapeAlphabet(std::list<sax::Token> &in, automaton::TM& automaton) { + popToken(in, Token::START_ELEMENT, "tapeAlphabet"); + + while (isToken(in, Token::START_ELEMENT, "symbol")) { + automaton.addTapeSymbol(parseSymbol(in)); + } + popToken(in, Token::END_ELEMENT, "tapeAlphabet"); + +} + +void ParserTM::transitions(std::list<sax::Token> &in, automaton::TM& automaton) { + popToken(in, Token::START_ELEMENT, "transitions"); + while (isToken(in, Token::START_ELEMENT, "transition")) { + automaton.addTransition(parseTransition(in)); + } + popToken(in, Token::END_ELEMENT, "transitions"); + +} + +void ParserTM::blankSymbol(std::list<sax::Token> &in, automaton::TM& automaton) { + popToken(in, Token::START_ELEMENT, "blankSymbol"); + if (in.front().getType() == Token::CHARACTER) { + automaton.setBlankSymbol(Symbol(in.front().getData())); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } + popToken(in, Token::END_ELEMENT, "blankSymbol"); +} + +TransitionTM ParserTM::parseTransition(std::list<sax::Token> &in) { + std::string from, symbol, to, out; + + in.pop_front(); + popToken(in, Token::START_ELEMENT, "current"); + if (in.front().getType() == Token::CHARACTER) { + from = in.front().getData(); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } + popToken(in, Token::END_ELEMENT, "current"); + + popToken(in, Token::START_ELEMENT, "input"); + if (in.front().getType() == Token::CHARACTER) { + symbol = in.front().getData(); + in.pop_front(); + } else if (in.front().getType() == Token::START_ELEMENT) { + popToken(in, Token::START_ELEMENT, "eps"); + popToken(in, Token::END_ELEMENT, "eps"); + symbol = ""; + } else { + symbol = ""; + } + + popToken(in, Token::END_ELEMENT, "input"); + + popToken(in, Token::START_ELEMENT, "next"); + if (in.front().getType() == Token::CHARACTER) { + to = in.front().getData(); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } + popToken(in, Token::END_ELEMENT, "next"); + + popToken(in, Token::START_ELEMENT, "output"); + if (in.front().getType() == Token::CHARACTER) { + out = in.front().getData(); + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } + popToken(in, Token::END_ELEMENT, "output"); + + TransitionTM::Shift shift; + popToken(in, Token::START_ELEMENT, "shift"); + if (in.front().getType() == Token::CHARACTER) { + if (in.front().getData() == "left") + shift = TransitionTM::LEFT; + if (in.front().getData() == "right") + shift = TransitionTM::RIGHT; + if (in.front().getData() == "none") + shift = TransitionTM::NONE; + in.pop_front(); + } else { + throw sax::ParserException(sax::Token("", sax::Token::CHARACTER), in.front()); + } + popToken(in, Token::END_ELEMENT, "shift"); + + popToken(in, Token::END_ELEMENT, "transition"); + return TransitionTM(State(from), Symbol(symbol), State(to), Symbol(out), shift); +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/TM/ParserTM.h b/alib/src/automaton/TM/ParserTM.h new file mode 100644 index 0000000000000000000000000000000000000000..61e3be733fa2e403450b2b89649dddd1c72a8297 --- /dev/null +++ b/alib/src/automaton/TM/ParserTM.h @@ -0,0 +1,27 @@ +/* + * ParserTM.h + * + * Created on: Apr 24, 2013 + * Author: martin + */ + +#ifndef PARSERTM_H_ +#define PARSERTM_H_ + +#include "../Parser.h" +#include "TM.h" + +namespace automaton { + +class ParserTM: public Parser { +public: + static void parse(std::list<sax::Token> &input, automaton::TM& automaton); + static void tapeAlphabet(std::list<sax::Token> &in, automaton::TM& automaton); + static void transitions(std::list<sax::Token> &in, automaton::TM& automaton); + static void blankSymbol(std::list<sax::Token> &in, automaton::TM& automaton); + + static TransitionTM parseTransition(std::list<sax::Token> &in); +}; + +} /* namespace automaton */ +#endif /* PARSERTM_H_ */ diff --git a/alib/src/automaton/TM/TM.cpp b/alib/src/automaton/TM/TM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d616af2406f5acec316d64c8fec692bb76c21ca5 --- /dev/null +++ b/alib/src/automaton/TM/TM.cpp @@ -0,0 +1,173 @@ +/* + * TM.cpp + * + * Created on: Apr 24, 2013 + * Author: martin + */ + +#include "TM.h" +#include "../exception/AutomatonException.h" + +namespace automaton { +using namespace std; +TM::TM() : + blankSymbol(Symbol("")) { + +} + +void TM::addTapeSymbol(const Symbol& symbol) { + pair<set<Symbol>::iterator, bool> ret = tapeAlphabet.insert(symbol); + if (!ret.second) + throw AutomatonException("Tape symbol \"" + symbol.getSymbol() + "\" already exists."); +} +void TM::removeTapeSymbol(const Symbol& symbol) { + for (set<Symbol>::const_iterator it = inputAlphabet.begin(); it != inputAlphabet.end(); it++) { + if (symbol == (*it)) { + throw AutomatonException("Tape symbol \"" + symbol.getSymbol() + "\" is used."); + } + } + + for (set<TransitionTM>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { + if (symbol == t->getInput() || symbol == t->getOutput()) + throw AutomatonException("Tape symbol \"" + symbol.getSymbol() + "\" is used."); + } + + int removed = inputAlphabet.erase(symbol); + if (!removed) + throw AutomatonException("Tape symbol \"" + symbol.getSymbol() + "\" doesn't exist."); + +} +const std::set<Symbol>& TM::getTapeSymbols() const { + return tapeAlphabet; +} + +void TM::addTransition(const TransitionTM& transition) { + if (states.find(transition.getCurrent()) == states.end()) { + //TODO throw exception - state doesn't exists + throw AutomatonException(""); + } + + if (transition.getInput().getSymbol().compare("") != 0) { + if (tapeAlphabet.find(transition.getInput()) == tapeAlphabet.end()) { + //TODO throw exception - inputSymbol doesn't exists + throw AutomatonException(""); + } + } + + if (states.find(transition.getNext()) == states.end()) { + //TODO throw exception - state doesn't exists + throw AutomatonException(""); + } + + if (transition.getInput().getSymbol().compare("") != 0) { + if (tapeAlphabet.find(transition.getInput()) == tapeAlphabet.end()) { + //TODO throw exception - inputSymbol doesn't exists + throw AutomatonException(""); + } + } + + pair<set<TransitionTM>::iterator, bool> ret = transitions.insert(transition); + if (!ret.second) { + //TODO throw exception - transition already exists + throw AutomatonException(""); + } + +} +void TM::removeTransition(const TransitionTM& transition) { + int removed = transitions.erase(transition); + if (!removed) { + //TODO throw exception - transition doesn't exists + throw AutomatonException(""); + } +} +const std::set<TransitionTM>& TM::getTransitions() const { + return transitions; +} + +void TM::setBlankSymbol(const Symbol& symbol) { + for (set<Symbol>::const_iterator it = inputAlphabet.begin(); it != inputAlphabet.end(); it++) { + if (symbol == (*it)) { + throw AutomatonException("Blank symbol \"" + symbol.getSymbol() + "\" cannot be in inputAlphabet."); + } + } + + if (tapeAlphabet.find(symbol) == tapeAlphabet.end()) + throw AutomatonException("Blank symbol \"" + symbol.getSymbol() + "\" must be in tapeAlphabet."); + + blankSymbol = symbol; + +} +const Symbol& TM::getBlankSymbol() const { + return blankSymbol; +} + +void TM::addInputSymbol(const Symbol& symbol) { + if (tapeAlphabet.find(symbol) == tapeAlphabet.end()) + throw AutomatonException("Input symbol \"" + symbol.getSymbol() + "\" must be in tapeAlphabet."); + if (symbol == blankSymbol) { + throw AutomatonException("Input symbol \"" + symbol.getSymbol() + "\" cannot be blank."); + } + + std::pair<std::set<Symbol>::iterator, bool> ret = inputAlphabet.insert(symbol); + if (!ret.second) + throw AutomatonException("Input symbol \"" + symbol.getSymbol() + "\" already exists."); +} + +void TM::removeState(const State& state) { + for (set<TransitionTM>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { + if (state == t->getCurrent() || state == t->getNext()) + throw AutomatonException("State \"" + state.getName() + "\" is used."); + } + + int removed = states.erase(state); + if (!removed) + throw AutomatonException("State \"" + state.getName() + "\" doesn't exist."); +} +void TM::removeInputSymbol(const Symbol& symbol) { + int removed = inputAlphabet.erase(symbol); + if (!removed) + throw AutomatonException("InputSymbol \"" + symbol.getSymbol() + "\" doesn't exist."); +} +void TM::toXML(std::ostream& out) const { + out << "<TM>\n"; + out << "\t<states>\n"; + for (set<State>::const_iterator st = states.begin(); st != states.end(); st++) { + st->toXML(out, "\t\t"); + } + out << "\t</states>\n"; + + out << "\t<tapeAlphabet>\n"; + for (set<Symbol>::const_iterator alpha = tapeAlphabet.begin(); alpha != tapeAlphabet.end(); alpha++) { + alpha->toXML(out, "\t\t"); + } + out << "\t</tapeAlphabet>\n"; + + out << "\t<inputAlphabet>\n"; + for (set<Symbol>::const_iterator alpha = inputAlphabet.begin(); alpha != inputAlphabet.end(); alpha++) { + alpha->toXML(out, "\t\t"); + } + out << "\t</inputAlphabet>\n"; + + out << "\t<transitions>\n"; + for (set<TransitionTM>::const_iterator tr = transitions.begin(); tr != transitions.end(); tr++) { + tr->toXML(out, "\t\t"); + } + out << "\t</transitions>\n"; + + out << "\t<initialStates>\n"; + for (set<State>::const_iterator ist = initialStates.begin(); ist != initialStates.end(); ist++) { + ist->toXML(out, "\t\t"); + } + out << "\t</initialStates>\n"; + + out << "\t<blankSymbol>" << blankSymbol.getSymbol() << "</blankSymbol>\n"; + + out << "\t<finalStates>\n"; + for (set<State>::const_iterator fst = finalStates.begin(); fst != finalStates.end(); fst++) { + fst->toXML(out, "\t\t"); + } + out << "\t</finalStates>\n"; + out << "</TM>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/TM/TM.h b/alib/src/automaton/TM/TM.h new file mode 100644 index 0000000000000000000000000000000000000000..23bf4a7739a21840bdde3cd5327c1d7d8d31d791 --- /dev/null +++ b/alib/src/automaton/TM/TM.h @@ -0,0 +1,43 @@ +/* + * TM.h + * + * Created on: Apr 24, 2013 + * Author: martin + */ + +#ifndef TM_H_ +#define TM_H_ + +#include "../Automaton.h" +#include "TransitionTM.h" + +namespace automaton { + +class TM: public automaton::Automaton { +protected: + std::set<Symbol> tapeAlphabet; + std::set<TransitionTM> transitions; + Symbol blankSymbol; + +public: + TM(); + + void addTapeSymbol(const Symbol& symbol ); + void removeTapeSymbol(const Symbol& symbol); + const std::set<Symbol>& getTapeSymbols() const ; + + void addTransition(const TransitionTM& transition); + void removeTransition(const TransitionTM& transition); + const std::set<TransitionTM>& getTransitions() const; + + void setBlankSymbol(const Symbol& symbol); + const Symbol& getBlankSymbol() const; + + virtual void addInputSymbol(const Symbol& symbol); + virtual void removeState(const State& state); + virtual void removeInputSymbol(const Symbol& symbol); + virtual void toXML(std::ostream& out) const; +}; + +} /* namespace automaton */ +#endif /* TM_H_ */ diff --git a/alib/src/automaton/TM/TransitionTM.cpp b/alib/src/automaton/TM/TransitionTM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8ca7404ff4622a46a645aafacda673d3b04af466 --- /dev/null +++ b/alib/src/automaton/TM/TransitionTM.cpp @@ -0,0 +1,66 @@ +/* + * TransitionTM.cpp + * + * Created on: Apr 24, 2013 + * Author: martin + */ + +#include "TransitionTM.h" + +namespace automaton { + +TransitionTM::TransitionTM(const State& current, const Symbol& input, const State& next, const Symbol& output, + Shift shift) : + Transition(current, input, next), output(output), shift(shift) { +} + +const Symbol& TransitionTM::getOutput() const { + return output; +} +void TransitionTM::setOutput(const Symbol& output) { + this->output = output; +} +TransitionTM::Shift TransitionTM::getShift() const { + return shift; +} +void TransitionTM::setShift(Shift shift) { + this->shift = shift; +} + +bool TransitionTM::operator <(const TransitionTM& other) const { + if (current != other.current) { + return current < other.current; + } else if (input != other.input) { + return input < other.input; + } else if (next != next) { + return next < other.next; + } else if (output != output) { + return output < other.output; + } else { + return shift < other.shift; + } + +} +bool TransitionTM::operator ==(const TransitionTM& other) const { + return current == other.current && input == other.input && next == other.next && output == other.output + && shift == other.shift; +} +bool TransitionTM::operator !=(const TransitionTM& other) const { + return !((*this) == other); +} + +void TransitionTM::toXML(std::ostream& out, const std::string& indent) const { + out << indent << "<transition>\n"; + out << indent << "\t" << "<current>" << current.getName() << "</current>\n"; + if (input.getSymbol() == "") { + out << indent << "\t" << "<input>" << "<eps/>" << "</input>\n"; + } else { + out << indent << "\t" << "<input>" << input.getSymbol() << "</input>\n"; + } + out << indent << "\t" << "<next>" << next.getName() << "</next>\n"; + out << indent << "\t" << "<output>" << output.getSymbol() << "</output>\n"; + out << indent << "\t" << "<shift>" << (std::string[]){"left","right","none"}[shift] << "</shift>\n"; + out << indent << "</transition>\n"; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/TM/TransitionTM.h b/alib/src/automaton/TM/TransitionTM.h new file mode 100644 index 0000000000000000000000000000000000000000..e2ffc8e642d653da147b41463e96e40469d327b6 --- /dev/null +++ b/alib/src/automaton/TM/TransitionTM.h @@ -0,0 +1,39 @@ +/* + * TransitionTM.h + * + * Created on: Apr 24, 2013 + * Author: martin + */ + +#ifndef TRANSITIONTM_H_ +#define TRANSITIONTM_H_ + +#include "../Transition.h" + +namespace automaton { + +class TransitionTM: public Transition { +public: + enum Shift { + LEFT, RIGHT, NONE + }; +protected: + Symbol output; + Shift shift; +public: + TransitionTM(const State& current, const Symbol& input, const State& next, const Symbol& output, Shift shift); + + const Symbol& getOutput() const; + void setOutput(const Symbol& output); + Shift getShift() const; + void setShift(Shift shift); + + bool operator <(const TransitionTM& other) const; + bool operator ==(const TransitionTM& other) const; + bool operator !=(const TransitionTM& other) const; + + void toXML(std::ostream& out, const std::string& indent) const; +}; + +} /* namespace automaton */ +#endif /* TRANSITIONTM_H_ */ diff --git a/alib/src/automaton/Transition.cpp b/alib/src/automaton/Transition.cpp new file mode 100644 index 0000000000000000000000000000000000000000..731e9e23ca47d3c4f3941cac122613cd54d3251d --- /dev/null +++ b/alib/src/automaton/Transition.cpp @@ -0,0 +1,41 @@ +/* + * Transition.cpp + * + * Created on: Apr 16, 2013 + * Author: martin + */ + +#include "Transition.h" + +namespace automaton { + +Transition::Transition(const State& current, const Symbol& input, const State& next) : + current(current), input(input), next(next) { + +} + +Transition::~Transition() { + +} +void Transition::setCurrent(const State& state) { + current = state; +} +const State& Transition::getCurrent() const { + return current; +} +void Transition::setInput(const Symbol& symbol) { + input = symbol; +} + +const Symbol& Transition::getInput() const { + return input; +} +void Transition::setNext(const State& state) { + next = state; +} + +const State& Transition::getNext() const { + return next; +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/Transition.h b/alib/src/automaton/Transition.h new file mode 100644 index 0000000000000000000000000000000000000000..063f7cf90a8bd83ed4dccb5329f5bd5f7813a66d --- /dev/null +++ b/alib/src/automaton/Transition.h @@ -0,0 +1,36 @@ +/* + * Transition.h + * + * Created on: Apr 16, 2013 + * Author: martin + */ + +#ifndef TRANSITION_H_ +#define TRANSITION_H_ + +#include "State.h" +#include "Symbol.h" + +namespace automaton { + +class Transition { +protected: + State current; + Symbol input; + State next; +public: + Transition(const State& current, const Symbol& input, const State& next); + virtual ~Transition(); + + void setCurrent(const State& state); + const State& getCurrent() const; + void setInput(const Symbol& symbol); + const Symbol& getInput() const; + void setNext(const State& state); + const State& getNext() const; + + virtual void toXML(std::ostream& out, const std::string& prefix) const = 0; +}; + +} /* namespace automaton */ +#endif /* TRANSITION_H_ */ diff --git a/alib/src/automaton/exception/AutomatonException.cpp b/alib/src/automaton/exception/AutomatonException.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ec4762348bb36022ad957c7d61734d18840bfa2f --- /dev/null +++ b/alib/src/automaton/exception/AutomatonException.cpp @@ -0,0 +1,25 @@ +/* + * AutomatonException.cpp + * + * Created on: Apr 1, 2013 + * Author: martin + */ + +#include "AutomatonException.h" + +namespace automaton { + +AutomatonException::AutomatonException(const std::string& cause) : + cause(cause) { + +} + +std::string AutomatonException::toString() const { + return cause; +} + +AutomatonException::~AutomatonException() throw () { + +} + +} /* namespace automaton */ diff --git a/alib/src/automaton/exception/AutomatonException.h b/alib/src/automaton/exception/AutomatonException.h new file mode 100644 index 0000000000000000000000000000000000000000..8e139f48056f54513cb1fa6118bfb2ad2dde0d73 --- /dev/null +++ b/alib/src/automaton/exception/AutomatonException.h @@ -0,0 +1,24 @@ +/* + * AutomatonException.h + * + * Created on: Apr 1, 2013 + * Author: martin + */ + +#ifndef AUTOMATONEXCEPTION_H_ +#define AUTOMATONEXCEPTION_H_ + +#include "../../AlibException.h" + +namespace automaton { + +class AutomatonException: public AlibException { + std::string cause; +public: + AutomatonException(const std::string& cause); + std::string toString() const; + virtual ~AutomatonException() throw (); +}; + +} /* namespace automaton */ +#endif /* AUTOMATONEXCEPTION_H_ */ diff --git a/alib/src/sax/ParserException.cpp b/alib/src/sax/ParserException.cpp new file mode 100644 index 0000000000000000000000000000000000000000..073491bef04565950d156d2d1de3cbd5d0aa2dd3 --- /dev/null +++ b/alib/src/sax/ParserException.cpp @@ -0,0 +1,23 @@ +/* + * ParserException.cpp + * + * Created on: Apr 16, 2013 + * Author: martin + */ + +#include "ParserException.h" + +namespace sax { + +ParserException::ParserException(const Token& expected, const Token& read) : + expected(expected), read(read) { +} +ParserException::~ParserException() throw () { + +} +std::string ParserException::toString() const { + return std::string( + "Expected: " + expected.getData() + " Read: " + read.getData()); +} + +} /* namespace sax */ diff --git a/alib/src/sax/ParserException.h b/alib/src/sax/ParserException.h new file mode 100644 index 0000000000000000000000000000000000000000..72be429a1046d8794b0027d6e38d626b5bcf03f0 --- /dev/null +++ b/alib/src/sax/ParserException.h @@ -0,0 +1,29 @@ +/* + * ParserException.h + * + * Created on: Apr 16, 2013 + * Author: martin + */ + +#ifndef PARSEREXCEPTION_H_ +#define PARSEREXCEPTION_H_ + +#include "../AlibException.h" +#include "Token.h" +#include <string.h> +namespace sax { + +class ParserException: public automaton::AlibException { +protected: + Token expected; + Token read; +public: + ParserException(const Token& expected,const Token& read); + ~ParserException() throw (); + std::string toString() const; + + +}; + +} /* namespace sax */ +#endif /* PARSEREXCEPTION_H_ */ diff --git a/alib/src/sax/SaxInterface.cpp b/alib/src/sax/SaxInterface.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7539279e89637089d1f74b121f33896db90b4e4d --- /dev/null +++ b/alib/src/sax/SaxInterface.cpp @@ -0,0 +1,73 @@ +/* + * SaxInterface.cpp + * + * Created on: 8.8.2012 + * Author: martin + */ + +#include "SaxInterface.h" + +#include <string> +#include <cstring> + +namespace sax { +void SaxInterface::initSAXHandler(xmlSAXHandler& handler) { + memset(&handler, 0, sizeof(handler)); + handler.initialized = XML_SAX2_MAGIC; + + handler.startElement = &sax::SaxInterface::startElement; + handler.characters = &sax::SaxInterface::characters; + handler.endElement = &sax::SaxInterface::endElement; +} + +void SaxInterface::parseMemory(std::string xmlIn, std::list<Token>& out) { + xmlSAXHandler handler; + initSAXHandler(handler); + + xmlSAXUserParseMemory(&handler, (void*) &out, xmlIn.c_str(), + xmlIn.length()); + + xmlCleanupParser(); +} + +void SaxInterface::parseFile(std::string filename, std::list<Token>& out) { + xmlSAXHandler handler; + initSAXHandler(handler); + + xmlSAXUserParseFile(&handler, (void*) &out, filename.c_str()); + + xmlCleanupParser(); +} + +void SaxInterface::characters(void * user_data, const xmlChar * ch, int len) { + std::list<Token> &out = *((std::list<Token>*) user_data); + std::string tmp((char*) ch, len); + + for (unsigned int i = 0; i < tmp.length(); i++) { + if (!isspace(tmp[i])) { + Token token(tmp, Token::CHARACTER); + out.push_back(token); + break; + } + } +} + +void SaxInterface::startElement(void* user_data, const xmlChar* name, + const xmlChar** attrs) { + std::list<Token> &out = *((std::list<Token>*) user_data); + out.push_back(Token ((char*) name, Token::START_ELEMENT)); + + /* if (attrs) { + while (attrs[0]) { + out.push_back(Token((char*) attrs[0], Token::ATTRIBUTE)); + out.push_back(Token((char*) attrs[1], Token::CHARACTER)); + attrs += 2; + } + }*/ +} + +void SaxInterface::endElement(void * user_data, const xmlChar * name) { + std::list<Token> &out = *((std::list<Token>*) user_data); + out.push_back(Token((char*) name, Token::END_ELEMENT)); +} +} /* namespace sax */ diff --git a/alib/src/sax/SaxInterface.h b/alib/src/sax/SaxInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..db442922d1e7bfce795f001db48d866564d57068 --- /dev/null +++ b/alib/src/sax/SaxInterface.h @@ -0,0 +1,34 @@ +/* + * SaxInterface.h + * + * Created on: 8.8.2012 + * Author: martin + */ + +#ifndef SAXINTERFACE_H_ +#define SAXINTERFACE_H_ + +#include <libxml/parser.h> +#include <list> +#include "Token.h" + +namespace sax { + +class SaxInterface { + +protected: + static void initSAXHandler(xmlSAXHandler&); + + //callbacks + static void characters(void * ctx, const xmlChar * ch, int len); + static void startElement(void *user_data, const xmlChar *name, + const xmlChar **attrs); + static void endElement(void * user_data, const xmlChar * name); + +public: + static void parseMemory(std::string, std::list<Token>&); + static void parseFile(std::string filename, std::list<Token>&); +}; + +} /* namespace sax */ +#endif /* SAXINTERFACE_H_ */ diff --git a/alib/src/sax/Token.cpp b/alib/src/sax/Token.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a0880c8a3e348e3c981c95e0194e2b690a436980 --- /dev/null +++ b/alib/src/sax/Token.cpp @@ -0,0 +1,29 @@ +/* + * ParseToken.cpp + * + * Created on: 9.8.2012 + * Author: martin + */ + +#include "Token.h" + +namespace sax { + +Token::Token(const std::string data, const Token::TokenType type) : + data(data), type(type) { + +} + +Token::~Token() { + +} + +std::string Token::getData() const { + return data; +} + +Token::TokenType Token::getType() const { + return type; +} + +} /* namespace sax */ diff --git a/alib/src/sax/Token.h b/alib/src/sax/Token.h new file mode 100644 index 0000000000000000000000000000000000000000..237865293fd2aed0b0d2d09fdcf0f7f919688d3a --- /dev/null +++ b/alib/src/sax/Token.h @@ -0,0 +1,39 @@ +/* + * ParseToken.h + * + * Created on: 9.8.2012 + * Author: martin + */ + +#ifndef PARSETOKEN_H_ +#define PARSETOKEN_H_ + +#include <string> + +namespace sax { + +class Token { +public: + + enum TokenType { + START_ELEMENT, + END_ELEMENT, + ATTRIBUTE, + CHARACTER + }; + +private: + std::string data; + TokenType type; + +public: + Token(const std::string, const TokenType); + virtual ~Token(); + + std::string getData() const; + TokenType getType() const; +}; + +} /* namespace sax */ + +#endif /* PARSETOKEN_H_ */ diff --git a/examples/FSM.xml b/examples/FSM.xml new file mode 100644 index 0000000000000000000000000000000000000000..c4d13266799b27af4f1b00e75f8b0811183262f4 --- /dev/null +++ b/examples/FSM.xml @@ -0,0 +1,60 @@ +<FSM> + <states> + <state>one</state> + <state>two</state> + <state>three</state> + <state>four</state> + </states> + <inputAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + </inputAlphabet> + <transitions> + <transition> + <current>four</current> + <input>1</input> + <next>four</next> + </transition> + <transition> + <current>four</current> + <input>0</input> + <next>one</next> + </transition> + <transition> + <current>one</current> + <input>0</input> + <next>two</next> + </transition> + <transition> + <current>one</current> + <input>1</input> + <next>one</next> + </transition> + <transition> + <current>three</current> + <input>0</input> + <next>four</next> + </transition> + <transition> + <current>three</current> + <input>1</input> + <next>three</next> + </transition> + <transition> + <current>two</current> + <input>0</input> + <next>three</next> + </transition> + <transition> + <current>two</current> + <input>1</input> + <next>two</next> + </transition> + </transitions> + <initialStates> + <state>one</state> + </initialStates> + <finalStates> + <state>one</state> + </finalStates> +</FSM> diff --git a/examples/FSM2.xml b/examples/FSM2.xml new file mode 100644 index 0000000000000000000000000000000000000000..ab53d811f6b38e2bf03303299b9d0b53e3ef445e --- /dev/null +++ b/examples/FSM2.xml @@ -0,0 +1,70 @@ +<FSM> + <states> + <state>one</state> + <state>two</state> + <state>three</state> + <state>four</state> + <state>five</state> + <state>six</state> + </states> + <inputAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + </inputAlphabet> + <transitions> + <transition> + <current>four</current> + <input>1</input> + <next>four</next> + </transition> + <transition> + <current>four</current> + <input>0</input> + <next>one</next> + </transition> + <transition> + <current>one</current> + <input>0</input> + <next>two</next> + </transition> + <transition> + <current>one</current> + <input>1</input> + <next>one</next> + </transition> + <transition> + <current>three</current> + <input>0</input> + <next>four</next> + </transition> + <transition> + <current>three</current> + <input>1</input> + <next>three</next> + </transition> + <transition> + <current>two</current> + <input>0</input> + <next>three</next> + </transition> + <transition> + <current>two</current> + <input>1</input> + <next>two</next> + </transition> + + <transition> + <current>five</current> + <input></input> + <next>six</next> + </transition> + </transitions> + <initialStates> + <state>one</state> + <state>five</state> + </initialStates> + <finalStates> + <state>one</state> + <state>six</state> + </finalStates> +</FSM> diff --git a/examples/PDA.xml b/examples/PDA.xml new file mode 100644 index 0000000000000000000000000000000000000000..38dd05a9103aae5de9d961195ab6745dbd97ea8a --- /dev/null +++ b/examples/PDA.xml @@ -0,0 +1,53 @@ +<PDA> + <states> + <state>a</state> + <state>b</state> + </states> + <inputAlphabet> + <symbol>{</symbol> + <symbol>}</symbol> + </inputAlphabet> + <stackAlphabet> + <symbol>0</symbol> + </stackAlphabet> + <transitions> + <transition> + <current>a</current> + <input>{</input> + <next>a</next> + <pop> + </pop> + <push> + <symbol>0</symbol> + </push> + </transition> + <transition> + <current>a</current> + <input>}</input> + <next>b</next> + <pop> + <symbol>0</symbol> + </pop> + <push> + </push> + </transition> + <transition> + <current>b</current> + <input>}</input> + <next>b</next> + <pop> + <symbol>0</symbol> + </pop> + <push> + </push> + </transition> + + </transitions> + <initialStates> + <state>a</state> + </initialStates> + <startSymbols> + </startSymbols> + <finalStates> + </finalStates> +</PDA> diff --git a/examples/TM.xml b/examples/TM.xml new file mode 100644 index 0000000000000000000000000000000000000000..1abfc3767eea7c1d242354c7af9ccfba35d96db0 --- /dev/null +++ b/examples/TM.xml @@ -0,0 +1,53 @@ +<TM> + <states> + <state>a1</state> + <state>a2</state> + <state>a3</state> + <state>a4</state> + </states> + <tapeAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + <symbol>B</symbol> + </tapeAlphabet> + <inputAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + </inputAlphabet> + <transitions> + <transition> + <current>a1</current> + <input>B</input> + <next>a2</next> + <output>0</output> + <shift>right</shift> + </transition> + <transition> + <current>a2</current> + <input>B</input> + <next>a3</next> + <output>B</output> + <shift>right</shift> + </transition> + <transition> + <current>a3</current> + <input>B</input> + <next>a4</next> + <output>1</output> + <shift>right</shift> + </transition> + <transition> + <current>a4</current> + <input>B</input> + <next>a1</next> + <output>B</output> + <shift>right</shift> + </transition> + </transitions> + <initialStates> + <state>a1</state> + </initialStates> + <blankSymbol>B</blankSymbol> + <finalStates> + </finalStates> +</TM> diff --git a/examples/TM2.xml b/examples/TM2.xml new file mode 100644 index 0000000000000000000000000000000000000000..d1c8ee8287bbbb14cec98081e9bd891775e4bfa0 --- /dev/null +++ b/examples/TM2.xml @@ -0,0 +1,99 @@ +<TM> + <states> + <state>q0</state> + <state>q1</state> + <state>q2</state> + <state>q3</state> + <state>q4</state> + </states> + <tapeAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + <symbol>X</symbol> + <symbol>Y</symbol> + <symbol>B</symbol> + </tapeAlphabet> + <inputAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + </inputAlphabet> + <transitions> + <transition> + <current>q0</current> + <input>0</input> + <next>q1</next> + <output>X</output> + <shift>right</shift> + </transition> + <transition> + <current>q1</current> + <input>0</input> + <next>q1</next> + <output>0</output> + <shift>right</shift> + </transition> + <transition> + <current>q1</current> + <input>Y</input> + <next>q1</next> + <output>Y</output> + <shift>right</shift> + </transition> + <transition> + <current>q1</current> + <input>1</input> + <next>q2</next> + <output>Y</output> + <shift>left</shift> + </transition> + <transition> + <current>q2</current> + <input>Y</input> + <next>q2</next> + <output>Y</output> + <shift>left</shift> + </transition> + <transition> + <current>q2</current> + <input>0</input> + <next>q2</next> + <output>0</output> + <shift>left</shift> + </transition> + <transition> + <current>q2</current> + <input>X</input> + <next>q0</next> + <output>X</output> + <shift>right</shift> + </transition> + <transition> + <current>q0</current> + <input>Y</input> + <next>q3</next> + <output>Y</output> + <shift>right</shift> + </transition> + <transition> + <current>q3</current> + <input>Y</input> + <next>q3</next> + <output>Y</output> + <shift>right</shift> + </transition> + <transition> + <current>q3</current> + <input>B</input> + <next>q4</next> + <output>B</output> + <shift>right</shift> + </transition> + </transitions> + <initialStates> + <state>q0</state> + </initialStates> + <blankSymbol>B</blankSymbol> + <finalStates> + <state>q4</state> + </finalStates> +</TM> diff --git a/examples/TM3.xml b/examples/TM3.xml new file mode 100644 index 0000000000000000000000000000000000000000..55b9a402930b9afbd6dd857633e356c740715d56 --- /dev/null +++ b/examples/TM3.xml @@ -0,0 +1,44 @@ +<TM> + <states> + <state>a1</state> + <state>a2</state> + </states> + <tapeAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + <symbol>B</symbol> + </tapeAlphabet> + <inputAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + </inputAlphabet> + <transitions> + <transition> + <current>a1</current> + <input>0</input> + <next>a2</next> + <output>0</output> + <shift>right</shift> + </transition> + <transition> + <current>a2</current> + <input>1</input> + <next>a1</next> + <output>1</output> + <shift>left</shift> + </transition> + <transition> + <current>a2</current> + <input>B</input> + <next>a2</next> + <output>1</output> + <shift>none</shift> + </transition> + </transitions> + <initialStates> + <state>a1</state> + </initialStates> + <blankSymbol>B</blankSymbol> + <finalStates> + </finalStates> +</TM>