Coder Social home page Coder Social logo

jflap-lib's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jflap-lib's Issues

Bug: assertion fails when loading FSA

Whenever I load a Finite State Automaton:
FiniteStateAutomaton automaton = (FiniteStateAutomaton)new XMLCodec().decode(new File("something.jff"), null);

I get the following error:

java.lang.AssertionError
	at edu.duke.cs.jflap.file.xml.AutomatonTransducer.addBlocks(AutomatonTransducer.java:217)
	at edu.duke.cs.jflap.file.xml.AutomatonTransducer.readBlocks(AutomatonTransducer.java:483)
	at edu.duke.cs.jflap.file.xml.AutomatonTransducer.readAutomaton(AutomatonTransducer.java:411)
	at edu.duke.cs.jflap.file.xml.AutomatonTransducer.fromDOM(AutomatonTransducer.java:402)
	at edu.duke.cs.jflap.file.XMLCodec.decode(XMLCodec.java:62)
	at edu.duke.cs.jflap.file.XMLCodec.decode(XMLCodec.java:90)
	at checker.nfa.NFABuilder.generateNFA(NFABuilder.java:17)
	at checker.CheckerUtils.parseGroup(CheckerUtils.java:123)
	at checker.CheckerUtils.readSettings(CheckerUtils.java:41)
	at checker.CheckerUtils.readSettings(CheckerUtils.java:30)
	at checker.CheckerUtils.loadCheckerSettings(CheckerUtils.java:24)
	at checker.CheckerUtilsTests.setUp(CheckerUtilsTests.java:20)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

The FSA loads without problems with the assertion commented out.

Update dependency in documentation

Unfortunately, the maven dependency in the documentation doesn't work anymore. It should be:

<dependency>
    <groupId>com.github.citiususc</groupId>
    <artifactId>jflap-lib</artifactId>
    <version>1.3</version>
</dependency>

Turing Machine simulateInput always returns false

TMSimulator.simulateInput() always returns false because it is calling TMSimulator.isAccepted() to check status. However, TMSimulator.isAccepted() always returns false and even states in a comment that it only exists as a formality and is not meant to be called, as seen below.

* the machine in a final state. This method does not appear to be used. It is only left here because the class from which it inherited requires it.

TMSimulator.simulateInput():

public boolean simulateInput(String input) {
/** clear the configurations to begin new simulation. */
//System.out.println("In Simulate Input");
myConfigurations.clear();
Configuration[] initialConfigs = getInitialConfigurations(input);
for (int k = 0; k < initialConfigs.length; k++) {
TMConfiguration initialConfiguration = (TMConfiguration) initialConfigs[k];
myConfigurations.add(initialConfiguration);
}
while (!myConfigurations.isEmpty()) {
//System.out.println("HERE!!!!!");
if (isAccepted())
return true;
ArrayList configurationsToAdd = new ArrayList();
Iterator it = myConfigurations.iterator();
while (it.hasNext()) {
TMConfiguration configuration = (TMConfiguration) it.next();
ArrayList configsToAdd = stepConfiguration(configuration);
configurationsToAdd.addAll(configsToAdd);
it.remove();
}
myConfigurations.addAll(configurationsToAdd);
}
return false;
}

TMSimulator.isAccepted():
/**
* Returns true if the simulation of the input string on the automaton left
* the machine in a final state. This method does not appear to be used. It is only left here because the class from which it inherited requires it.
*
* @return true if the simulation of the input string on the automaton left
* the machine in a final state
*/
public boolean isAccepted() {
return false;
}

I believe the line if (isAccepted()) should call TMConfiguration.isAccept() instead of TMSimulator.isAccepted() to properly check if TM input is accepted or not.

TMConfiguration.isAccept()

/**
* Returns <CODE>true</CODE> if this configuration is an accepting
* configuration, based on the chosen criteria. Currently, we look at accept by halting and accept by final state.
//MERLIN MERLIN MERLIN MERLIN MERLIN//
*
* @return <CODE>true</CODE> if this configuration is accepting, <CODE>false</CODE>
* otherwise
*/
public boolean isAccept() {
for (int i = 0; i < myFilters.length; i++){
if (myFilters[i].accept(this)) return true;
}
return false;
}

org/w3c/dom/ls/DocumentLS

When I try to run the jar bundles with any FSA I always get the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
at edu.duke.cs.jflap.file.XMLCodec.decode(XMLCodec.java:59)
at edu.duke.cs.jflap.file.XMLCodec.decode(XMLCodec.java:90)
at es.usc.citius.jflap.cli.IO.loadAutomaton(IO.java:37)
at es.usc.citius.jflap.cli.CommandLine$RunInputCommand.run(CommandLine.java:79)
at es.usc.citius.jflap.cli.CommandLine$Cli.parseAndRun(CommandLine.java:136)
at es.usc.citius.jflap.cli.CommandLine.main(CommandLine.java:21)
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ls.DocumentLS
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 17 more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.