Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.0
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.syntax
Class Reduction

    java.lang.Object
      org.codehaus.groovy.syntax.CSTNode
          org.codehaus.groovy.syntax.Reduction

    class Reduction
    extends CSTNode

A syntax reduction, produced by the `Parser`.

see:
  Parser

see:
  Token

see:
  CSTNode

see:
  Types

author:
  bob mcwhirter

author:
  Chris Poirier

version:
  $Id: Reduction.java 7922 2007-09-04 01:42:57Z paulk $

Field Summary
`static Reduction` | `EMPTY`

Constructor Summary
`Reduction(Token root)` Initializes the `Reduction` with the specified root.
`private Reduction()` Initializes the `Reduction` to empty.

Method Summary
`CSTNode` | `add(CSTNode element)` Adds an element to the node.
`Reduction` | `asReduction()` Creates a `Reduction` from this node.
`CSTNode` | `get(int index)` Returns the specified element, or null.
`Token` | `getRoot()` Returns the root of the node, the Token that indicates it's type.
`boolean` | `isAnExpression()` Returns true if the node is a complete expression.
`boolean` | `isEmpty()` Returns true if the node is completely empty (no root, even).
`void` | `markAsExpression()` Marks the node a complete expression.
`static Reduction` | `newContainer()` Creates a new `Reduction` with `Token.NULL` as it's root.
`CSTNode` | `remove(int index)` Removes a node from the `Reduction`.
`CSTNode` | `set(int index, CSTNode element)` Sets an element in at the specified index.
`int` | `size()` Returns the number of elements in the node.

Methods inherited from class CSTNode
add, addChildrenOf, asReduction, canMean, children, get, get, getDescription, getMeaning, getMeaningAs, getRoot, getRoot, getRootText, getStartColumn, getStartLine, getType, hasChildren, isA, isAllOf, isAnExpression, isEmpty, isOneOf, markAsExpression, matches, matches, matches, matches, matches, set, setMeaning, size, toString, write, write

Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll

Field Detail

### EMPTY

    static final Reduction EMPTY

Constructor Detail

### Reduction

    public Reduction(Token root)

  Initializes the `Reduction` with the specified root.

### Reduction

    private Reduction()

  Initializes the `Reduction` to empty.

Method Detail

### add

    public CSTNode add(CSTNode element)

  Adds an element to the node.

### asReduction

    public Reduction asReduction()

  Creates a `Reduction` from this node. Returns self if the node is already a `Reduction`.

### get

    public CSTNode get(int index)

  Returns the specified element, or null.

### getRoot

    public Token getRoot()

  Returns the root of the node, the Token that indicates it's type. Returns null if there is no root (usually only if the node is a placeholder of some kind -- see isEmpty()).

### isAnExpression

    public boolean isAnExpression()

  Returns true if the node is a complete expression.

### isEmpty

    public boolean isEmpty()

  Returns true if the node is completely empty (no root, even).

### markAsExpression

    public void markAsExpression()

  Marks the node a complete expression.

### newContainer

    public static Reduction newContainer()

  Creates a new `Reduction` with `Token.NULL` as it's root.

### remove

    public CSTNode remove(int index)

  Removes a node from the `Reduction`. You cannot remove the root node (index 0).

### set

    public CSTNode set(int index, CSTNode element)

  Sets an element in at the specified index.

### size

    public int size()

  Returns the number of elements in the node.

Copyright © 2003-2009 The Codehaus. All rights reserved.