ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe.parser
Interface PragmaParser

All Known Implementing Classes:
ErrorPragmaParser, EscPragmaParser

public interface PragmaParser

PragmaParser objects are called by Lex objects to parse pragmas out of pragma-containing comments. They are also called to see if a comment contains pragmas in the first place. See Lex for more details.

Pragmas are described using Token objects. The ttype field of a pragma token must be one of TagConstants.LEXICALPRAGMA, TagConstants.MODIFIERPRAGMA, TagConstants.STMTPRAGMA, or TagConstants.TYPEDECLELEMPRAGMA; the auxVal field must be filled have a type according to the table in Token.

See Also:
Token, Lex
Todo:
These methods need JML specifications.

Method Summary
 boolean checkTag(int tag)
          Decide whether a comment contains pragmas.
 void close()
          Stop parsing the current reader.
 boolean getNextPragma(Token destination)
          Parse the next pragma.
 FieldDecl isPragmaDecl(Token l)
           
 void restart(CorrelatedReader in, boolean eolComment)
          Restart a pragma parser on a new input stream.
 

Method Detail

checkTag

public boolean checkTag(int tag)
Decide whether a comment contains pragmas. When it encounters a comment, a Lex object passes the first character of the comment to the checkTag method of its PragmaParser. If this call returns false, the comment is assumed to contain no pragmas and thus is discarded. If this call returns true, the comment may contain pragmas, so it is converted into a CorrelatedReader and passed to restart. (The tag argument is either a char or -1; -1 indicates the empty comment.)


isPragmaDecl

public FieldDecl isPragmaDecl(Token l)
Todo:
Need to write documentation for this method.

restart

public void restart(CorrelatedReader in,
                    boolean eolComment)
Restart a pragma parser on a new input stream. If this already opened on another CorrelatedReader, closes the old reader.

eolComment is true to indicate that the correlated reader stream is reading from a Java comment that begins with "//" as opposed to a Java comment that begins with "/*".


getNextPragma

public boolean getNextPragma(Token destination)
Parse the next pragma. If none are left, returns false; otherwise, returns true and updates fields of destination to describe the pragma. When false is returned, the pragma parser is expected to close the underlying CorrelatedReader and in other ways clean up resources.

This method requires that the PragmaParser is "open;" that is, restart has been called and, since the last call to restart, getNextPragma has not returned false and close has not been called.


close

public void close()
Stop parsing the current reader. Sometimes a Lex object will be stopped before its associated PragmaParser has finished reading all pragmas out of a comment (for example, when Lex.restart is called). In this case, the Lex object calls PragmaParser.close. This method should close the underlying CorrelatedReader and in other ways clean up resources.


ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage