org.sc3d.apt.sss.v3
Class Escape

java.lang.Object
  extended by org.sc3d.apt.sss.v3.Escape

public class Escape
extends java.lang.Object

Represents an escape sequence in a literal string or literal character. This is not a subclass of Token, because escape sequences are simply incorporated into the surrounding Token. This class exists only as a way of sharing the code that lexes escape sequences.


Field Summary
 boolean isOkay
          'true' if this Escape represents a syntactically correct escape sequence, otherwise 'false'.
 int length
          The number of characters that make up this Escape.
 Sentence sentence
          The Sentence in which this Escape was found.
 int start
          The index of the character in 'sentence' at which this Escape starts.
 int value
          The character code represented by this Escape.
 
Constructor Summary
Escape(Sentence sentence, int start, int length, int value, boolean isOkay)
          Constructs an Escape given values for its fields.
 
Method Summary
static Escape lex(Sentence sentence, int start)
          Lexes an Escape in the middle of 'sentence' starting at 'start'.
static void main(java.lang.String[] args)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sentence

public final Sentence sentence
The Sentence in which this Escape was found.


start

public final int start
The index of the character in 'sentence' at which this Escape starts.


length

public final int length
The number of characters that make up this Escape.


value

public final int value
The character code represented by this Escape. This is a 32-bit value. The value is not defined unless 'isOkay'.


isOkay

public final boolean isOkay
'true' if this Escape represents a syntactically correct escape sequence, otherwise 'false'.

Constructor Detail

Escape

public Escape(Sentence sentence,
              int start,
              int length,
              int value,
              boolean isOkay)
Constructs an Escape given values for its fields.

Method Detail

lex

public static Escape lex(Sentence sentence,
                         int start)
Lexes an Escape in the middle of 'sentence' starting at 'start'. This method always returns an instance of Escape. If the escape sequence is syntactically incorrect, this method returns an Escape representing the correct part, and attaches an error message to 'sentence'.

Parameters:
sentence - the Sentence from which to pluck an Escape.
start - the index of the initial '\' character of the escape sequence.
Returns:
a fresh Escape.
Throws:
java.lang.IllegalArgumentException - if 'start' is not the index of a '\' character.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)