Package abstrasy.pcfx

Source Code of abstrasy.pcfx.PCFx_restart

package abstrasy.pcfx;


import abstrasy.Interpreter;
import abstrasy.Node;

import abstrasy.interpreter.InterpreterException;
import abstrasy.interpreter.StdErrors;

/**
* Abstrasy Interpreter
*
* Copyright : Copyright (c) 2006-2012, Luc Bruninx.
*
* Concédée sous licence EUPL, version 1.1 uniquement (la «Licence»).
*
* Vous ne pouvez utiliser la présente oeuvre que conformément à la Licence.
* Vous pouvez obtenir une copie de la Licence à l’adresse suivante:
*
*   http://www.osor.eu/eupl
*
* Sauf obligation légale ou contractuelle écrite, le logiciel distribué sous
* la Licence est distribué "en l’état", SANS GARANTIES OU CONDITIONS QUELLES
* QU’ELLES SOIENT, expresses ou implicites.
*
* Consultez la Licence pour les autorisations et les restrictions
* linguistiques spécifiques relevant de la Licence.
*
*
* @author Luc Bruninx
* @version 1.0
*/

public class PCFx_restart extends PCFx {

    public PCFx_restart() {
    }


    /**
     * eval
     *
     * @param startAt Node
     * @return Node
     * @throws Exception
     * @todo Implémenter cette méthode abstrasy.PCFx
     */
    public Node eval(Node startAt) throws Exception {
        /**
         * formes: (restart)
         *         (restart {...})          -> généralement {...} est un symbole..
         *         (restart [args])
         *         (restart {...} [args])
         */
        Node xnode=null;
        Node anode=null;
       
        /**
         * il doit s'agir d'un tail-node !
         */
        Interpreter interpreter = Interpreter.mySelf();
    if (!interpreter.isTerminalNode()){
      throw new InterpreterException(StdErrors.Restart_misplaced);
    }
       
        /**
         * analyse des arguments...
         */
        switch(startAt.size()){
            case 1: /* forme (restart) */
                break;
            case 2:
                xnode=startAt.getSubNode(1, Node.TYPE_LAZY|Node.TYPE_CLIST);
                if(!xnode.isLazy()){
                    // si ce n'est pas une lazy, c'est une liste...
                    anode=xnode;
                    xnode=null;
                }
                break;
            case 3:
                xnode=startAt.getSubNode(1, Node.TYPE_LAZY);
                anode=startAt.getSubNode(2, Node.TYPE_CLIST);
                break;
            default:
                /**
                 * problème...
                 */
                throw new InterpreterException(StdErrors.Argument_count_mismatch);
        }
   
        throw interpreter.getRestartException(startAt,xnode,anode);
      
    }

}
TOP

Related Classes of abstrasy.pcfx.PCFx_restart

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.