JML

org.multijava.util.lexgen
Class TokenDefinition

java.lang.Object
  extended byorg.multijava.util.lexgen.TokenDefinition

class TokenDefinition
extends Object


Field Summary
private  String[] flags
          An array of the token flags that are true for this token.
private  int id
           
static int KEYWORD
           
static int LITERAL
          Token types
private  String name
           
static int OTHER
           
private  int type
           
private  String value
          The text value of this token in pure string format (with escape codes evaluated).
 
Constructor Summary
TokenDefinition(int type, String name, String value, List flags)
          Creates a new TokenDefinition instance.
 
Method Summary
(package private)  boolean accumKeyword(List accum, String prefix, List legalFlags)
          Adds the token information for this to accum if this is a keyword or literal token.
 void checkIdentifiers(Hashtable identifiers, String prefix, int id, String sourceFile)
          Check for duplicate identifiers
private  int flagsAsInt(List legalFlags)
           
 void printDefinition(PrintWriter out, String prefix)
          Prints the token definition to definition file (txt)
 void printInterface(PrintWriter out, String prefix)
          Prints the token definition to interface file (java)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LITERAL

public static final int LITERAL
Token types


KEYWORD

public static final int KEYWORD

OTHER

public static final int OTHER

type

private final int type

name

private final String name

value

private final String value
The text value of this token in pure string format (with escape codes evaluated).


flags

private final String[] flags
An array of the token flags that are true for this token.


id

private int id
Constructor Detail

TokenDefinition

public TokenDefinition(int type,
                       String name,
                       String value,
                       List flags)
Creates a new TokenDefinition instance.

Parameters:
type - the kind of token represented by this, one of LITERAL, KEYWORD, OTHER
name - an identifier for this token
value - the source code text matched by this token, will match name if this parameter is null
flags - a list of Strings giving the flags that are true for this token
Method Detail

checkIdentifiers

public void checkIdentifiers(Hashtable identifiers,
                             String prefix,
                             int id,
                             String sourceFile)
                      throws LexgenError
Check for duplicate identifiers

Parameters:
identifiers - a table of all token identifiers
prefix - the literal prefix
id - the id of the token
sourceFile - the file where the token is defined
Throws:
LexgenError

printDefinition

public void printDefinition(PrintWriter out,
                            String prefix)
Prints the token definition to definition file (txt)

Parameters:
out - the output stream
prefix - the literal prefix

printInterface

public void printInterface(PrintWriter out,
                           String prefix)
Prints the token definition to interface file (java)

Parameters:
out - the output stream
prefix - the literal prefix

accumKeyword

boolean accumKeyword(List accum,
                     String prefix,
                     List legalFlags)
Adds the token information for this to accum if this is a keyword or literal token.

   requires (\forall Object o; accum.contains(o); 
			o instanceof DefinitionFile.KeywordTokenInfo);
   ensures (\forall Object o; accum.contains(o); 
			o instanceof DefinitionFile.KeywordTokenInfo);
 also
   requires type == LITERAL || type == KEYWORD;
   ensures \old(accum.size() + 1) == accum.size();
 also
   requires !(type == LITERAL || type == KEYWORD);
   ensures \old(accum.equals(accum));
 also
   ensures \result != true ==> (* an error was reported to System.err *);
 


flagsAsInt

private int flagsAsInt(List legalFlags)

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.