JML

org.multijava.util.lexgen
Class DefinitionFile

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

class DefinitionFile
extends Object


Nested Class Summary
(package private) static class DefinitionFile.KeywordTokenInfo
          This nested class serves as a data structure for accumulating information in #accumKeywords(List,String,List).
 
Field Summary
private static String DEFAULT_PREFIX
           
private  TokenDefinition[] definitions
           
private  List flags
          An immutable list of identifier Strings representing the valid flags for keywords and literals in this vocabulary.
private  String packageName
           
private  String prefix
           
private  String sourceFile
           
private  String vocabulary
           
 
Constructor Summary
DefinitionFile(String sourceFile, String packageName, String vocabulary, String prefix, List flags, ArrayList definitions)
          Constructs a token definition file
 
Method Summary
(package private)  boolean accumKeywords(List accum, String prefix, List legalFlags)
          Accumulates a list of keyword token information in accum.
 int checkIdentifiers(Hashtable identifiers, String prefix, int id)
          Check for duplicate identifiers
 List flags()
          Returns an immutable list of identifier Strings representing the valid flags for keywords and literals in this vocabulary.
 String getClassName()
          Returns the package name
 String getPackageName()
          Returns the package name
 String getPrefix()
          Returns the literal prefix
 String getVocabulary()
          Returns the vocabulary name
 void printDefinition(PrintWriter out, String prefix)
          Prints token definitions to definition file (txt)
 void printInterface(PrintWriter out, String parent)
          Prints the token definition to interface file (java)
static DefinitionFile read(String sourceFile)
          Reads and parses an token definition file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PREFIX

private static final String DEFAULT_PREFIX

sourceFile

private final String sourceFile

packageName

private final String packageName

vocabulary

private final String vocabulary

prefix

private final String prefix

flags

private final List flags
An immutable list of identifier Strings representing the valid flags for keywords and literals in this vocabulary.


definitions

private final TokenDefinition[] definitions
Constructor Detail

DefinitionFile

public DefinitionFile(String sourceFile,
                      String packageName,
                      String vocabulary,
                      String prefix,
                      List flags,
                      ArrayList definitions)
Constructs a token definition file

Method Detail

read

public static DefinitionFile read(String sourceFile)
                           throws LexgenError
Reads and parses an token definition file

Parameters:
sourceFile - the name of the source file
Returns:
a class info structure holding the information from the source
Throws:
LexgenError

checkIdentifiers

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

Parameters:
identifiers - a table of all token identifiers
prefix - the literal prefix
id - the id of the first token
Returns:
the id of the last token + 1
Throws:
LexgenError

printDefinition

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

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

printInterface

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

Parameters:
out - the output stream
parent - the super interface

accumKeywords

boolean accumKeywords(List accum,
                      String prefix,
                      List legalFlags)
Accumulates a list of keyword token information in accum.

 requires (\forall Object o; accum.contains(o); 
				   o instanceof KeywordTokenInfo);
 ensures (\forall Object o; accum.contains(o); 
				  o instanceof KeywordTokenInfo);
 also
   ensures \result != true ==> (* an error was reported to System.err *);
 


getClassName

public String getClassName()
Returns the package name


getPackageName

public String getPackageName()
Returns the package name


getVocabulary

public String getVocabulary()
Returns the vocabulary name


getPrefix

public String getPrefix()
Returns the literal prefix


flags

public List flags()
Returns an immutable list of identifier Strings representing the valid flags for keywords and literals in this vocabulary.


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.