openjava.ptree.util
Class PartialParser

java.lang.Object
  |
  +--openjava.ptree.util.PartialParser

public final class PartialParser
extends Object

The PartialParser class is an utilty class to make ptree objects from string.

See Also:
ParseTree, Expression, Statement, StatementList, MemberDeclaration, MemberDeclarationList, ClassDeclaration, CompilationUnit

Constructor Summary
protected PartialParser()
          Constructor should not be called.
 
Method Summary
private static ParseTree initialize(Environment env, ParseTree p)
           
static Expression makeExpression(Environment env, String str)
          Converts a string into an expression.
static Statement makeStatement(Environment env, String str)
          Converts a string into a statement.
static StatementList makeStatementList(Environment env, String str)
          Converts a string into a statement list.
static String replace(String base, Object a0)
           
static String replace(String base, Object[] args)
          Replaces "#s" "#EXPR" "#STMT" "#STMTS" in the given string with the given arguments.
static String replace(String base, Object a0, Object a1)
           
static String replace(String base, Object a0, Object a1, Object a2)
           
static String replace(String base, Object a0, Object a1, Object a2, Object a3)
           
static String replace(String base, Object a0, Object a1, Object a2, Object a3, Object a4)
           
static String replace(String base, Object a0, Object a1, Object a2, Object a3, Object a4, Object a5)
           
static String replace(String base, Object a0, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6)
           
static String replace(String base, Object a0, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6, Object a7)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartialParser

protected PartialParser()
Constructor should not be called.

Method Detail

initialize

private static ParseTree initialize(Environment env,
                                    ParseTree p)
                             throws ParseTreeException
ParseTreeException

replace

public static final String replace(String base,
                                   Object[] args)
                            throws MOPException
Replaces "#s" "#EXPR" "#STMT" "#STMTS" in the given string with the given arguments.

"##" is replaced with "#".


   #s      arg.toString()
   #EXPR   ((Expression) arg).toString()
   #STMT   ((Statement) arg).toString()
   #STMTS  ((StatementList) arg).toString()
 

MOPException

replace

public static final String replace(String base,
                                   Object a0)
                            throws MOPException
MOPException

replace

public static final String replace(String base,
                                   Object a0,
                                   Object a1)
                            throws MOPException
MOPException

replace

public static final String replace(String base,
                                   Object a0,
                                   Object a1,
                                   Object a2)
                            throws MOPException
MOPException

replace

public static final String replace(String base,
                                   Object a0,
                                   Object a1,
                                   Object a2,
                                   Object a3)
                            throws MOPException
MOPException

replace

public static final String replace(String base,
                                   Object a0,
                                   Object a1,
                                   Object a2,
                                   Object a3,
                                   Object a4)
                            throws MOPException
MOPException

replace

public static final String replace(String base,
                                   Object a0,
                                   Object a1,
                                   Object a2,
                                   Object a3,
                                   Object a4,
                                   Object a5)
                            throws MOPException
MOPException

replace

public static final String replace(String base,
                                   Object a0,
                                   Object a1,
                                   Object a2,
                                   Object a3,
                                   Object a4,
                                   Object a5,
                                   Object a6)
                            throws MOPException
MOPException

replace

public static final String replace(String base,
                                   Object a0,
                                   Object a1,
                                   Object a2,
                                   Object a3,
                                   Object a4,
                                   Object a5,
                                   Object a6,
                                   Object a7)
                            throws MOPException
MOPException

makeExpression

public static Expression makeExpression(Environment env,
                                        String str)
                                 throws MOPException
Converts a string into an expression. For example:
     "i + 3"
 

or :
     "f()"
 

Returns:
the expression node which the specified string represents.
Throws:
MOPException - if any critical error occurs.

makeStatement

public static Statement makeStatement(Environment env,
                                      String str)
                               throws MOPException
Converts a string into a statement. For example:
     "i++;"
 

or :
     "for(;;){ f(); }"
 

But local variable declarations are not allowed.

Returns:
the statement node which the specified string represents.
Throws:
MOPException - if any critical error occurs.

makeStatementList

public static StatementList makeStatementList(Environment env,
                                              String str)
                                       throws MOPException
Converts a string into a statement list. For example:
     "i++; j = 3;"
 

Local variable declarations like following can also be parsed.

     "int  n, m;"
 

Returns:
the statements node which the specified string represents.
Throws:
MOPException - if any critical error occurs.

SourceForge.net_Logo