Extension SDK 10.1.2

oracle.javatools.parser.generic
Class Language

java.lang.Object
  extended byoracle.javatools.parser.generic.Language
All Implemented Interfaces:
GenericTokens

public abstract class Language
extends java.lang.Object
implements GenericTokens

The Language interface provides methods for providing basic details of a language, such as the keywords, the comment delimiters, and the quote delimiters of a language. This is intended to provide clients with the ability to obtain a simple lexer implementation for a language without a lot of language-specific implementation details.

Clients that require more language-specific features or details will need to implement their own custom Lexer to accommodate the unique features of a given language.

The GenericLexer implementation is a concrete Lexer that was written for this Language API, can be used to instantiate a Lexer for a given Language implementation.


Field Summary
protected  BraceHelper braceHelper
           
static java.lang.String[] EMPTY_ARRAY
          Empty String array, useful when a language feature is not available.
protected  KeywordTable keywordTable
          Stores a keyword table, containing all of the keywords of this language.
 
Fields inherited from interface oracle.javatools.parser.generic.GenericTokens
TK_CLOSE_BRACE, TK_FLOAT, TK_IDENTIFIER, TK_INTEGER, TK_KEYWORD, TK_MULTI_COMMENT, TK_OPEN_BRACE, TK_OPERATOR, TK_QUOTES, TK_SINGLE_COMMENT
 
Constructor Summary
protected Language()
          Initializes the base Language abstract implementation.
 
Method Summary
 BraceHelper getBraceHelper()
          Fetches a brace helper for this language that has useful routines for a brace matching implementation.
abstract  java.lang.String[][] getBraces()
          Fetches an array of String arrays, each of which represent a pair of matched braces.
abstract  java.lang.String[] getHexadecimals()
          Fetches an array of prefix used to start a hexadecimal integer literal if the language supports integer literals.
abstract  java.lang.String[] getKeywords()
          Fetches an array of the keywords in this language.
protected  KeywordTable getKeywordTable()
          Returns a KeywordTable for this language, based on the keywords supported, and whether the language is case-sensitive or not.
abstract  java.lang.String[][] getMultiLineComments()
          Fetches an array of String arrays, each of which represents a multi-line comment.
abstract  java.lang.String[] getOctals()
          Fetches an array of prefixes used to start an octal integer literal if the language supports integer literals.
 java.lang.String[] getOperators()
          Fetches an array of Strings, each of which represent an operator in the given language.
abstract  java.lang.String[][] getQuotes()
          Fetches an array of String arrays, each of which represents a type of quote.
abstract  java.lang.String[] getSingleLineComments()
          Fetches an array of Strings, each of which can be used to start a single-lined comment in this language.
abstract  boolean isCaseSensitive()
          Fetches whether this language (i.e., keywords) is case sensitive or not.
abstract  boolean isIdentifierCharacter(char c)
          Fetches whether the specified character can be part of an identifier (or keyword.) Consecutive sequence of characters, all of which return true for isIdentifierCharacter(), that do not match a keyword will generate a TK_IDENTIFIER token by the GenericLexer (assuming if course that those characters are not contained in a comment or string literal.)
abstract  boolean usesFloats()
          Fetches whether this language has floating point literals.
abstract  boolean usesIntegers()
          Fetches whether the language has integer literals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keywordTable

protected KeywordTable keywordTable
Stores a keyword table, containing all of the keywords of this language.


braceHelper

protected BraceHelper braceHelper

EMPTY_ARRAY

public static final java.lang.String[] EMPTY_ARRAY
Empty String array, useful when a language feature is not available.

Constructor Detail

Language

protected Language()
Initializes the base Language abstract implementation.

Method Detail

isCaseSensitive

public abstract boolean isCaseSensitive()
Fetches whether this language (i.e., keywords) is case sensitive or not. For example, Java is case-sensitive while SQL is not.

Returns:
true if the language is case-sensitive.

isIdentifierCharacter

public abstract boolean isIdentifierCharacter(char c)
Fetches whether the specified character can be part of an identifier (or keyword.) Consecutive sequence of characters, all of which return true for isIdentifierCharacter(), that do not match a keyword will generate a TK_IDENTIFIER token by the GenericLexer (assuming if course that those characters are not contained in a comment or string literal.)

Parameters:
c - the character to check
Returns:
true if the character c can be part of an identifer (or keyword

getKeywords

public abstract java.lang.String[] getKeywords()
Fetches an array of the keywords in this language.

Returns:
a String array of the keywords in this language

getKeywordTable

protected KeywordTable getKeywordTable()
Returns a KeywordTable for this language, based on the keywords supported, and whether the language is case-sensitive or not.

Returns:
a KeywordTable for this language

getSingleLineComments

public abstract java.lang.String[] getSingleLineComments()
Fetches an array of Strings, each of which can be used to start a single-lined comment in this language. Single-lined comments are automatically terminated at the end of the line.

Returns:
a String array of single line comment starters

getMultiLineComments

public abstract java.lang.String[][] getMultiLineComments()
Fetches an array of String arrays, each of which represents a multi-line comment. Each contained String array consists of a start delimiter, and an end delimiter.

Returns:
an array of String arrays to describe multi-line comments

getQuotes

public abstract java.lang.String[][] getQuotes()
Fetches an array of String arrays, each of which represents a type of quote. Each contained String array consists of a start delimiter, an end delimiter, and optionally any number of Strings that will be ignored (useful for languages with escape characters.)

Returns:
an array of String arrays to describe quotation characters

getBraces

public abstract java.lang.String[][] getBraces()
Fetches an array of String arrays, each of which represent a pair of matched braces. Each contained String array consists of a pair of open brace and close brace character, such as "{" and "}". This can be used by other components to perform brace-matching for this language.

Returns:
an array of String arrays that describe brace characters

getOperators

public java.lang.String[] getOperators()
Fetches an array of Strings, each of which represent an operator in the given language. This could be used by other components to color operators a given way in syntax highlighting. Implementations that override this should also override isOperatorCharacter().

Returns:
an array of Strings that describe the operators

usesIntegers

public abstract boolean usesIntegers()
Fetches whether the language has integer literals. Integer literals are generally defined as a consecutive sequence of numeric characters with the first character not '0' unless this language does not support octal numbers.

Returns:
true if this language has integer literals

usesFloats

public abstract boolean usesFloats()
Fetches whether this language has floating point literals. Floating point literals are generally defined (and will be recognized) as an integer part, a decimal point, a fractional part, an 'e' or 'E', and an optionally signed integer exponent.

Returns:
true if this language has floating-point literals

getOctals

public abstract java.lang.String[] getOctals()
Fetches an array of prefixes used to start an octal integer literal if the language supports integer literals. If no octal prefix is defined, simply return an empty array

Returns:
an array of prefixes used to start an octal integer

getHexadecimals

public abstract java.lang.String[] getHexadecimals()
Fetches an array of prefix used to start a hexadecimal integer literal if the language supports integer literals. If no hexadecimal prefix is defined, simply return an empty array.

Returns:
an array of prefixes used to start an hexadecimal integer

getBraceHelper

public BraceHelper getBraceHelper()
Fetches a brace helper for this language that has useful routines for a brace matching implementation.

Returns:
the brace helper for this language

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.