gov.llnl.babel.parsers.sidl
Class Parser

java.lang.Object
  extended by gov.llnl.babel.parsers.sidl.Parser
All Implemented Interfaces:
ParserConstants

public class Parser
extends java.lang.Object
implements ParserConstants

The Parser class is automatically generated by the JavaCC compiler. The primary public method in the parser is beginParse, which parses the SIDL code in the input stream set in the parser constructor. The other public methods are setSourceURL, which sets the name associated with the input stream, and setMetadata, which stores metadata to be associated with symbols created from this input file.


Field Summary
 Token jj_nt
           
 boolean lookingAhead
           
 Token token
           
 ParserTokenManager token_source
           
 
Fields inherited from interface gov.llnl.babel.parsers.sidl.ParserConstants
BEGIN_DOC_COMMENT, DEFAULT, EOF, IN_DOC_COMMENT, LINE_DOC_COMMENT, T_ABSTRACT, T_ARRAY, T_ASTERISK, T_BOOLEAN, T_CATCH_ALL, T_CHAR, T_CHARACTER, T_CLASS, T_CLOSE_ANGLE, T_CLOSE_BRACE, T_CLOSE_CURLY, T_CLOSE_PAREN, T_COLON, T_COLUMN_MAJOR, T_COMMA, T_COMMENT, T_COPY, T_DCOMPLEX, T_DIGIT, T_DOUBLE, T_ELSE, T_ENSURE, T_ENUM, T_EQUALS, T_EQUIVALENT, T_EXTENDS, T_FALSE, T_FCOMPLEX, T_FINAL, T_FLOAT, T_FLOAT_LIT, T_GREATER_EQUAL, T_HYPHEN, T_IDENTIFIER, T_IF_AND_ONLY_IF, T_IMPLEMENTS, T_IMPLEMENTS_ALL, T_IMPLIES, T_IMPORT, T_IN, T_INOUT, T_INT, T_INTEGER, T_INTERFACE, T_INVARIANT, T_IS, T_LESS_EQUAL, T_LESS_GREATER, T_LETTER, T_LOCAL, T_LOGICAL_AND, T_LOGICAL_OR, T_LOGICAL_XOR, T_LONG, T_MODULUS, T_NONBLOCKING, T_NOT, T_NOT_EQUAL, T_NULL, T_ONEWAY, T_OPAQUE, T_OPEN_ANGLE, T_OPEN_BRACE, T_OPEN_CURLY, T_OPEN_PAREN, T_ORDER, T_OUT, T_PACKAGE, T_PLUS, T_POWER, T_PURE, T_RARRAY, T_REMAINDER, T_REQUIRE, T_RESULT, T_ROW_MAJOR, T_SCOPE, T_SEMICOLON, T_SHIFT_LEFT, T_SHIFT_RIGHT, T_SOLIDUS, T_STATIC, T_STRING, T_STRING_LIT, T_THEN, T_THROWS, T_TILDE, T_TRUE, T_UNSIGNED, T_VERSION, T_VERSION_STRING, T_VOID, tokenImage
 
Constructor Summary
Parser(java.io.InputStream stream)
           
Parser(java.io.InputStream stream, java.lang.String encoding)
           
Parser(ParserTokenManager tm)
           
Parser(java.io.Reader stream)
           
 
Method Summary
 void AddArguments(MethodCall mc)
          An argument expression list is a comma-separated list of conditional expressions.
 void AddInterface(Extendable ext, java.util.List implall)
          This production parses the next scoped identifier and validates that the name exists and is an interface symbol.
 void AdditiveExpr()
          An additive expression may be a unary (multiplicative) expression or binary (additive op multiplicative) expression, where op is "+" or "-".
 void addMetadata(java.lang.String key, java.lang.String value)
          Add metadata to be associated with symbols generated during the parse of this input stream.
 void AndExpr()
          A AND-expression may be a unary (equality) expression or binary (AND "and" equality) expression.
 void Argument()
          Parse a SIDL argument.
 void Array()
          Parse an array construct and push the resulting type and ordering on top of the stack.
 void AssertionExpr()
          An assertion expression may be a unary (conditional) expression or binary (conditional ("implies" | "iff") conditional) expression.
 void Assertions(Extendable ext, Method m, int type, Comment comment)
          This production parses the assertions associated with the specified type.
 java.lang.String[] beginParse()
          Begin parsing and analysis of the SIDL grammar.
 void Class()
          A SIDL class specification begins with an optional abstract keyword followed by the class token followed by an identifier.
 void ClassMethod(Class cls)
          This production parses the SIDL method description for a class method.
 void ComplexLit()
          Parse complex literal.
 void ConditionalExpr()
          A conditional expression is simply an inclusive-OR expression.
 void Definition()
          A SIDL Definition production consists of a class, interface, enumerated type, or package.
 void disable_tracing()
           
 void enable_tracing()
           
 void Enum()
          The SIDL enumeration specification begins with an "enum" token followed by an identifier.
 void Enumerator(Enumeration e)
          The SIDL enumerator specification consists of an identifier followed by an optional assignment statement beginning with an equals and followed by an integer value.
 void EqualityExpr()
          An equality expression may be a unary (relational) expression or binary (equality op relational) expression, where op is "==" or "!=".
 void ExclusiveOrExpr()
          A exclusive-OR expression may be a unary (AND) expression or binary (exclusive-OR "xor" AND) expression.
 void FloatLit()
          Parse float literal.
 ParseException generateParseException()
           
 Token getNextToken()
           
 Token getToken(int index)
           
 void Identifier()
          A SIDL identifier must start with a letter and may be followed by any number of letters, numbers, or underscores.
 void Import()
          A SIDL Import production begins with an "import" token and is followed by a scoped identifier which is optionally followed by a "version" token and a version number.
 void InclusiveOrExpr()
          A inclusive-OR expression may be a unary (exclusive-OR) expression or binary (inclusive-OR "or" exclusive-OR) expression.
 void IntegerLit()
          Parse integer literal.
 void Interface()
          A SIDL interface specification begins with the interface token followed by an identifier.
 void InterfaceMethod(Interface ifc)
          This method parses a SIDL method and then checks whether it can be added to the interface object.
 void Invariants(Extendable ext)
          This production parses the invariants associated with the interface or class.
 void LiteralExpr()
          A literal expression is a literal of type: integer, character, floating point, or string.
 void Method(Extendable ext, Method m)
          The SIDL method production has a return type, a method identifier, an optional argument list, an optional communication modifier, and an optional throws clause.
 void MultiplicativeExpr()
          A multiplicative expression may be a unary (multiplicative) expression or binary (multiplicative expression, "*" or "/" or "mod", unary) expression.
 void Package()
          The SIDL package specification begins with a "package" token followed by a scoped identifier.
 void PostfixExpr()
          A postfix expression may be a primary expression or an identifier followed by an optional argument list.
 void PowerExpr()
          A multiplicative expression may be a unary (multiplicative) expression or binary (multiplicative expression, "*" or "/" or "mod", unary) expression.
 void PrimaryExpr()
          A primary expression may be an identifier, literal, or conditional expression within parentheses.
 void Rarray()
          Parse an rarray construct and push the resulting type and ordering on top of the stack.
 void ReInit(java.io.InputStream stream)
           
 void ReInit(java.io.InputStream stream, java.lang.String encoding)
           
 void ReInit(ParserTokenManager tm)
           
 void ReInit(java.io.Reader stream)
           
 void RelationalExpr()
          An relational expression may be a unary (shift) expression or binary (relational op shift) expression, where op is ">", "<", "<=", or ">=".
 void Require()
          A SIDL Require production begins with a "require" token and is followed by a scoped identifer, a "version" token, and a version number.
 void ScopedIdentifier()
          All SIDL scoped names are of the general form "ID ( .
 void setSourceURL(java.lang.String url)
          Set the source URL name.
 void ShiftExpr()
          A shift expression may be a unary (additive) expression or binary (shift op additive) expression, where op is "<<" or ">>".
 void Specification()
          A SIDL Specification contains zero or more require productions followed by zero or more import productions followed by zero or more package productions followed by the end-of-file.
 void SymbolType()
          This production parses a scoped identifier and verifies that it is either a forward reference or a symbol that may be used as a type (either an enum, an interface, or a class).
 void Type()
          A SIDL type consists of one of the standard built-in types (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string), a user-defined type (interface, class, or enum), or an array.
 void UnaryExpr()
          A unary expression may be a postfix or prefix expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public ParserTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead
Constructor Detail

Parser

public Parser(java.io.InputStream stream)

Parser

public Parser(java.io.InputStream stream,
              java.lang.String encoding)

Parser

public Parser(java.io.Reader stream)

Parser

public Parser(ParserTokenManager tm)
Method Detail

setSourceURL

public void setSourceURL(java.lang.String url)
Set the source URL name. If the source URL is not set, then it is "file:unknown.sidl".


addMetadata

public void addMetadata(java.lang.String key,
                        java.lang.String value)
Add metadata to be associated with symbols generated during the parse of this input stream. By default, the parser creates metadata associated with the source file (keyword "source-url"), compiler version (keyword "babel-version"), and source line number of the symbol definition (keyword "source-line").


beginParse

public java.lang.String[] beginParse()
                              throws SIDLException
Begin parsing and analysis of the SIDL grammar. All of the exceptions generated during the parse are subclasses of SIDLException. The symbols generated during the parse are returned in the symbol table. Any warnings generated during the parse are returned through the string array return argument (or null if there were no warnings).

Throws:
SIDLException

Specification

public final void Specification()
                         throws ParseException,
                                SymbolException
A SIDL Specification contains zero or more require productions followed by zero or more import productions followed by zero or more package productions followed by the end-of-file. Before leaving the specification scope, resolve all references in the symbol table.

Throws:
ParseException
SymbolException

Require

public final void Require()
                   throws ParseException,
                          SymbolException
A SIDL Require production begins with a "require" token and is followed by a scoped identifer, a "version" token, and a version number. The scoped identifier must be not defined. The version number is specified in the general form "V1.V2...Vn" where Vi is a non-negative integer.

Throws:
ParseException
SymbolException

Import

public final void Import()
                  throws ParseException,
                         SymbolException
A SIDL Import production begins with an "import" token and is followed by a scoped identifier which is optionally followed by a "version" token and a version number. The scoped identifier must be defined and it must be a package. The version number is specified in the general form "V1.V2...Vn" where Vi is a non-negative integer. A particular package may only be included in one import statement. The import package name is added to the default search path. At the end of the parse, any import statements that were not used to resolve a symbol name are output as warnings.

Throws:
ParseException
SymbolException

Package

public final void Package()
                   throws ParseException,
                          SymbolException
The SIDL package specification begins with a "package" token followed by a scoped identifier. The new package namespace begins with an open curly brace, a set of zero or more definitions, and a close curly brace. The closing curly brace may be followed by an optional semicolon. The package identifier must have a version defined for it, and it must not have been previously defined as a symbol or used as a forward reference. The parent of the package must itself be a package and must have been defined. The symbols within the curly braces will be defined within the package scope.

Throws:
ParseException
SymbolException

Definition

public final void Definition()
                      throws ParseException,
                             SymbolException
A SIDL Definition production consists of a class, interface, enumerated type, or package.

Throws:
ParseException
SymbolException

Class

public final void Class()
                 throws ParseException,
                        SymbolException
A SIDL class specification begins with an optional abstract keyword followed by the class token followed by an identifier. The abstract keyword is required if and only if there are abstract methods in the class. The class keyword is followed by an identifer. The identifier string may not have been previously defined, although it may have been used as a forward reference. The identifier string may be preceeded by a documentation comment. A class may optionally extend another class; if no class is specified, then the class will automatically extend the SIDL base class (unless it is itself the SIDL base class). Then parse the implements-all and implements clauses. The interfaces parsed during implements-all are saved in a set and then all those methods are defined at the end of the class definition. The methods block begins with an open curly-brace followed by zero or more methods followed by a close curly-brace and optional semicolon.

Throws:
ParseException
SymbolException

Enum

public final void Enum()
                throws ParseException,
                       SymbolException
The SIDL enumeration specification begins with an "enum" token followed by an identifier. The enumerator list begins with an open curly brace, a set of one or more definitions, and a close curly brace. The closing curly brace may be followed by an optional semicolon. The enumeration symbol identifier must have a version defined for it, and it must not have been previously defined as a symbol. Forward references are not allowed for enumerated types. This routine creates the enumerated class and then grabs the list of enumeration symbols and their optional values.

Throws:
ParseException
SymbolException

Enumerator

public final void Enumerator(Enumeration e)
                      throws ParseException,
                             SymbolException
The SIDL enumerator specification consists of an identifier followed by an optional assignment statement beginning with an equals and followed by an integer value. This routine adds the new enumeration symbol to the list and then returns.

Throws:
ParseException
SymbolException

Interface

public final void Interface()
                     throws ParseException,
                            SymbolException
A SIDL interface specification begins with the interface token followed by an identifier. An interface may have an extends block consisting of a comma-separated sequence of interfaces. The methods block begins with an open curly-brace followed by zero or more methods followed by a close curly-brace and optional semicolon. Interfaces may be preceeded by a documentation comment. The identifier string may not have been previously defined, although it may have been used as a forward reference. If the interface does not extend another interface, then it must extend the base SIDL interface (unless, of course, this is the definition for the base SIDL interface).

Throws:
ParseException
SymbolException

AddInterface

public final void AddInterface(Extendable ext,
                               java.util.List implall)
                        throws ParseException,
                               SymbolException
This production parses the next scoped identifier and validates that the name exists and is an interface symbol. Then each of its methods are checked for validity with the existing methods. If everything checks out, then the new interface is added to the existing object.

Throws:
ParseException
SymbolException

Invariants

public final void Invariants(Extendable ext)
                      throws ParseException,
                             SymbolException
This production parses the invariants associated with the interface or class.

Throws:
ParseException
SymbolException

ClassMethod

public final void ClassMethod(Class cls)
                       throws ParseException,
                              SymbolException
This production parses the SIDL method description for a class method. A class method may start with abstract, final, or static. An error is thrown if the method has already been defined in the class object or if the method name is the same as the class name. An error is also thrown if a method has been defined in a parent class and (1) the signatures do not match, (2) either of the methods is static, (3) the existing method is final, or (4) the new method is abstract but the existing method was not abstract.

Throws:
ParseException
SymbolException

InterfaceMethod

public final void InterfaceMethod(Interface ifc)
                           throws ParseException,
                                  SymbolException
This method parses a SIDL method and then checks whether it can be added to the interface object. An error is thrown if the method has already been added to the interface object or if the method name is the same as the interface name. An error is also thrown if a previous method was defined with the same name but a different signature.

Throws:
ParseException
SymbolException

Method

public final void Method(Extendable ext,
                         Method m)
                  throws ParseException,
                         SymbolException
The SIDL method production has a return type, a method identifier, an optional argument list, an optional communication modifier, and an optional throws clause. The return type may be void (no return type) or any valid SIDL type. The method is built piece by piece.

Throws:
ParseException
SymbolException

Argument

public final void Argument()
                    throws ParseException,
                           SymbolException
Parse a SIDL argument. Arguments begin with an optional copy modifier followed by in, out, or inout followed by a type and a formal argument. The argument is returned on the top of the argument stack. This routine also checks that the copy modifier is used only for symbol objects. For all other types, copy is redundant.

Throws:
ParseException
SymbolException

Type

public final void Type()
                throws ParseException,
                       SymbolException
A SIDL type consists of one of the standard built-in types (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string), a user-defined type (interface, class, or enum), or an array. This production parses the type and pushes the resulting type object on the top of the argument stack.

Throws:
ParseException
SymbolException

Array

public final void Array()
                 throws ParseException,
                        SymbolException
Parse an array construct and push the resulting type and ordering on top of the stack. Only dimensions one through MAX_ARRAY_DIM (inclusive) are supported.

Throws:
ParseException
SymbolException

Rarray

public final void Rarray()
                  throws ParseException,
                         SymbolException
Parse an rarray construct and push the resulting type and ordering on top of the stack. Only dimensions one through MAX_ARRAY_DIM (inclusive) are supported. And don't forget the indices!

Throws:
ParseException
SymbolException

SymbolType

public final void SymbolType()
                      throws ParseException,
                             SymbolException
This production parses a scoped identifier and verifies that it is either a forward reference or a symbol that may be used as a type (either an enum, an interface, or a class).

Throws:
ParseException
SymbolException

Assertions

public final void Assertions(Extendable ext,
                             Method m,
                             int type,
                             Comment comment)
                      throws ParseException,
                             SymbolException
This production parses the assertions associated with the specified type.

Throws:
ParseException
SymbolException

AssertionExpr

public final void AssertionExpr()
                         throws ParseException,
                                SymbolException
An assertion expression may be a unary (conditional) expression or binary (conditional ("implies" | "iff") conditional) expression.

Throws:
ParseException
SymbolException

ConditionalExpr

public final void ConditionalExpr()
                           throws ParseException,
                                  SymbolException
A conditional expression is simply an inclusive-OR expression.

Throws:
ParseException
SymbolException

InclusiveOrExpr

public final void InclusiveOrExpr()
                           throws ParseException,
                                  SymbolException
A inclusive-OR expression may be a unary (exclusive-OR) expression or binary (inclusive-OR "or" exclusive-OR) expression.

Throws:
ParseException
SymbolException

ExclusiveOrExpr

public final void ExclusiveOrExpr()
                           throws ParseException,
                                  SymbolException
A exclusive-OR expression may be a unary (AND) expression or binary (exclusive-OR "xor" AND) expression.

Throws:
ParseException
SymbolException

AndExpr

public final void AndExpr()
                   throws ParseException,
                          SymbolException
A AND-expression may be a unary (equality) expression or binary (AND "and" equality) expression.

Throws:
ParseException
SymbolException

EqualityExpr

public final void EqualityExpr()
                        throws ParseException,
                               SymbolException
An equality expression may be a unary (relational) expression or binary (equality op relational) expression, where op is "==" or "!=".

Throws:
ParseException
SymbolException

RelationalExpr

public final void RelationalExpr()
                          throws ParseException,
                                 SymbolException
An relational expression may be a unary (shift) expression or binary (relational op shift) expression, where op is ">", "<", "<=", or ">=".

Throws:
ParseException
SymbolException

ShiftExpr

public final void ShiftExpr()
                     throws ParseException,
                            SymbolException
A shift expression may be a unary (additive) expression or binary (shift op additive) expression, where op is "<<" or ">>".

Throws:
ParseException
SymbolException

AdditiveExpr

public final void AdditiveExpr()
                        throws ParseException,
                               SymbolException
An additive expression may be a unary (multiplicative) expression or binary (additive op multiplicative) expression, where op is "+" or "-".

Throws:
ParseException
SymbolException

MultiplicativeExpr

public final void MultiplicativeExpr()
                              throws ParseException,
                                     SymbolException
A multiplicative expression may be a unary (multiplicative) expression or binary (multiplicative expression, "*" or "/" or "mod", unary) expression.

Throws:
ParseException
SymbolException

PowerExpr

public final void PowerExpr()
                     throws ParseException,
                            SymbolException
A multiplicative expression may be a unary (multiplicative) expression or binary (multiplicative expression, "*" or "/" or "mod", unary) expression.

Throws:
ParseException
SymbolException

UnaryExpr

public final void UnaryExpr()
                     throws ParseException,
                            SymbolException
A unary expression may be a postfix or prefix expression.

Throws:
ParseException
SymbolException

PostfixExpr

public final void PostfixExpr()
                       throws ParseException,
                              SymbolException
A postfix expression may be a primary expression or an identifier followed by an optional argument list.

Throws:
ParseException
SymbolException

PrimaryExpr

public final void PrimaryExpr()
                       throws ParseException,
                              SymbolException
A primary expression may be an identifier, literal, or conditional expression within parentheses.

Throws:
ParseException
SymbolException

LiteralExpr

public final void LiteralExpr()
                       throws ParseException,
                              SymbolException
A literal expression is a literal of type: integer, character, floating point, or string.

Throws:
ParseException
SymbolException

ComplexLit

public final void ComplexLit()
                      throws ParseException,
                             SymbolException
Parse complex literal.

Throws:
ParseException
SymbolException

FloatLit

public final void FloatLit()
                    throws ParseException,
                           SymbolException
Parse float literal.

Throws:
ParseException
SymbolException

IntegerLit

public final void IntegerLit()
                      throws ParseException,
                             SymbolException
Parse integer literal.

Throws:
ParseException
SymbolException

AddArguments

public final void AddArguments(MethodCall mc)
                        throws ParseException,
                               SymbolException
An argument expression list is a comma-separated list of conditional expressions.

Throws:
ParseException
SymbolException

ScopedIdentifier

public final void ScopedIdentifier()
                            throws ParseException,
                                   SymbolException
All SIDL scoped names are of the general form "ID ( . ID )*". Each identifier ID is a string of letters, numbers, and underscores that must begin with a letter. The scope resolution operator "." separates the identifiers in a name.

Throws:
ParseException
SymbolException

Identifier

public final void Identifier()
                      throws ParseException,
                             SymbolException
A SIDL identifier must start with a letter and may be followed by any number of letters, numbers, or underscores. It may not be a reserved word in any of the SIDL implementation languages (e.g., C or C++).

Throws:
ParseException
SymbolException

ReInit

public void ReInit(java.io.InputStream stream)

ReInit

public void ReInit(java.io.InputStream stream,
                   java.lang.String encoding)

ReInit

public void ReInit(java.io.Reader stream)

ReInit

public void ReInit(ParserTokenManager tm)

getNextToken

public final Token getNextToken()

getToken

public final Token getToken(int index)

generateParseException

public ParseException generateParseException()

enable_tracing

public final void enable_tracing()

disable_tracing

public final void disable_tracing()