oracle.javatools.parser.generic
Class Language

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.

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.

Language

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.)

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.