Search in sources :

Example 31 with EmptyStackException

use of java.util.EmptyStackException in project Algorithms by wlsgussla123.

the class Main method pop.

public char pop() throws EmptyStackException {
    if (isEmpty())
        new EmptyStackException();
    char data = this.data[this.top];
    this.top--;
    return data;
}
Also used : EmptyStackException(java.util.EmptyStackException)

Example 32 with EmptyStackException

use of java.util.EmptyStackException in project Algorithms by wlsgussla123.

the class MyStack method pop.

public T pop() {
    if (top == null)
        throw new EmptyStackException();
    T data = top.data;
    top = top.next;
    return data;
}
Also used : EmptyStackException(java.util.EmptyStackException)

Example 33 with EmptyStackException

use of java.util.EmptyStackException in project linuxtools by eclipse.

the class ParseNewlibTexinfo method BuildXMLFromTexinfo2.

public static void BuildXMLFromTexinfo2(String srcdir, String builddir, BufferedWriter os, String lib) {
    try {
        srcdir = srcdir.endsWith("/") ? srcdir + lib : srcdir + "/" + lib;
        builddir = builddir.endsWith("/") ? builddir + lib : builddir + "/" + lib;
        String qFile = srcdir + "/" + lib + ".texinfo";
        try {
            BufferedReader is = new BufferedReader(new FileReader(qFile));
            String il;
            boolean ignore = false;
            while (is != null) {
                while (null != (il = is.readLine())) {
                    if (!ignore && il.startsWith("@findex")) {
                        HandleFunction(os, is, il, builddir);
                    } else if (!ignore && il.startsWith("@include")) {
                        is = HandleInclude(is, builddir, il);
                    } else if (il.startsWith("@ignore")) {
                        ignore = true;
                    } else if (il.startsWith("@end ignore")) {
                        ignore = false;
                    }
                }
                is.close();
                is = readers.pop();
            }
        } catch (IOException e) {
            System.out.println("Input File IOException: " + e);
            return;
        } catch (EmptyStackException f) {
        // ok, we expect to get here
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
        System.out.println("NullPointerException: " + e);
        return;
    }
}
Also used : EmptyStackException(java.util.EmptyStackException) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException)

Example 34 with EmptyStackException

use of java.util.EmptyStackException in project scheduling by ow2-proactive.

the class FlowChecker method dfsBlocks.

/**
 * Find matching start and end blocks in a task tree using depth first search
 *
 * @param tree task tree to search
 * @param done already treated tasks; multiple dependencies: multiple passes
 * @param env accumulates the previously read start tags
 * @param join stacks previous join targets
 * @throws FlowError
 */
private void dfsBlocks(TaskTree tree, Set<String> done, Stack<TaskTree> env, Stack<TaskTree> join) throws FlowError {
    if (tree.joins.size() > 0 && !tree.joinTrigger) {
        return;
    }
    if (tree.targetOf != null && !done.contains(tree.targetOf.element.getName())) {
        return;
    }
    FlowBlock fb = tree.element.getFlowBlock();
    String name = tree.element.getName();
    if (done.contains(name)) {
        return;
    } else {
        done.add(name);
    }
    switch(fb) {
        case START:
            // push new opening tag in the environment
            env.push(tree);
            break;
        case END:
            // close the last opened block
            TaskTree start = null;
            try {
                start = env.pop();
            } catch (EmptyStackException e) {
                throw new FlowError("Unmatched end block", FlowErrorType.BLOCK, name);
            }
            Block blk = new Block(start, tree);
            blocks.add(blk);
            break;
        case NONE:
            break;
    }
    List<TaskTree> children = new ArrayList<>();
    children.addAll(tree.children);
    if (tree.children.size() == 0) {
        if (tree.element.getFlowScript() != null && tree.element.getFlowScript().getActionType().equals(FlowActionType.IF.toString())) {
            if (tree.targetJoin != null) {
                join.add(tree.targetJoin);
            }
            for (TaskTree t : tree.targets) {
                children.add(t);
            }
        } else if (join.size() > 0) {
            TaskTree pop = join.pop();
            children.add(pop);
            pop.joinTrigger = true;
        }
    }
    // recursive call
    for (TaskTree child : children) {
        dfsBlocks(child, done, env, join);
    }
}
Also used : EmptyStackException(java.util.EmptyStackException) FlowBlock(org.ow2.proactive.scheduler.common.task.flow.FlowBlock) ArrayList(java.util.ArrayList) FlowBlock(org.ow2.proactive.scheduler.common.task.flow.FlowBlock)

Example 35 with EmptyStackException

use of java.util.EmptyStackException in project CommandHelper by EngineHub.

the class CompilerObject method popNode.

private void popNode(Target t) throws ConfigCompileException {
    try {
        nodes.pop();
        pointer = nodes.peek();
    } catch (EmptyStackException e) {
        throw new ConfigCompileException("Unmatched closing parenthesis. (Did you put too many right parenthesis?)", t);
    }
}
Also used : EmptyStackException(java.util.EmptyStackException) ConfigCompileException(com.laytonsmith.core.exceptions.ConfigCompileException)

Aggregations

EmptyStackException (java.util.EmptyStackException)47 Stack (java.util.Stack)13 Test (org.junit.Test)6 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)5 Callable (java.util.concurrent.Callable)5 NamespaceSupport (org.xml.sax.helpers.NamespaceSupport)5 ActivityImple (com.arjuna.mwlabs.wsas.activity.ActivityImple)3 IOException (java.io.IOException)3 ResourceApplicationContext (com.cloud.spring.module.context.ResourceApplicationContext)2 ConfigCompileException (com.laytonsmith.core.exceptions.ConfigCompileException)2 ArrayList (java.util.ArrayList)2 SystemException (org.omg.CORBA.SystemException)2 ApplicationContext (org.springframework.context.ApplicationContext)2 ActionControl (com.arjuna.ArjunaOTS.ActionControl)1 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)1 LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)1 TabHeader (com.jsql.view.swing.tab.TabHeader)1 FileOptions (com.laytonsmith.core.compiler.FileOptions)1 KeywordList (com.laytonsmith.core.compiler.KeywordList)1 CDecimal (com.laytonsmith.core.constructs.CDecimal)1