JML

org.jmlspecs.jmlrac
Class RacParser

java.lang.Object
  extended byorg.jmlspecs.jmlrac.RacParser

public abstract class RacParser
extends Object

A utility class for generating RAC nodes from a string and an array of RAC/JML nodes. This class provides several inner classes implementing RAC nodes and provides a set of factory methods for creating them.

Version:
$Revision: 1.7 $
Author:
Yoonsik Cheon
See Also:
RacNode

Nested Class Summary
static class RacParser.RacBlock
          A RAC node class for representing blocks.
static class RacParser.RacMethodDeclaration
          A RAC node class for representing method declarations.
static class RacParser.RacStatement
          A RAC node class for representing statements.
 
Field Summary
static Object END_OF_LINE
          A marker object denoting the end of line.
 
Constructor Summary
RacParser()
           
 
Method Summary
private static List parse(String code, Object[] asts)
          Parses the given string representing verbatim code possibly with positional markers ($i) and returns a list of objects (strings, objects, END_OF_LINE's) with $i replaced by the i-th objects of the array asts.
static RacParser.RacBlock parseBlock(String code)
          Returns an object of RacBlock for the given string.
static RacParser.RacBlock parseBlock(String code, Object ast)
          Returns an object of RacBlock for the given string.
static RacParser.RacBlock parseBlock(String code, Object ast1, Object ast2)
          Returns an object of RacBlock for the given string.
static RacParser.RacBlock parseBlock(String code, Object ast1, Object ast2, Object ast3)
          Returns an object of RacBlock for the given string.
static RacParser.RacMethodDeclaration parseMethod(String code)
          Returns an object of RacMethodDeclaration for the given string.
static RacParser.RacMethodDeclaration parseMethod(String code, Object ast)
          Returns an object of RacMethodDeclaration for the given string.
static RacParser.RacMethodDeclaration parseMethod(String code, Object ast1, Object ast2)
          Returns an object of RacMethodDeclaration for the given string.
static RacParser.RacMethodDeclaration parseMethod(String code, Object ast1, Object ast2, Object ast3)
          Returns an object of RacMethodDeclaration for the given string.
static RacParser.RacMethodDeclaration parseMethod(String code, Object[] asts)
          Returns an object of RacMethodDeclaration for the given string.
static RacParser.RacStatement parseStatement(String code)
          Returns an object of RacStatement for the given string.
static RacParser.RacStatement parseStatement(String code, Object ast)
          Returns an object of RacStatement for the given string.
static RacParser.RacStatement parseStatement(String code, Object ast1, Object ast2)
          Returns an object of RacStatement for the given string.
static RacParser.RacStatement parseStatement(String code, Object ast1, Object ast2, Object ast3)
          Returns an object of RacStatement for the given string.
static RacParser.RacStatement parseStatement(String code, Object[] asts)
          Returns an object of RacStatement for the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

END_OF_LINE

public static final Object END_OF_LINE
A marker object denoting the end of line.

Constructor Detail

RacParser

public RacParser()
Method Detail

parseMethod

public static RacParser.RacMethodDeclaration parseMethod(String code)
Returns an object of RacMethodDeclaration for the given string. The string is treated as a method declaration.

 requires code != null;
 


parseMethod

public static RacParser.RacMethodDeclaration parseMethod(String code,
                                                         Object ast)
Returns an object of RacMethodDeclaration for the given string. The string is treated as a method declaration and may contain a marker ($0) at which position the object ast is inserted.

 requires code != null;
 


parseMethod

public static RacParser.RacMethodDeclaration parseMethod(String code,
                                                         Object ast1,
                                                         Object ast2)
Returns an object of RacMethodDeclaration for the given string. The string is treated as a method declaration and may contain markers ($0, $1) at which positions the objects ast1 and ast2 are inserted repectively.

 requires code != null;
 


parseMethod

public static RacParser.RacMethodDeclaration parseMethod(String code,
                                                         Object ast1,
                                                         Object ast2,
                                                         Object ast3)
Returns an object of RacMethodDeclaration for the given string. The string is treated as a method declaration and may contain markers ($0, $1, $2) at which positions the objects ast1, ast2, and ast3 are inserted repectively.

 requires code != null;
 


parseMethod

public static RacParser.RacMethodDeclaration parseMethod(String code,
                                                         Object[] asts)
Returns an object of RacMethodDeclaration for the given string. The string is treated as a method declaration and may contain markers ($i) at which positions the i-th object of the array asts is inserted.

 requires code != null;
 


parseStatement

public static RacParser.RacStatement parseStatement(String code,
                                                    Object ast)
Returns an object of RacStatement for the given string. The string is treated as a statement and may contain a marker ($0) at which position the object ast is inserted.

 requires code != null;
 


parseStatement

public static RacParser.RacStatement parseStatement(String code,
                                                    Object ast1,
                                                    Object ast2)
Returns an object of RacStatement for the given string. The string is treated as a statement and may contain markers ($0, $1) at which positions the objects ast1 and ast2 are inserted repectively. For example, the following call creates a RacStatement object representing an if-statement.
 parseStatement("if (x > 1) { $0 } else { $1 }", s1, s2);
 

 requires code != null;
 


parseStatement

public static RacParser.RacStatement parseStatement(String code,
                                                    Object ast1,
                                                    Object ast2,
                                                    Object ast3)
Returns an object of RacStatement for the given string. The string is treated as a statement and may contain markers ($0, $1, $2) at which positions the objects ast1, ast2, and ast3 are inserted repectively.

 requires code != null;
 


parseStatement

public static RacParser.RacStatement parseStatement(String code)
Returns an object of RacStatement for the given string. The string is treated as a statement.

 requires code != null;
 


parseStatement

public static RacParser.RacStatement parseStatement(String code,
                                                    Object[] asts)
Returns an object of RacStatement for the given string. The string is treated as a statement and may contain markers ($i) at which positions the i-th object of the array asts is inserted.

 requires code != null;
 


parseBlock

public static RacParser.RacBlock parseBlock(String code)
Returns an object of RacBlock for the given string. The string is treated as a block statement.

 requires code != null;
 


parseBlock

public static RacParser.RacBlock parseBlock(String code,
                                            Object ast)
Returns an object of RacBlock for the given string. The string is treated as a block statement and may contain a marker ($0) at which position the object ast is inserted.

 requires code != null;
 


parseBlock

public static RacParser.RacBlock parseBlock(String code,
                                            Object ast1,
                                            Object ast2)
Returns an object of RacBlock for the given string. The string is treated as a block statement and may contain two markers $0 and $1 and at which position the object ast1, and ast2 are inserted respectively.

 requires code != null;
 


parseBlock

public static RacParser.RacBlock parseBlock(String code,
                                            Object ast1,
                                            Object ast2,
                                            Object ast3)
Returns an object of RacBlock for the given string. The string is treated as a block statement and may contain three markers $0, $1, and $2 and at which position the object ast1, ast2, and ast3 are inserted respectively.

 requires code != null;
 


parse

private static List parse(String code,
                          Object[] asts)
Parses the given string representing verbatim code possibly with positional markers ($i) and returns a list of objects (strings, objects, END_OF_LINE's) with $i replaced by the i-th objects of the array asts. For example, if code is
  "if ($0) {\n  count = count + 1;\n}"
 
then, the returnes list is has the following form:
  "if ("
  arg0
  ") {"
  END_OF_LINE
  "  count = count + 1;"
  END_OF_LINE
  "}"
 

 requires code != null;
 ensures \result != null;
 


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.