org.sc3d.apt.sss.v3
Class Grammar.Terminal

java.lang.Object
  extended by org.sc3d.apt.sss.v3.Grammar
      extended by org.sc3d.apt.sss.v3.Grammar.Terminal
Direct Known Subclasses:
Grammar.Keyword
Enclosing class:
Grammar

public static class Grammar.Terminal
extends Grammar

The subclass of Grammar with 'isTerminal==true'. This class and its subclasses are used to represent grammars that are terminals.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.sc3d.apt.sss.v3.Grammar
Grammar.Keyword, Grammar.NonTerminal, Grammar.Production, Grammar.Terminal
 
Field Summary
 int type
          The type of Tokens matched by this Terminal (one of the 'Token.TYPE_XXX' values).
 
Fields inherited from class org.sc3d.apt.sss.v3.Grammar
isTerminal
 
Constructor Summary
Grammar.Terminal(int type)
          Constructs a Terminal which matches a single Token of type 'type'.
 
Method Summary
 boolean accepts(Token t)
          Returns 'true' if 't' is the right kind of Token for this Terminal.
 Grammar getGrammarOfContents()
          If this Terminal is of type 'TYPE_BRACKET', 'TYPE_SQUARE' or 'TYPE_BRACE', override this method so that it returns the Grammar that should be used to parse the contents of any brackets that are accepted by this Terminal.
 java.lang.String toString()
          Returns a String representation of this Terminal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

public final int type
The type of Tokens matched by this Terminal (one of the 'Token.TYPE_XXX' values).

Constructor Detail

Grammar.Terminal

public Grammar.Terminal(int type)
Constructs a Terminal which matches a single Token of type 'type'.

Method Detail

accepts

public boolean accepts(Token t)
Returns 'true' if 't' is the right kind of Token for this Terminal.


toString

public java.lang.String toString()
Returns a String representation of this Terminal.

Specified by:
toString in class Grammar

getGrammarOfContents

public Grammar getGrammarOfContents()
If this Terminal is of type 'TYPE_BRACKET', 'TYPE_SQUARE' or 'TYPE_BRACE', override this method so that it returns the Grammar that should be used to parse the contents of any brackets that are accepted by this Terminal. Ideally, the same Grammar object should be returned every time the method is called. Do not call this method for Terminals that do not accept brackets. The default implementation throws a RuntimeException. Note that this method has no effect on the 'accepts()' method.