All Downloads are FREE. Search and download functionalities are using the official Maven repository.

beaver.Action Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is part of Beaver Parser Generator.                       *
 * Copyright (C) 2003,2004 Alexander Demenchuk .  *
 * 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 BEFORE the first argument of this action
	 * @return a symbol or a value of a LHS nonterminal
	 */
	public abstract Symbol reduce(Symbol[] args, int offset);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy