org.codehaus.groovy.syntax
Class Types

Typing information for the CST system. The types here are those used by CSTNode, Token, and Reduction.

author:
bob mcwhirter
author:
Chris Poirier
version:
$Id: Types.java 6778 2007-07-02 10:40:33Z glaforge $

Field Summary
 int ANY
           
 int ANY_END_OF_STATEMENT
           
 int ARRAY_EXPRESSION
           
 int ARRAY_ITEM_TERMINATORS
           
 int ASSIGN
           
 int ASSIGNMENT_OPERATOR
           
 int BITWISE_AND
           
 int BITWISE_AND_EQUAL
           
 int BITWISE_NEGATION
           
 int BITWISE_OPERATOR
           
 int BITWISE_OR
           
 int BITWISE_OR_EQUAL
           
 int BITWISE_XOR
           
 int BITWISE_XOR_EQUAL
           
 int COLON
           
 int COMMA
           
 int COMPARE_EQUAL
           
 int COMPARE_GREATER_THAN
           
 int COMPARE_GREATER_THAN_EQUAL
           
 int COMPARE_IDENTICAL
           
 int COMPARE_LESS_THAN
           
 int COMPARE_LESS_THAN_EQUAL
           
 int COMPARE_NOT_EQUAL
           
 int COMPARE_NOT_IDENTICAL
           
 int COMPARE_TO
           
 int COMPARISON_OPERATOR
           
 int COMPLEX_EXPRESSION
           
 int CREATABLE_PRIMITIVE_TYPE
           
 int CREATABLE_TYPE_NAME
           
 int DECIMAL_NUMBER
           
 int DECLARATION_MODIFIER
           
 int DEREFERENCE_OPERATOR
           
 Map DESCRIPTIONS
           
 int DIVIDE
           
 int DIVIDE_EQUAL
           
 int DOT
           
 int DOT_DOT
           
 int DOT_DOT_DOT
           
 int DOUBLE_PIPE
           
 int EOF
           
 int EQUAL
           
 int EQUALS
           
 int EXPRESSION
           
 int FIND_REGEX
           
 int GENERAL_END_OF_STATEMENT
           
 int GSTRING_END
           
 int GSTRING_EXPRESSION_END
           
 int GSTRING_EXPRESSION_START
           
 int GSTRING_START
           
 int IDENTIFIER
           
 int INFIX_OPERATOR
           
 int INTDIV
           
 int INTDIV_EQUAL
           
 int INTEGER_NUMBER
           
 int KEYWORD
           
 int KEYWORD_ABSTRACT
           
 int KEYWORD_AS
           
 int KEYWORD_ASSERT
           
 int KEYWORD_BOOLEAN
           
 int KEYWORD_BREAK
           
 int KEYWORD_BYTE
           
 int KEYWORD_CASE
           
 int KEYWORD_CATCH
           
 int KEYWORD_CHAR
           
 int KEYWORD_CLASS
           
 int KEYWORD_CONST
           
 int KEYWORD_CONTINUE
           
 int KEYWORD_DEF
           
 int KEYWORD_DEFAULT
           
 int KEYWORD_DEFMACRO
           
 int KEYWORD_DO
           
 int KEYWORD_DOUBLE
           
 int KEYWORD_ELSE
           
 int KEYWORD_EXPRESSION
           
 int KEYWORD_EXTENDS
           
 int KEYWORD_FALSE
           
 int KEYWORD_FINAL
           
 int KEYWORD_FINALLY
           
 int KEYWORD_FLOAT
           
 int KEYWORD_FOR
           
 int KEYWORD_GOTO
           
 int KEYWORD_IDENTIFIER
           
 int KEYWORD_IF
           
 int KEYWORD_IMPLEMENTS
           
 int KEYWORD_IMPORT
           
 int KEYWORD_IN
           
 int KEYWORD_INSTANCEOF
           
 int KEYWORD_INT
           
 int KEYWORD_INTERFACE
           
 int KEYWORD_LONG
           
 int KEYWORD_MIXIN
           
 int KEYWORD_NATIVE
           
 int KEYWORD_NEW
           
 int KEYWORD_NULL
           
 int KEYWORD_PACKAGE
           
 int KEYWORD_PRIVATE
           
 int KEYWORD_PROPERTY
           
 int KEYWORD_PROTECTED
           
 int KEYWORD_PUBLIC
           
 int KEYWORD_RETURN
           
 int KEYWORD_SHORT
           
 int KEYWORD_STATIC
           
 int KEYWORD_SUPER
           
 int KEYWORD_SWITCH
           
 int KEYWORD_SYNCHRONIZED
           
 int KEYWORD_THIS
           
 int KEYWORD_THROW
           
 int KEYWORD_THROWS
           
 int KEYWORD_TRANSIENT
           
 int KEYWORD_TRUE
           
 int KEYWORD_TRY
           
 int KEYWORD_VOID
           
 int KEYWORD_VOLATILE
           
 int KEYWORD_WHILE
           
 int LEFT_CURLY_BRACE
           
 int LEFT_OF_MATCHED_CONTAINER
           
 int LEFT_PARENTHESIS
           
 int LEFT_SHIFT
           
 int LEFT_SHIFT_EQUAL
           
 int LEFT_SQUARE_BRACKET
           
 int LITERAL
           
 int LITERAL_EXPRESSION
           
 int LOGICAL_AND
           
 int LOGICAL_AND_EQUAL
           
 int LOGICAL_OPERATOR
           
 int LOGICAL_OR
           
 int LOGICAL_OR_EQUAL
           
 Map LOOKUP
           
 int LOOP
           
 int MATCHED_CONTAINER
           
 int MATCH_REGEX
           
 int MATH_OPERATOR
           
 int METHOD_CALL_STARTERS
           
 int MINUS
           
 int MINUS_EQUAL
           
 int MINUS_MINUS
           
 int MOD
           
 int MOD_EQUAL
           
 int MULTIPLY
           
 int MULTIPLY_EQUAL
           
 int NAMED_VALUE
           
 int NAVIGATE
           
 int NEWLINE
           
 int NOT
           
 int NOT_EOF
           
 int NUMBER
           
 int OPERATOR_EXPRESSION
           
 int OPTIONAL_DATATYPE_FOLLOWERS
           
 int PARAMETER_TERMINATORS
           
 int PIPE
           
 int PLUS
           
 int PLUS_EQUAL
           
 int PLUS_PLUS
           
 int POSTFIX_MINUS_MINUS
           
 int POSTFIX_OPERATOR
           
 int POSTFIX_PLUS_PLUS
           
 int POWER
           
 int POWER_EQUAL
           
 int PRECLUDES_CAST_OPERATOR
           
 int PREFIX_MINUS
           
 int PREFIX_MINUS_MINUS
           
 int PREFIX_OPERATOR
           
 int PREFIX_OR_INFIX_OPERATOR
           
 int PREFIX_PLUS
           
 int PREFIX_PLUS_PLUS
           
 int PRIMITIVE_TYPE
           
 int PURE_PREFIX_OPERATOR
           
 int QUESTION
           
 int RANGE_OPERATOR
           
 int REGEX_COMPARISON_OPERATOR
           
 int REGEX_PATTERN
           
 int RESERVED_KEYWORD
           
 int RIGHT_CURLY_BRACE
           
 int RIGHT_OF_MATCHED_CONTAINER
           
 int RIGHT_PARENTHESIS
           
 int RIGHT_SHIFT
           
 int RIGHT_SHIFT_EQUAL
           
 int RIGHT_SHIFT_UNSIGNED
           
 int RIGHT_SHIFT_UNSIGNED_EQUAL
           
 int RIGHT_SQUARE_BRACKET
           
 int SEMICOLON
           
 int SIGN
           
 int SIMPLE_EXPRESSION
           
 int STAR
           
 int STAR_STAR
           
 int STRING
           
 int SWITCH_BLOCK_TERMINATORS
           
 int SWITCH_ENTRIES
           
 int SYMBOL
           
 int SYNTHETIC
           
 int SYNTH_BLOCK
           
 int SYNTH_CAST
           
 int SYNTH_CLASS
           
 int SYNTH_CLOSURE
           
 int SYNTH_COMPILATION_UNIT
           
 int SYNTH_EXPRESSION
           
 int SYNTH_GSTRING
           
 int SYNTH_INTERFACE
           
 int SYNTH_LABEL
           
 int SYNTH_LIST
           
 int SYNTH_MAP
           
 int SYNTH_METHOD
           
 int SYNTH_METHOD_CALL
           
 int SYNTH_MIXIN
           
 int SYNTH_PARAMETER_DECLARATION
           
 int SYNTH_PROPERTY
           
 int SYNTH_TERNARY
           
 int SYNTH_TUPLE
           
 int SYNTH_VARIABLE_DECLARATION
           
 Map TEXTS
           
 int TRUTH_VALUE
           
 int TYPE_DECLARATION
           
 int TYPE_LIST_TERMINATORS
           
 int TYPE_NAME
           
 int UNKNOWN
           
 int UNSAFE_OVER_NEWLINES
           
 
Constructor Summary
Types()
           
 
Method Summary
static void addDescription(int type, String description)
           Adds a description to the set.
static void addDescription(Integer type, String description)
           Adds a description to the set.
static void addTranslation(String text, int type)
           Adds a element to the TEXTS and LOOKUP.
static boolean canMean(int actual, int preferred)
           Given two types, returns true if the first can be viewed as the second.
static String getDescription(int type)
           Gets the description for the specified type.
static int getPrecedence(int type, boolean throwIfInvalid)
           Returns the precendence of the specified operator.
static String getText(int type)
           Returns the text for the specified type.
static int lookup(String text, int filter)
           Returns the type for the specified symbol/keyword text.
static int lookupKeyword(String text)
           Returns the type for the specified keyword text.
static int lookupSymbol(String text)
           Returns the type for the specified symbol text.
static void makePostfix(CSTNode node, boolean throwIfInvalid)
           Converts a node from a generic type to a specific postfix type.
static void makePrefix(CSTNode node, boolean throwIfInvalid)
           Converts a node from a generic type to a specific prefix type.
static boolean ofType(int specific, int general)
           Given two types, returns true if the second describes the first.
 

Constructor Detail

Types

Types()


Method Detail

addDescription

static void addDescription(int type, String description)
Adds a description to the set.


addDescription

static void addDescription(Integer type, String description)
Adds a description to the set.


addTranslation

static void addTranslation(String text, int type)
Adds a element to the TEXTS and LOOKUP.


canMean

public static boolean canMean(int actual, int preferred)
Given two types, returns true if the first can be viewed as the second. NOTE that canMean() is orthogonal to ofType().


getDescription

public static String getDescription(int type)
Gets the description for the specified type.


getPrecedence

public static int getPrecedence(int type, boolean throwIfInvalid)
Returns the precendence of the specified operator. Non-operator's will receive -1 or a GroovyBugError, depending on your preference.


getText

public static String getText(int type)
Returns the text for the specified type. Returns "" if the text isn't found.


lookup

public static int lookup(String text, int filter)
Returns the type for the specified symbol/keyword text. Returns UNKNOWN if the text isn't found. You can filter finds on a type.


lookupKeyword

public static int lookupKeyword(String text)
Returns the type for the specified keyword text. Returns UNKNOWN if the text isn't found.


lookupSymbol

public static int lookupSymbol(String text)
Returns the type for the specified symbol text. Returns UNKNOWN if the text isn't found.


makePostfix

public static void makePostfix(CSTNode node, boolean throwIfInvalid)
Converts a node from a generic type to a specific postfix type. Throws a GroovyBugError if the type can't be converted.


makePrefix

public static void makePrefix(CSTNode node, boolean throwIfInvalid)
Converts a node from a generic type to a specific prefix type. Throws a GroovyBugError if the type can't be converted and requested.


ofType

public static boolean ofType(int specific, int general)
Given two types, returns true if the second describes the first.