Action.java :  » Parser » beaver » beaver » Java Open Source

Java Open Source » Parser » beaver 
beaver » beaver » Action.java
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is part of Beaver Parser Generator.                       *
 * Copyright (C) 2003,2004 Alexander Demenchuk <alder@softanvil.com>.  *
 * All rights reserved.                                                *
 * See the file "LICENSE" for the terms and conditions for copying,    *
 * distribution and modification of Beaver.                            *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

package beaver;

/**
 * An "interface" to Java code executed when a production is reduced.
 */
public abstract class Action
{
  static public final Action NONE = new Action()
  {
    public Symbol reduce(Symbol[] args, int offset)
    {
      return new Symbol(null);
    }
  };
  
  static public final Action RETURN = new Action()
  {
    public Symbol reduce(Symbol[] args, int offset)
    {
      return args[offset + 1];
    }
  };
  
  /**
   * Am action code that is executed when the production is reduced.
   *
   * @param args   an array part of which is filled with this action arguments
   * @param offset to the last element <b>BEFORE</b> the first argument of this action
   * @return a symbol or a value of a LHS nonterminal
   */
  public abstract Symbol reduce(Symbol[] args, int offset);
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.