From: khartlage Date: Sun, 6 Jun 2004 14:59:44 +0000 (+0000) Subject: Eliminated unused classes X-Git-Url: http://secure.phpeclipse.com Eliminated unused classes --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractCase.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractCase.java deleted file mode 100644 index 4817163..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractCase.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * Superclass of case statement that we can find in a switch. - * @author Matthieu Casanova - */ -public abstract class AbstractCase extends Statement { - - /** The statements in the case. */ - public final Statement[] statements; - - /** - * Create a case statement. - * @param statements the statements array - * @param sourceStart the beginning source offset - * @param sourceEnd the ending offset - */ - protected AbstractCase(final Statement[] statements, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.statements = statements; - } - - - /** - * Get the variables from outside (parameters, globals ...). - * @param list the list where we will put variables - */ - public final void getOutsideVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getOutsideVariable(list); - } - } - - /** - * get the modified variables. - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractPHPComment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractPHPComment.java deleted file mode 100644 index f60ebf0..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractPHPComment.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * Here are php comment. - * @author Matthieu Casanova - */ -public abstract class AbstractPHPComment extends AstNode { - - /** - * Create a comment giving starting and ending offset. - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - protected AbstractPHPComment(final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - } - - /** - * Get the variables from outside (parameters, globals ...) - * @param list the list where we will put variables - */ - public final void getOutsideVariable(final List list) { - } - - /** - * get the modified variables. - * @param list the list where we will put variables - */ - public final void getModifiedVariable(final List list) { - } - - /** - * Get the variables used. - * @param list the list where we will put variables - */ - public final void getUsedVariable(final List list) { - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractSuffixExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractSuffixExpression.java deleted file mode 100644 index d0283b5..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractSuffixExpression.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * Variable suffix. - * class access or [something] - * Should it be an expression ? - * @author Matthieu Casanova - */ -public abstract class AbstractSuffixExpression extends Expression { - - protected AbstractSuffixExpression(final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractVariable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractVariable.java deleted file mode 100644 index 9a91e22..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractVariable.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * The variable superclass. - * @author Matthieu Casanova - */ -public abstract class AbstractVariable extends Expression { - protected AbstractVariable(final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - } - - /** - * This method will return the name of the variable. - * @return a string containing the name of the variable. - */ - public abstract String getName(); -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArgumentDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArgumentDeclaration.java deleted file mode 100644 index c961dd1..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArgumentDeclaration.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - - -/** - * An argument declaration. - * - * @author Matthieu Casanova - */ -public final class ArgumentDeclaration extends VariableDeclaration { - - /** - * Create an argument. - * - * @param name the name - * @param reference the variable is a reference ? - * @param initialization the initialization - * @param sourceStart the start point - */ - public ArgumentDeclaration(final Variable name, - final boolean reference, - final Expression initialization, - final int sourceStart) { - super(name, initialization, VariableDeclaration.EQUAL, sourceStart); - this.reference = reference; - } - - /** - * Create an argument. - * - * @param name the name - * @param reference the variable is a reference ? - * @param sourceStart the start point - */ - public ArgumentDeclaration(final Variable name, - final boolean reference, - final int sourceStart) { - super(name, sourceStart); - this.reference = reference; - } - - /** - * Return the expression as String. - * - * @return the expression - */ - public String toStringExpression() { - if (initialization == null) { - if (reference) { - return '&' + variable.toStringExpression(); - } else { - return variable.toStringExpression(); - } - } else { - final String variableString = variable.toStringExpression(); - final String initializationString = initialization.toStringExpression(); - final StringBuffer buff = new StringBuffer(4 + - variableString.length() + - initializationString.length()); - if (reference) { - buff.append('&'); - } - buff.append(variableString); - buff.append(" = "); - buff.append(initializationString); - return buff.toString(); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java deleted file mode 100644 index 53e5b62..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java +++ /dev/null @@ -1,80 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * An access to a key of an array. - * @author Matthieu Casanova - */ -public final class ArrayDeclarator extends AbstractVariable { - - /** The name of the array. */ - private final AbstractVariable prefix; - - /** The key. */ - private final Expression key; - - /** - * Create an ArrayDeclarator. - * @param prefix the prefix, it could be a variable. - * @param key the key - * @param sourceEnd the end of the expression - */ - public ArrayDeclarator(final AbstractVariable prefix, - final Expression key, - final int sourceEnd) { - super(prefix.sourceStart, sourceEnd); - this.prefix = prefix; - this.key = key; - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - final StringBuffer buff = new StringBuffer(prefix.toStringExpression()); - buff.append('['); - if (key != null) { - buff.append(key.toStringExpression()); - } - buff.append(']'); - return buff.toString(); - } - - /** - * Return the name of the variable. - * @return the name of the functionName variable - */ - public String getName() { - return prefix.getName(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - prefix.getModifiedVariable(list); - if (key != null) { - key.getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - prefix.getUsedVariable(list); - if (key != null) { - key.getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java deleted file mode 100644 index 8dca5e1..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * an array initializer. - * array('a','b','c') or array('a' => 2,'b' = '3'); - * @author Matthieu Casanova - */ -public final class ArrayInitializer extends Expression { - - /** the key and values. */ - private final ArrayVariableDeclaration[] vars; - - /** - * Create a new array initializer. - * @param vars the keys and values of the array - * @param sourceStart the starting offset - * @param sourceEnd the ending offset - */ - public ArrayInitializer(final ArrayVariableDeclaration[] vars, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.vars = vars; - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - final StringBuffer buff = new StringBuffer("array("); - for (int i = 0; i < vars.length; i++) { - if (i != 0) { - buff.append(","); - } - if (vars[i] != null) { - buff.append(vars[i].toStringExpression()); - } - } - buff.append(")"); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - for (int i = 0; i < vars.length; i++) { - if (vars[i] != null) { - vars[i].getModifiedVariable(list); - } - } - } - - /** - * Get the variables used. - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - for (int i = 0; i < vars.length; i++) { - if (vars[i] != null) { - vars[i].getUsedVariable(list); - } - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayVariableDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayVariableDeclaration.java deleted file mode 100644 index 215c9ea..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayVariableDeclaration.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * a variable declaration in an array(). - * it could take Expression as key. - * - * @author Matthieu Casanova - */ -public final class ArrayVariableDeclaration extends Expression { - - /** the array key. */ - private final Expression key; - - /** the array value. */ - private Expression value; - - /** - * Create a new array variable declaration. - * - * @param key the key - * @param value the value - */ - public ArrayVariableDeclaration(final Expression key, final Expression value) { - super(key.sourceStart, value.sourceEnd); - this.key = key; - this.value = value; - } - - /** - * Create a new array variable declaration. - * - * @param key the key - * @param sourceEnd the end position - */ - public ArrayVariableDeclaration(final Expression key, final int sourceEnd) { - super(key.sourceStart, sourceEnd); - this.key = key; - } - - /** - * Return the expression as String. - * - * @return the expression - */ - public String toStringExpression() { - if (value == null) { - return key.toStringExpression(); - } else { - final String keyString = key.toStringExpression(); - final String valueString = value.toStringExpression(); - final StringBuffer buff = new StringBuffer(keyString.length() + valueString.length() + 3); - buff.append(keyString); - buff.append(" => "); - buff.append(valueString); - return buff.toString(); - } - } - - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - key.getModifiedVariable(list); - if (value != null) { - value.getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - key.getUsedVariable(list); - if (value != null) { - value.getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AstNode.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AstNode.java deleted file mode 100644 index e4ccbbb..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AstNode.java +++ /dev/null @@ -1,94 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * It will be the mother of our own ast tree for php just like the ast tree of Eclipse. - * @author Matthieu Casanova - */ -public abstract class AstNode { - - /** Starting and ending position of the node in the sources. */ - public int sourceStart, sourceEnd; - - protected AstNode() { - super(); - } - /** - * Create a node giving starting and ending offset. - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - protected AstNode(final int sourceStart, final int sourceEnd) { - this.sourceStart = sourceStart; - this.sourceEnd = sourceEnd; - } - - /** - * Add some tabulations. - * @param tab the number of tabulations - * @return a String containing some spaces - */ - public static String tabString(final int tab) { - final StringBuffer s = new StringBuffer(2 * tab); - for (int i = tab; i > 0; i--) { - s.append(" "); //$NON-NLS-1$ - } - return s.toString(); - } - - /** - * Return the object into String. - * It should be overriden - * @return a String - */ - public String toString() { - return "****" + super.toString() + "****"; //$NON-NLS-2$ //$NON-NLS-1$ - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public abstract String toString(int tab); - - /** - * Get the variables from outside (parameters, globals ...) - * @param list the list where we will put variables - */ - public abstract void getOutsideVariable(List list); - - /** - * get the modified variables. - * @param list the list where we will put variables - */ - public abstract void getModifiedVariable(List list); - - /** - * Get the variables used. - * @param list the list where we will put variables - */ - public abstract void getUsedVariable(List list); - - /** - * This method will analyze the code. - * by default it will do nothing - */ - public void analyzeCode() {} - - /** - * Check if the array array contains the object o. - * @param array an array - * @param o an obejct - * @return true if the array contained the object o - */ - public final boolean arrayContains(final Object[] array, final Object o) { - for (int i = 0; i < array.length; i++) { - if (array[i].equals(o)) { - return true; - } - } - return false; - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java deleted file mode 100644 index 7488cb8..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * a binary expression is a combination of two expressions with an operator. - * - * @author Matthieu Casanova - */ -public final class BinaryExpression extends OperatorExpression { - - /** The left expression. */ - private final Expression left; - /** The right expression. */ - private final Expression right; - - /** - * Create a binary expression. - * - * @param left the left expression - * @param right the right expression - * @param operator an operator taken in the {@link OperatorExpression} interface - */ - public BinaryExpression(final Expression left, - final Expression right, - final int operator) { - super(operator, left.sourceStart, right.sourceEnd); - this.left = left; - this.right = right; - } - - public String toStringExpression() { - final String leftString = left.toStringExpression(); - final String operatorString = operatorToString(); - final String rightString = right.toStringExpression(); - final StringBuffer buff = new StringBuffer(leftString.length() + operatorString.length() + rightString.length()); - buff.append(leftString); - buff.append(operatorString); - buff.append(rightString); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - left.getModifiedVariable(list); - right.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - left.getUsedVariable(list); - right.getUsedVariable(list); - } - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java deleted file mode 100644 index 1f6c9a0..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java +++ /dev/null @@ -1,88 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A Block. - * { - * statements - * }. - * @author Matthieu Casanova - */ -public final class Block extends Statement { - - /** An array of statements inside the block. */ - public final Statement[] statements; - - /** - * Create a block. - * @param statements the statements - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - public Block(final Statement[] statements, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.statements = statements; - } - - /** - * tell if the block is empty. - * @return the block is empty if there are no statements in it - */ - public boolean isEmptyBlock() { - return statements == null; - } - - /** - * Return the block as String. - * @param tab how many tabs - * @return the string representation of the block - */ - public String toString(final int tab) { - final String s = AstNode.tabString(tab); - final StringBuffer buff = new StringBuffer(s); - buff.append("{\n"); //$NON-NLS-1$ - if (statements != null) { - for (int i = 0; i < statements.length; i++) { - buff.append(statements[i].toString(tab + 1)).append(";\n");//$NON-NLS-1$ - } - } - buff.append("}\n"); //$NON-NLS-1$ - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getOutsideVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BranchStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BranchStatement.java deleted file mode 100644 index 3013a50..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BranchStatement.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * Here is a branchstatement : break or continue. - * @author Matthieu Casanova - */ -public abstract class BranchStatement extends Statement { - - /** The label (if there is one). */ - protected final Expression expression; - - protected BranchStatement(final Expression expression, final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - this.expression = expression; - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public final void getOutsideVariable(final List list) { - if (expression != null) { - expression.getOutsideVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public final void getModifiedVariable(final List list) { - if (expression != null) { - expression.getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public final void getUsedVariable(final List list) { - if (expression != null) { - expression.getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Break.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Break.java deleted file mode 100644 index df40b0f..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Break.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * A break statement. - * @author Matthieu Casanova - */ -public final class Break extends BranchStatement { - - public Break(final Expression expression, final int sourceStart, final int sourceEnd) { - super(expression, sourceStart, sourceEnd); - } - - public String toString(final int tab) { - final String s = tabString(tab); - if (expression != null) { - return s + "break " + expression.toString();//$NON-NLS-1$ - } - return s + "break";//$NON-NLS-1$ - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java deleted file mode 100644 index 751f223..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A Case statement for a Switch. - * @author Matthieu Casanova - */ -public final class Case extends AbstractCase { - - private final Expression value; - - public Case(final Expression value, - final Statement[] statements, - final int sourceStart, - final int sourceEnd) { - super(statements, sourceStart, sourceEnd); - this.value = value; - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("case "); - buff.append(value.toStringExpression()); - buff.append(" :\n"); - if (statements != null) { - for (int i = 0; i < statements.length; i++) { - final Statement statement = statements[i]; - buff.append(statement.toString(tab + 1)); - } - } - return buff.toString(); - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - super.getModifiedVariable(list); - value.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - super.getUsedVariable(list); - value.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java deleted file mode 100644 index 8b52822..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java +++ /dev/null @@ -1,69 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * This is a cast expression. - * @author Matthieu Casanova - */ -public final class CastExpression extends Expression { - - /** The type in which we cast the expression. */ - private final ConstantIdentifier type; - - /** The expression to be casted. */ - private final Expression expression; - - /** - * Create a cast expression. - * @param type the type - * @param expression the expression - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - public CastExpression(final ConstantIdentifier type, - final Expression expression, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.type = type; - this.expression = expression; - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - final StringBuffer buff = new StringBuffer("("); - buff.append(type.toStringExpression()); - buff.append(") "); - buff.append(expression.toStringExpression()); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - expression.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - expression.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassAccess.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassAccess.java deleted file mode 100644 index 5a0553b..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassAccess.java +++ /dev/null @@ -1,99 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * Any class access. - * @author Matthieu Casanova - */ -public final class ClassAccess extends AbstractVariable { - - /** a static class access : "::". */ - public static final int STATIC = 0; - - /** a normal class access : "->". */ - public static final int NORMAL = 1; - - private final Expression prefix; - - /** the suffix. */ - private final Expression suffix; - - /** the type of access. */ - private final int type; - - /** - * Create a new class access. - * @param prefix - * @param suffix - * @param type the type of access {@link #STATIC} or {@link #NORMAL} - */ - public ClassAccess(final Expression prefix, - final Expression suffix, - final int type) { - super(prefix.sourceStart, suffix.sourceEnd); - this.prefix = prefix; - this.suffix = suffix; - this.type = type; - } - - private String toStringOperator() { - switch (type) { - case STATIC : return "::"; //$NON-NLS-1$ - case NORMAL : return "->"; //$NON-NLS-1$ - } - return "unknown operator"; //$NON-NLS-1$ - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - final String prefixString = prefix.toStringExpression(); - final String operatorString = toStringOperator(); - final String suffixString = suffix.toStringExpression(); - final StringBuffer buff = new StringBuffer(prefixString.length() + - operatorString.length() + - suffixString.length()); - buff.append(prefixString); - buff.append(operatorString); - buff.append(suffixString); - return buff.toString(); - } - - /** - * todo: find a better way to handle this - * @return the name of the variable - */ - public String getName() { - if (prefix instanceof AbstractVariable) { - return ((AbstractVariable)prefix).getName(); - } - return prefix.toStringExpression(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - prefix.getUsedVariable(list); - suffix.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java deleted file mode 100644 index adb4332..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java +++ /dev/null @@ -1,211 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.Position; - - -/** - * This class is my ClassDeclaration declaration for php. - * It is similar to org.eclipse.jdt.internal.compiler.ast.TypeDeclaration - * It directly extends AstNode because a class cannot appear anywhere in php - * @author Matthieu Casanova - */ -public final class ClassDeclaration extends Statement implements OutlineableWithChildren { - - /** The name of the class. */ - private final String name; - /** The superclass. */ - private String superclass; - - public int declarationSourceStart; - public int declarationSourceEnd; - public int bodyStart; - public int bodyEnd; - /** The methods of the class. */ - private final ArrayList methods = new ArrayList(); - /** The constructor of the class. */ - private MethodDeclaration constructor; - /** The fields of the class. */ - private final ArrayList fields = new ArrayList(); - - private final Object parent; - /** The outlineable children (those will be in the node array too. */ - private final ArrayList children = new ArrayList(); - - private final Position position; - - /** - * Create a class giving starting and ending offset. - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - public ClassDeclaration(final Object parent, - final String name, - final String superclass, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.parent = parent; - this.name = name; - this.superclass = superclass; - position = new Position(sourceStart, name.length()); - } - - /** - * Create a class giving starting and ending offset. - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - public ClassDeclaration(final Object parent, - final String name, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.parent = parent; - this.name = name; - position = new Position(sourceStart, name.length()); - } - - /** - * Add a method to the class. - * @param method the method declaration - */ - public void addMethod(final MethodDeclaration method) { - methods.add(method); - add(method); - if (method.name.equals(name)) { - constructor = method; - } - } - - public void addField(final FieldDeclaration var) { - for (int i = 0; i < var.vars.length; i++) { - final VariableDeclaration c = var.vars[i]; - children.add(c); - } - fields.add(var); - } - - public boolean add(final Outlineable o) { - return children.add(o); - } - - /** - * Tell if the class has a constructor. - * @return a boolean - */ - public boolean hasConstructor() { - return constructor != null; - } - - /** - * Return the class as String. - * @param tab how many tabs before the class - * @return the code of this class into String - */ - public String toString(final int tab) { - return tabString(tab) + toStringHeader() + toStringBody(tab); - } - - /** - * Return the body of the class as String. - * @param tab how many tabs before the body of the class - * @return the body as String - */ - private String toStringBody(final int tab) { - final StringBuffer buff = new StringBuffer(" {");//$NON-NLS-1$ - if (fields != null) { - for (int i = 0; i < fields.size(); i++) { - final FieldDeclaration field = (FieldDeclaration) fields.get(i); - buff.append("\n"); //$NON-NLS-1$ - buff.append(field.toString(tab + 1)); - buff.append(";");//$NON-NLS-1$ - } - } - for (int i = 0; i < methods.size(); i++) { - final MethodDeclaration o = (MethodDeclaration) methods.get(i); - buff.append("\n");//$NON-NLS-1$ - buff.append(o.toString(tab + 1)); - } - buff.append("\n").append(tabString(tab)).append("}"); //$NON-NLS-2$ //$NON-NLS-1$ - return buff.toString(); - } - - /** - * Return the header of the class as String. - * @return the header of the class - */ - private String toStringHeader() { - final StringBuffer buff = new StringBuffer("class ").append(name);//$NON-NLS-1$ - if (superclass != null) { - buff.append(" extends "); //$NON-NLS-1$ - buff.append(superclass); - } - return buff.toString(); - } - - /** - * Get the image of a class. - * @return the image that represents a php class - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_CLASS; - } - - public Object getParent() { - return parent; - } - - public Outlineable get(final int index) { - return (Outlineable) children.get(index); - } - - public int size() { - return children.size(); - } - - public String toString() { - final StringBuffer buff = new StringBuffer(name); - if (superclass != null) { - buff.append(":"); //$NON-NLS-1$ - buff.append(superclass); - } - return buff.toString(); - } - - public Position getPosition() { - return position; - } - - public List getList() { - return children; - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) {} -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassInstantiation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassInstantiation.java deleted file mode 100644 index 30ee9a9..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassInstantiation.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * a class instantiation. - * @author Matthieu Casanova - */ -public final class ClassInstantiation extends PrefixedUnaryExpression { - - private final boolean reference; - - public ClassInstantiation(final Expression expression, - final boolean reference, - final int sourceStart) { - super(expression, OperatorIds.NEW, sourceStart); - this.reference = reference; - } - - public String toStringExpression() { - if (!reference) { - return super.toStringExpression(); - } - return '&' + super.toStringExpression(); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java deleted file mode 100644 index 04ad606..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java +++ /dev/null @@ -1,69 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A ConditionalExpression is like that : booleanExpression ? trueValue : falseValue;. - * @author Matthieu Casanova - */ -public final class ConditionalExpression extends OperatorExpression { - - private final Expression condition; - private final Expression valueIfTrue; - private final Expression valueIfFalse; - - public ConditionalExpression(final Expression condition, - final Expression valueIfTrue, - final Expression valueIfFalse) { - super(-1, condition.sourceStart, valueIfFalse.sourceEnd); - this.condition = condition; - this.valueIfTrue = valueIfTrue; - this.valueIfFalse = valueIfFalse; - } - - public String toStringExpression() { - final String conditionString = condition.toStringExpression(); - final String valueIfTrueString = valueIfTrue.toStringExpression(); - final String valueIfFalse = this.valueIfFalse.toStringExpression(); - final StringBuffer buff = new StringBuffer(8 + - conditionString.length() + - valueIfTrueString.length() + - valueIfFalse.length()); - buff.append("("); - buff.append(conditionString); - buff.append(") ? "); - buff.append(valueIfTrueString); - buff.append(" : "); - buff.append(valueIfFalse); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - condition.getModifiedVariable(list); - valueIfTrue.getModifiedVariable(list); - valueIfFalse.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - condition.getUsedVariable(list); - valueIfTrue.getUsedVariable(list); - valueIfFalse.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConstantIdentifier.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConstantIdentifier.java deleted file mode 100644 index 0978c7d..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConstantIdentifier.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -import test.Token; - -/** - * @author Matthieu Casanova - */ -public final class ConstantIdentifier extends Expression { - - private final String name; - - public ConstantIdentifier(final String name, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.name = name; - } - - public ConstantIdentifier(final Token token) { - super(token.sourceStart,token.sourceEnd); - name = token.image; - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - return name; - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) {} -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Continue.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Continue.java deleted file mode 100644 index bb37d26..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Continue.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * A continue statement. - * @author Matthieu Casanova - */ -public final class Continue extends BranchStatement { - - public Continue(final Expression expression, final int sourceStart, final int sourceEnd) { - super(expression, sourceStart, sourceEnd); - } - - public String toString(final int tab) { - final String s = tabString(tab); - if (expression == null) { - return s + "continue";//$NON-NLS-1$ - } - return s + "continue " + expression.toString();//$NON-NLS-1$ - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DefaultCase.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DefaultCase.java deleted file mode 100644 index e8c6d12..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DefaultCase.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * A default case for a switch. - * it's default : .....; - * @author Matthieu Casanova - */ -public final class DefaultCase extends AbstractCase { - - /** - * Create a default case. - * - * @param statements the statements - * @param sourceStart the starting offset - * @param sourceEnd the ending offset - */ - public DefaultCase(final Statement[] statements, final int sourceStart, final int sourceEnd) { - super(statements, sourceStart, sourceEnd); - } - - /** - * Return the object into String. - * - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("default : \n"); //$NON-NLS-1$ - for (int i = 0; i < statements.length; i++) { - final Statement statement = statements[i]; - buff.append(statement.toString(tab + 9)); - } - return buff.toString(); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Define.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Define.java deleted file mode 100644 index 7351341..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Define.java +++ /dev/null @@ -1,94 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage; -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.ui.PHPUiImages; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.Position; - -import java.util.List; - -/** - * a Define. - * define(expression,expression) - * - * @author Matthieu Casanova - */ -public final class Define extends Statement implements Outlineable { - - private final Expression defineName; - private final Expression defineValue; - - private final Object parent; - private final Position position; - - public Define(final Object parent, - final Expression defineName, - final Expression defineValue, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.parent = parent; - this.defineName = defineName; - this.defineValue = defineValue; - position = new Position(sourceStart, sourceEnd); - } - - public String toString(final int tab) { - final String nameString = defineName.toStringExpression(); - final String valueString = defineValue.toStringExpression(); - final StringBuffer buff = new StringBuffer(tab + 10 + nameString.length() + valueString.length()); - buff.append(tabString(tab)); - buff.append("define("); - buff.append(nameString); - buff.append(", "); - buff.append(valueString); - buff.append(")"); - return buff.toString(); - } - - public String toString() { - final String nameString = defineName.toStringExpression(); - final String valueString = defineValue.toStringExpression(); - final StringBuffer buff = new StringBuffer(nameString.length() + valueString.length() + 3); - buff.append(nameString); - buff.append(" = "); - buff.append(valueString); - return buff.toString(); - } - - public ImageDescriptor getImage() { - return PHPUiImages.DESC_VAR; - } - - public Object getParent() { - return parent; - } - - public Position getPosition() { - return position; - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - list.add(new VariableUsage(defineName.toStringExpression(), sourceStart));//todo: someday : evaluate the defineName - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) {} -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java deleted file mode 100644 index a6c2934..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java +++ /dev/null @@ -1,83 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A do statement. - * - * @author Matthieu Casanova - */ -public final class DoStatement extends Statement { - - - /** The condition expression. */ - private final Expression condition; - /** The action of the while. (it could be a block) */ - private final Statement action; - - public DoStatement(final Expression condition, - final Statement action, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.condition = condition; - this.action = action; - } - - /** - * Return the object into String. - * - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final String conditionString = condition.toStringExpression(); - final StringBuffer buff; - if (action == null) { - buff = new StringBuffer(17 + tab + conditionString.length()); - buff.append("do ");//$NON-NLS-1$ - buff.append(" {} ;"); //$NON-NLS-1$ - } else { - final String actionString = action.toString(tab + 1); - buff = new StringBuffer(13 + conditionString.length() + actionString.length()); - buff.append("do ");//$NON-NLS-1$ - buff.append("\n");//$NON-NLS-1$ - buff.append(actionString); - } - buff.append(tabString(tab)); - buff.append(" while (");//$NON-NLS-1$ - buff.append(conditionString); - buff.append(")");//$NON-NLS-1$ - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - condition.getOutsideVariable(list); // todo: check if unuseful - action.getOutsideVariable(list); - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - condition.getModifiedVariable(list); - action.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - condition.getUsedVariable(list); - action.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java deleted file mode 100644 index b4677ce..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * an echo statement. - * echo something; - * - * @author Matthieu Casanova - */ -public final class EchoStatement extends Statement { - - /** An array of expressions in this echo statement. */ - private final Expression[] expressions; - - public EchoStatement(final Expression[] expressions, final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - this.expressions = expressions; - } - - public String toString() { - final StringBuffer buff = new StringBuffer("echo ");//$NON-NLS-1$ - for (int i = 0; i < expressions.length; i++) { - if (i != 0) { - buff.append(", ");//$NON-NLS-1$ - } - buff.append(expressions[i].toStringExpression()); - } - return buff.toString(); - } - - /** - * Return the object into String. - * - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final String tabs = tabString(tab); - final String str = toString(); - final StringBuffer buff = new StringBuffer(tabs.length() + str.length()); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - for (int i = 0; i < expressions.length; i++) { - expressions[i].getOutsideVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - for (int i = 0; i < expressions.length; i++) { - expressions[i].getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - for (int i = 0; i < expressions.length; i++) { - expressions[i].getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java deleted file mode 100644 index 47748bc..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * an else statement. - * it's else - * @author Matthieu Casanova - */ -public final class Else extends Statement { - - /** the statements. */ - private final Statement[] statements; - - /** - * An else statement bad version ( : endif). - * @param statements the statements - * @param sourceStart the starting offset - * @param sourceEnd the ending offset - */ - public Else(final Statement[] statements, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.statements = statements; - } - - /** - * An else statement good version - * @param statement the statement (it could be a block) - * @param sourceStart the starting offset - * @param sourceEnd the ending offset - */ - public Else(final Statement statement, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - statements = new Statement[1]; - statements[0] = statement; - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("else \n");//$NON-NLS-1$ - Statement statement; - for (int i = 0; i < statements.length; i++) { - statement = statements[i]; - buff.append(statement.toString(tab + 1)).append("\n");//$NON-NLS-1$ - } - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getOutsideVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java deleted file mode 100644 index b0ff581..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java +++ /dev/null @@ -1,74 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * An elseif statement. - * @author Matthieu Casanova - */ -public final class ElseIf extends Statement { - - /** The condition. */ - private final Expression condition; - - /** The statements. */ - private final Statement[] statements; - - public ElseIf(final Expression condition, final Statement[] statements, final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - this.condition = condition; - this.statements = statements; - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("elseif ("); - buff.append(condition.toStringExpression()); - buff.append(") \n"); - for (int i = 0; i < statements.length; i++) { - final Statement statement = statements[i]; - buff.append(statement.toString(tab + 1)).append('\n'); - } - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getModifiedVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getModifiedVariable(list); - } - condition.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - for (int i = 0; i < statements.length; i++) { - statements[i].getUsedVariable(list); - } - condition.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java deleted file mode 100644 index 34f4d4d..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * An empty statement. - * @author Matthieu Casanova - */ -public final class EmptyStatement extends Statement { - - public EmptyStatement(final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - } - - public String toString(final int tab) { - return tabString(tab) + ';'; //$NON-NLS-1$ - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) {} -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Expression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Expression.java deleted file mode 100644 index aa5841e..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Expression.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - - -/** - * An expression. - * @author Matthieu Casanova - */ -public abstract class Expression extends Statement { - - /** - * Create an expression giving starting and ending offset - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - protected Expression(final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - } - - /** - * Return the expression with a number of spaces before. - * @param tab how many spaces before the expression - * @return a string representing the expression - */ - public final String toString(final int tab) { - return tabString(tab) + toStringExpression(); - } - - /** - * Return the expression as String. - * @return the expression - */ - public abstract String toStringExpression(); -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FalseLiteral.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FalseLiteral.java deleted file mode 100644 index 161eb67..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FalseLiteral.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import test.Token; - -/** - * @author Matthieu Casanova - */ -public final class FalseLiteral extends MagicLiteral { - - public FalseLiteral(final Token token) { - super(token.sourceStart, token.sourceEnd); - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - return "false";//$NON-NLS-1$ - } - - public String toString() { - return "false";//$NON-NLS-1$ - } -} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java deleted file mode 100644 index c36e9dd..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java +++ /dev/null @@ -1,96 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.Position; - -/** - * A Field declaration. - * This is a variable declaration for a php class - * In fact it's an array of VariableUsage, since a field could contains - * several var : - * var $toto,$tata; - * @author Matthieu Casanova - */ -public final class FieldDeclaration extends Statement implements Outlineable { - - /** The variables. */ - public final VariableDeclaration[] vars; - - private final Object parent; - private final Position position; - - /** - * Create a new field. - * @param vars the array of variables. - * @param sourceStart the starting offset - * @param sourceEnd the ending offset - */ - public FieldDeclaration(final VariableDeclaration[] vars, - final int sourceStart, - final int sourceEnd, - final Object parent) { - super(sourceStart, sourceEnd); - this.vars = vars; - this.parent = parent; - position = new Position(sourceStart, sourceEnd); - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("var ");//$NON-NLS-1$ - for (int i = 0; i < vars.length; i++) { - if (i != 0) { - buff.append(",");//$NON-NLS-1$ - } - buff.append(vars[i].toStringExpression()); - } - return buff.toString(); - } - - /** - * Get the image of a variable. - * @return the image that represents a php variable - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_VAR; - } - - public Object getParent() { - return parent; - } - - public Position getPosition() { - return position; - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) {} -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java deleted file mode 100644 index b11d6f0..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A For statement. - * for(initializations;condition;increments) action - * @author Matthieu Casanova - */ -public final class ForStatement extends Statement { - - /** the initializations. */ - private final Expression[] initializations; - - /** the condition. */ - private final Expression condition; - /** the increments. */ - private final Expression[] increments; - - private final Statement action; - - /** - * a for statement. - * - * @param initializations the initializations expressions - * @param condition the condition when the for get out - * @param increments the increments statements - * @param action the action (a statement, a block ...) - * @param sourceStart the beginning sources - * @param sourceEnd the ending sources - */ - public ForStatement(final Expression[] initializations, - final Expression condition, - final Expression[] increments, - final Statement action, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.initializations = initializations; - this.condition = condition; - this.increments = increments; - this.action = action; - } - - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("for ("); //$NON-NLS-1$ - //inits - if (initializations != null) { - for (int i = 0; i < initializations.length; i++) { - buff.append(initializations[i].toStringExpression()); - if (i != (initializations.length - 1)) - buff.append(" , "); //$NON-NLS-1$ - } - } - buff.append("; "); //$NON-NLS-1$ - //cond - if (condition != null) { - buff.append(condition.toStringExpression()); - } - buff.append("; "); //$NON-NLS-1$ - //updates - if (increments != null) { - for (int i = 0; i < increments.length; i++) { - //nice only with expressions - buff.append(increments[i].toStringExpression()); - if (i != (increments.length - 1)) - buff.append(" , "); //$NON-NLS-1$ - } - } - buff.append(") "); //$NON-NLS-1$ - //block - if (action == null) - buff.append("{}"); //$NON-NLS-1$ - else - buff.append(action.toString(tab + 1)); //$NON-NLS-1$ - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - if (condition != null) { - condition.getOutsideVariable(list); - } - if (action != null) { - action.getOutsideVariable(list); - } - if (initializations != null) { - for (int i = 0; i < initializations.length; i++) { - initializations[i].getOutsideVariable(list); - } - } - if (increments != null) { - for (int i = 0; i < increments.length; i++) { - increments[i].getOutsideVariable(list); - } - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - if (condition != null) { - condition.getModifiedVariable(list); - } - if (action != null) { - action.getModifiedVariable(list); - } - if (initializations != null) { - for (int i = 0; i < initializations.length; i++) { - initializations[i].getModifiedVariable(list); - } - } - if (increments != null) { - for (int i = 0; i < increments.length; i++) { - increments[i].getModifiedVariable(list); - } - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - if (condition != null) { - condition.getUsedVariable(list); - } - if (action != null) { - action.getUsedVariable(list); - } - if (initializations != null) { - for (int i = 0; i < initializations.length; i++) { - initializations[i].getUsedVariable(list); - } - } - if (increments != null) { - for (int i = 0; i < increments.length; i++) { - increments[i].getUsedVariable(list); - } - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForeachStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForeachStatement.java deleted file mode 100644 index d32038a..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForeachStatement.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * @author Matthieu Casanova - */ -public final class ForeachStatement extends Statement { - - private final Expression expression; - private final Expression variable; - private final Statement statement; - - public ForeachStatement(final Expression expression, - final Expression variable, - final Statement statement, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.expression = expression; - this.variable = variable; - this.statement = statement; - } - - /** - * Return the object into String. - * - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final String expressionString = expression.toStringExpression(); - final String variableString = variable.toStringExpression(); - final String statementString = statement.toString(tab + 1); - final StringBuffer buff = new StringBuffer(tab + - expressionString.length() + - variableString.length() + - statementString.length() + 18); - buff.append(tabString(tab)); - buff.append("foreach ("); - buff.append(expressionString); - buff.append(" as "); - buff.append(variableString); - buff.append(" {\n"); - buff.append(statementString); - buff.append("\n}"); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - expression.getOutsideVariable(list); - variable.getOutsideVariable(list); - statement.getOutsideVariable(list); - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - expression.getModifiedVariable(list); - variable.getUsedVariable(list); - statement.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - expression.getUsedVariable(list); - statement.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java deleted file mode 100644 index d897240..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A Function call. - * @author Matthieu Casanova - */ -public final class FunctionCall extends AbstractSuffixExpression { - - /** the function name. */ - private final Expression functionName; - - /** the arguments. */ - private final Expression[] args; - - /** - * a function call. - * it's functionName(args ...) - * @param functionName the function name - * @param args the arguments - * @param sourceEnd the source end - */ - public FunctionCall(final Expression functionName, - final Expression[] args, - final int sourceEnd) { - super(functionName.sourceStart, sourceEnd); - this.functionName = functionName; - this.args = args; - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - final StringBuffer buff = new StringBuffer(functionName.toStringExpression()); - buff.append('('); - if (args != null) { - for (int i = 0; i < args.length; i++) { - final Expression arg = args[i]; - if (i != 0) { - buff.append(','); - } - buff.append(arg.toStringExpression()); - } - } - buff.append(')'); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - if (args != null) { - for (int i = 0; i < args.length; i++) { - args[i].getModifiedVariable(list); - } - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - functionName.getUsedVariable(list); - if (args != null) { - for (int i = 0; i < args.length; i++) { - args[i].getUsedVariable(list); - } - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java deleted file mode 100644 index 3e97fb4..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java +++ /dev/null @@ -1,114 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.ui.PHPUiImages; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.Position; - -import test.PHPParserSuperclass; - -/** - * A GlobalStatement statement in php. - * @author Matthieu Casanova - */ -public final class GlobalStatement extends Statement implements Outlineable { - - /** An array of the variables called by this global statement. */ - private final AbstractVariable[] variables; - - private final Object parent; - - private final Position position; - - public GlobalStatement(final Object parent, - final AbstractVariable[] variables, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.variables = variables; - this.parent = parent; - position = new Position(sourceStart, sourceEnd); - } - - public String toString() { - final StringBuffer buff = new StringBuffer("global ");//$NON-NLS-1$ - for (int i = 0; i < variables.length; i++) { - if (i != 0) { - buff.append(", ");//$NON-NLS-1$ - } - buff.append(variables[i].toStringExpression()); - } - return buff.toString(); - } - - public String toString(final int tab) { - return tabString(tab) + toString(); - } - - /** - * This will return the image for the outline of the object. - * @return an image - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_INC; - } - - public Object getParent() { - return parent; - } - - public Position getPosition() { - return position; - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - for (int i = 0; i < variables.length; i++) { - variables[i].getUsedVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) {} - - /** - * We will analyse the code. - * if we have in globals a special variable it will be reported as a warning. - * @see Variable#SPECIAL_VARS - */ - public void analyzeCode() { - for (int i = 0; i < variables.length; i++) { - if (arrayContains(Variable.SPECIAL_VARS, variables[i].getName())) { - try { - PHPParserSuperclass.setMarker("warning, you shouldn't request " + variables[i].getName() + " as global", - variables[i].sourceStart, - variables[i].sourceEnd, - PHPParserSuperclass.WARNING, - ""); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - } - } - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLBlock.java deleted file mode 100644 index d276a00..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLBlock.java +++ /dev/null @@ -1,52 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * @author Matthieu Casanova - */ -public final class HTMLBlock extends Statement { - - private final AstNode[] nodes; - - public HTMLBlock(final AstNode[] nodes) { - super(nodes[0].sourceStart, nodes[(nodes.length > 0) ? nodes.length - 1 : 0].sourceEnd); - this.nodes = nodes; - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("?>"); - for (int i = 0; i < nodes.length; i++) { - buff.append(nodes[i].toString(tab + 1)); - } - buff.append("="; //$NON-NLS-1$ - case NOT_EQUAL: - return "!="; //$NON-NLS-1$ - case LEFT_SHIFT: - return "<<"; //$NON-NLS-1$ - case RIGHT_SHIFT: - return ">>"; //$NON-NLS-1$ - case UNSIGNED_RIGHT_SHIFT: - return ">>>"; //$NON-NLS-1$ - case OR_OR: - return "||"; //$NON-NLS-1$ - case AND_AND: - return "&&"; //$NON-NLS-1$ - case PLUS: - return "+"; //$NON-NLS-1$ - case MINUS: - return "-"; //$NON-NLS-1$ - case NOT: - return "!"; //$NON-NLS-1$ - case REMAINDER: - return "%"; //$NON-NLS-1$ - case XOR: - return "^"; //$NON-NLS-1$ - case AND: - return "&"; //$NON-NLS-1$ - case MULTIPLY: - return "*"; //$NON-NLS-1$ - case OR: - return "|"; //$NON-NLS-1$ - case TWIDDLE: - return "~"; //$NON-NLS-1$ - case DIVIDE: - return "/"; //$NON-NLS-1$ - case GREATER: - return ">"; //$NON-NLS-1$ - case LESS: - return "<"; //$NON-NLS-1$ - case ORL: - return "OR"; //$NON-NLS-1$ - case ANDL: - return "AND"; //$NON-NLS-1$ - case DOT: - return "."; //$NON-NLS-1$ - case DIF: - return "<>"; //$NON-NLS-1$ - case BANG_EQUAL_EQUAL: - return "!=="; //$NON-NLS-1$ - case EQUAL_EQUAL_EQUAL: - return "==="; //$NON-NLS-1$ - case EQUAL: - return "="; //$NON-NLS-1$ - case AT: - return "@"; //$NON-NLS-1$ - case PLUS_PLUS: - return "++"; //$NON-NLS-1$ - case MINUS_MINUS: - return "--"; //$NON-NLS-1$ - case NEW: - return "new "; //$NON-NLS-1$ - } - return "unknown operator " +operator; //$NON-NLS-1$ - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/OperatorIds.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/OperatorIds.java deleted file mode 100644 index 09d6c1b..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/OperatorIds.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * The operators used in php. - * Copied from org.eclipse.jdt.internal.compiler.ast.OperatorIds - * @author Matthieu Casanova - */ -public interface OperatorIds { - int AND_AND = 0; // "&&" - int OR_OR = 1; // "||" - int AND = 2; // "&" - int OR = 3; // "|" - int LESS = 4; // "<" - int LESS_EQUAL = 5; // "<=" - int GREATER = 6; // ">" - int GREATER_EQUAL = 7; // ">=" - int XOR = 8; // "^" - int DIVIDE = 9; // "/" - int LEFT_SHIFT = 10; // "<<" - int NOT = 11; // "!" - int TWIDDLE = 12; // "~" - int MINUS = 13; // "-" - int PLUS = 14; // "+" - int MULTIPLY = 15; // "*" - int REMAINDER = 16; // "%" - int RIGHT_SHIFT = 17; // ">>" - int EQUAL_EQUAL = 18; // "==" - int UNSIGNED_RIGHT_SHIFT= 19; // ">>>" - int ORL = 20; // "OR" - int ANDL = 21; // "AND" - int DOT = 22; // "." - int DIF = 23; // "<>" - int BANG_EQUAL_EQUAL = 24; // "!==" - int EQUAL_EQUAL_EQUAL = 25; // "===" - int AT = 26; // "@" - - int NOT_EQUAL = 29; // "!=" - int PLUS_PLUS = 32; // "++" - int MINUS_MINUS = 33; // "--" - int NEW = 34; // "new " - int EQUAL = 35; // "=" -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPDocument.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPDocument.java deleted file mode 100644 index 0f81089..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPDocument.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.Position; - -/** - * It's a php document. - * This class is an outlineable object - * It will contains html and php - * @author Matthieu Casanova - */ -public final class PHPDocument implements OutlineableWithChildren { - - /** - * The nodes. - * It will include html nodes or php nodes - */ - public AstNode[] nodes; - - private final char[] name; - - /** The parent of the object. */ - private final Object parent; - - /** The outlineable children (those will be in the node array too. */ - private final ArrayList children = new ArrayList(); - - private final Position position; - /** - * Create the PHPDocument. - * @param parent the parent object (it should be null isn't it ?) - */ - public PHPDocument(final Object parent, - final char[] name) { - this.parent = parent; - this.name = name; - position = new Position(1,name.length); - } - - /** - * Return the php document as String. - * @return a string representation of the object. - */ - public String toString() { - final StringBuffer buff = new StringBuffer(); - AstNode node; - if (nodes != null) { - int i; - for (i = 0; i < nodes.length; i++) { - node = nodes[i]; - if (node == null) { - break; - } - buff.append(node.toString(0)); - if (node instanceof HTMLCode) { - buff.append("\n");//$NON-NLS-1$ - } else { - buff.append(";\n");//$NON-NLS-1$ - } - } - } - return buff.toString(); - } - - /** - * Add an outlineable object. - * @param o the new outlineable - * @return does the addition worked ? - */ - public boolean add(final Outlineable o) { - return children.add(o); - } - - /** - * Return the outlineable at the index. - * @param index the index - * @return an outlineable object - */ - public Outlineable get(final int index) { - return (Outlineable) children.get(index); - } - - /** - * The number of outlineable children. - * @return the number of children that are outlineable - */ - public int size() { - return children.size(); - } - - /** - * This will return the image for the outline of the object. - * @return an image - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_CLASS; - } - - /** - * Get the parent of the object. - * @return the parent of the object - */ - public Object getParent() { - return parent; - } - - public Position getPosition() { - return position; - } - - public List getList() { - return children; - } -} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPEchoBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPEchoBlock.java deleted file mode 100644 index abef9c5..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPEchoBlock.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * a php echo block. - * - * @author Matthieu Casanova - */ -public final class PHPEchoBlock extends AstNode { - - /** the expression. */ - private final Expression expr; - - /** - * Create a new php echo block. - * @param expr the expression - * @param sourceStart the starting offset - * @param sourceEnd the ending offset - */ - public PHPEchoBlock(final Expression expr, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.expr = expr; - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final String tabs = tabString(tab); - final String expression = expr.toStringExpression(); - final StringBuffer buff = new StringBuffer(tabs.length() + - expression.length() + - 5); - buff.append(tabs); - buff.append("");//$NON-NLS-1$ - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) {} - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - expr.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PostfixedUnaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PostfixedUnaryExpression.java deleted file mode 100644 index 8101890..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PostfixedUnaryExpression.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * @author Matthieu Casanova - */ -public final class PostfixedUnaryExpression extends UnaryExpression { - - public PostfixedUnaryExpression(final Expression expression, - final int operator, - final int sourceEnd) { - super(expression, operator, expression.sourceStart, sourceEnd); - } - - public String toStringExpression() { - return expression.toStringExpression() + operatorToString(); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrefixedUnaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrefixedUnaryExpression.java deleted file mode 100644 index 5e1ef75..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrefixedUnaryExpression.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * @author Matthieu Casanova - */ -public class PrefixedUnaryExpression extends UnaryExpression { - - public PrefixedUnaryExpression(final Expression expression, - final int operator, - final int sourceStart) { - super(expression, operator, sourceStart, expression.sourceEnd); - } - - public String toStringExpression() { - return operatorToString() + expression.toStringExpression(); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrintExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrintExpression.java deleted file mode 100644 index 9dca4d1..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrintExpression.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * @author Matthieu Casanova - */ -public final class PrintExpression extends Expression { - - private final Expression expression; - - public PrintExpression(final Expression expression, final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - this.expression = expression; - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - return "print " + expression.toStringExpression(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - expression.getOutsideVariable(list); - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - expression.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - expression.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java deleted file mode 100644 index 61e5cec..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A return statement. - * @author Matthieu Casanova - */ -public final class ReturnStatement extends Statement { - - private final Expression expression; - - public ReturnStatement(final Expression expression, final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - this.expression = expression; - } - - public String toString(final int tab) { - final String s = tabString(tab); - if (expression == null) { - return s + "return";//$NON-NLS-1$ - } - return s + "return " + expression.toStringExpression();//$NON-NLS-1$ - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - if (expression != null) { - expression.getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - if (expression != null) { - expression.getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Statement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Statement.java deleted file mode 100644 index ff647a4..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Statement.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - - -/** - * A Statement. - * @author Matthieu Casanova - */ -public abstract class Statement extends AstNode { - - /** - * Create a node giving starting and ending offset. - * @param sourceStart starting offset - * @param sourceEnd ending offset - */ - protected Statement(final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - } - - /** - * Tell if the block is empty. - * @return a statement is not empty by default - */ - public boolean isEmptyBlock() { - return false; - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StaticStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StaticStatement.java deleted file mode 100644 index 60d5da9..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StaticStatement.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A GlobalStatement statement in php. - * @author Matthieu Casanova - */ -public final class StaticStatement extends Statement { - - /** An array of the variables called by this global statement. */ - private final VariableDeclaration[] variables; - - public StaticStatement(final VariableDeclaration[] variables, final int sourceStart, final int sourceEnd) { - super(sourceStart, sourceEnd); - this.variables = variables; - } - - public String toString() { - final StringBuffer buff = new StringBuffer("static "); - for (int i = 0; i < variables.length; i++) { - if (i != 0) { - buff.append(", "); - } - buff.append(variables[i]); - } - return buff.toString(); - } - - public String toString(final int tab) { - return tabString(tab) + toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - for (int i = 0; i < variables.length; i++) { - variables[i].getModifiedVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java deleted file mode 100644 index a9d0338..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html - * - * Contributors: - * IBM Corporation - initial API and implementation - ******************************************************************************/ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -import test.Token; - -public final class StringLiteral extends Literal { - private String source; - - private AbstractVariable[] variablesInside; - - public StringLiteral(final Token token) { - super(token.sourceStart,token.sourceEnd); - source = token.image; - } - - /** - * Create a new StringLiteral - * @param token the token - * @param s sourcestart - * @param e sourceend - * @deprecated - */ - public StringLiteral(final String token, final int s, final int e) { - super(s, e); - source = token; - } - - /** - * Create a new StringLiteral - * @param token the token - * @param s sourcestart - * @param e sourceend - * @deprecated - */ - public StringLiteral(final String token, - final int s, - final int e, - final AbstractVariable[] variablesInside) { - super(s, e); - source = token; - this.variablesInside = variablesInside; - } - - /** - * Create a new StringLiteral - * @param token the token - * @param s sourcestart - * @param e sourceend - */ - public StringLiteral(final char[] token, final int s, final int e) { - this(new String(token),s, e); - } - - public StringLiteral(final int s, final int e) { - super(s, e); - } - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - return source; - } - - /** - * @deprecated - use field instead - */ - public int sourceEnd() { - return sourceEnd; - } - - /** - * @deprecated - use field instead - */ - public int sourceStart() { - return sourceStart; - } - - public void getUsedVariable(final List list) { - if (variablesInside != null) { - for (int i = 0; i < variablesInside.length; i++) { - variablesInside[i].getUsedVariable(list); - } - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/SwitchStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/SwitchStatement.java deleted file mode 100644 index e12e122..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/SwitchStatement.java +++ /dev/null @@ -1,73 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * @author Matthieu Casanova - */ -public final class SwitchStatement extends Statement { - - private final Expression variable; - private final AbstractCase[] cases; - - public SwitchStatement(final Expression variable, - final AbstractCase[] cases, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.variable = variable; - this.cases = cases; - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); - buff.append("switch (").append(variable.toStringExpression()).append(") {\n"); - for (int i = 0; i < cases.length; i++) { - final AbstractCase cas = cases[i]; - buff.append(cas.toString(tab + 1)); - buff.append('\n'); - } - buff.append('}'); - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - for (int i = 0; i < cases.length; i++) { - cases[i].getOutsideVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - for (int i = 0; i < cases.length; i++) { - cases[i].getModifiedVariable(list); - } - variable.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - for (int i = 0; i < cases.length; i++) { - cases[i].getUsedVariable(list); - } - variable.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/TrueLiteral.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/TrueLiteral.java deleted file mode 100644 index bb63a58..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/TrueLiteral.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import test.Token; - -/** - * the true literal. - * @author Matthieu Casanova - */ -public final class TrueLiteral extends MagicLiteral { - - public TrueLiteral(final Token token) { - super(token.sourceStart, token.sourceEnd); - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - return "true";//$NON-NLS-1$ - } - - public String toString() { - return "true";//$NON-NLS-1$ - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Types.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Types.java deleted file mode 100644 index 4165fb4..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Types.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -/** - * The php types defined here. - * @author Matthieu Casanova - */ -public interface Types { - - char[] STRING = {'s', 't', 'r', 'i', 'n', 'g'}; - char[] BOOL = {'b', 'o', 'o', 'l'}; - char[] BOOLEAN = {'b', 'o', 'o', 'l', 'e', 'a', 'n'}; - char[] REAL = {'r', 'e', 'a', 'l'}; - char[] DOUBLE = {'d', 'o', 'u', 'b', 'l', 'e'}; - char[] FLOAT = {'f', 'l', 'o', 'a', 't'}; - char[] INT = {'i', 'n', 't'}; - char[] INTEGER = {'i', 'n', 't', 'e', 'g', 'e', 'r'}; - char[] OBJECT = {'o', 'b', 'j', 'e', 'c', 't'}; - char[] ARRAY = {'a', 'r', 'r', 'a', 'y'}; - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/UnaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/UnaryExpression.java deleted file mode 100644 index 09f1cf1..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/UnaryExpression.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * @author Matthieu Casanova - */ -public abstract class UnaryExpression extends OperatorExpression { - - public final Expression expression; - - protected UnaryExpression(final Expression expression, final int operator, final int sourceStart, final int sourceEnd) { - super(operator, sourceStart, sourceEnd); - this.expression = expression; - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public final void getOutsideVariable(final List list) {} - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public final void getModifiedVariable(final List list) { - expression.getModifiedVariable(list); - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public final void getUsedVariable(final List list) { - expression.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java deleted file mode 100644 index 3c8699e..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java +++ /dev/null @@ -1,123 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A Variable assignation. - * $varname = initializer - * @author Matthieu Casanova - */ -public final class VarAssignation extends Expression { - - public static final int EQUAL = 0; - public static final int PLUS_EQUAL = 1; - public static final int MINUS_EQUAL = 2; - public static final int STAR_EQUAL = 3; - public static final int SLASH_EQUAL = 4; - public static final int AND_EQUAL = 5; - public static final int OR_EQUAL = 6; - public static final int XOR_EQUAL = 7; - public static final int DOT_EQUAL = 8; - public static final int REM_EQUAL = 9; - public static final int TILDE_EQUAL = 10; - public static final int LSHIFT_EQUAL = 11; - public static final int RSIGNEDSHIFT_EQUAL = 12; - - public final Expression variableName; - public final Expression initializer; - public final int operator; - - /** - * Create a new variable assignation. - * @param variableName the name of the variable - * @param initializer the expression in initializer - * @param operator the operator of assignation - * @param sourceStart the sourceStart - * @param sourceEnd the sourceEnd - */ - public VarAssignation(final Expression variableName, - final Expression initializer, - final int operator, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.variableName = variableName; - this.initializer = initializer; - this.operator = operator; - } - - /** - * Return the operator as String. - * @return the operator - */ - public String operatorToString() { - switch (operator) { - case EQUAL: - return "="; //$NON-NLS-1$ - case PLUS_EQUAL: - return "+="; //$NON-NLS-1$ - case MINUS_EQUAL: - return "-="; //$NON-NLS-1$ - case STAR_EQUAL: - return "*="; //$NON-NLS-1$ - case SLASH_EQUAL: - return "/="; //$NON-NLS-1$ - case AND_EQUAL: - return "<="; //$NON-NLS-1$ - case OR_EQUAL: - return "|=";//$NON-NLS-1$ - case XOR_EQUAL: - return "^=";//$NON-NLS-1$ - case DOT_EQUAL: - return ".="; //$NON-NLS-1$ - case REM_EQUAL: - return "%="; //$NON-NLS-1$ - case TILDE_EQUAL: - return "~="; //$NON-NLS-1$ - case LSHIFT_EQUAL: - return "<<="; //$NON-NLS-1$ - case RSIGNEDSHIFT_EQUAL: - return ">>="; //$NON-NLS-1$ - } - return " unknown operator ";//$NON-NLS-1$ - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - final String varName = variableName.toStringExpression(); - final String init = initializer.toStringExpression(); - final String operatorString = operatorToString(); - final StringBuffer buff = new StringBuffer(varName.length() + operatorString.length() + init.length() + 2); - buff.append(varName); - buff.append(" ");//$NON-NLS-1$ - buff.append(operatorString); - buff.append(" ");//$NON-NLS-1$ - buff.append(init); - return buff.toString(); - } - - - /** - * Get the variables from outside (parameters, globals ...) - */ - public void getOutsideVariable(final List list) { - } - - /** - * get the modified variables. - */ - public void getModifiedVariable(final List list) { - variableName.getUsedVariable(list); - initializer.getModifiedVariable(list); - } - - /** - * Get the variables used. - */ - public void getUsedVariable(final List list) { - initializer.getUsedVariable(list); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java deleted file mode 100644 index 3cced48..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java +++ /dev/null @@ -1,131 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage; - -/** - * A variable. - * It could be a simple variable, or contains another variable. - * @author Matthieu Casanova - */ -public final class Variable extends AbstractVariable { - - /** The name of the variable. */ - private String name; - - /** A variable inside ($$varname). */ - private AbstractVariable variable; - - /** the variable is defined like this ${expression} */ - private Expression expression; - - private static final String _GET = "_GET"; - private static final String _POST = "_POST"; - private static final String _REQUEST = "_REQUEST"; - private static final String _SERVER = "_SERVER"; - private static final String _SESSION = "_SESSION"; - private static final String _this = "this"; - private static final String GLOBALS = "GLOBALS"; - private static final String _COOKIE = "_COOKIE"; - private static final String _FILES = "_FILES"; - private static final String _ENV = "_ENV"; - - /** Here is an array of all superglobals variables and the special "this". */ - public static final String[] SPECIAL_VARS = {_GET, - _POST, - _REQUEST, - _SERVER, - _SESSION, - _this, - GLOBALS, - _COOKIE, - _FILES, - _ENV}; - - /** - * Create a new simple variable. - * @param name the name - * @param sourceStart the starting position - * @param sourceEnd the ending position - */ - public Variable(final String name, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.name = name; - } - - /** - * Create a special variable ($$toto for example). - * @param variable the variable contained - * @param sourceStart the starting position - * @param sourceEnd the ending position - */ - public Variable(final AbstractVariable variable, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.variable = variable; - } - - /** - * Create a special variable ($$toto for example). - * @param expression the variable contained - * @param sourceStart the starting position - * @param sourceEnd the ending position - */ - public Variable(final Expression expression, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.expression = expression; - } - - /** - * Return the expression as String. - * @return the expression - */ - public String toStringExpression() { - return '$' + getName(); - } - - public String getName() { - if (name != null) { - return name; - } - if (variable != null) { - return variable.toStringExpression(); - } - return '{' + expression.toStringExpression() + '}'; - } - - /** - * Get the variables from outside (parameters, globals ...) - */ - public void getOutsideVariable(final List list) { - } - - /** - * get the modified variables. - */ - public void getModifiedVariable(final List list) { - } - - /** - * Get the variables used. - */ - public void getUsedVariable(final List list) { - final String varName; - if (name != null) { - varName = name; - } else if (variable != null) { - varName = variable.getName(); - } else { - varName = expression.toStringExpression();//todo : do a better thing like evaluate this ?? - } - if (!arrayContains(SPECIAL_VARS, name)) { - list.add(new VariableUsage(varName, sourceStart)); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java deleted file mode 100644 index fc4f236..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java +++ /dev/null @@ -1,227 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.ui.PHPUiImages; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.Position; - -import java.util.List; - -/** - * A variable declaration. - * - * @author Matthieu Casanova - */ -public class VariableDeclaration extends Expression implements Outlineable { - - public static final int EQUAL = 0; - public static final int PLUS_EQUAL = 1; - public static final int MINUS_EQUAL = 2; - public static final int STAR_EQUAL = 3; - public static final int SLASH_EQUAL = 4; - public static final int AND_EQUAL = 5; - public static final int OR_EQUAL = 6; - public static final int XOR_EQUAL = 7; - public static final int DOT_EQUAL = 8; - public static final int REM_EQUAL = 9; - public static final int TILDE_EQUAL = 10; - public static final int LSHIFT_EQUAL = 11; - public static final int RSIGNEDSHIFT_EQUAL = 12; - - protected final AbstractVariable variable; - - /** The value for variable initialization. */ - public Expression initialization; - - private Object parent; - protected boolean reference; - - private Position position; - - private int operator; - - /** - * Create a variable. - * - * @param variable the name of the variable - * @param initialization the initialization - * @param operator the assign operator - * @param sourceStart the start point - */ - public VariableDeclaration(final Object parent, - final AbstractVariable variable, - final Expression initialization, - final int operator, - final int sourceStart) { - super(sourceStart, initialization.sourceEnd); - this.initialization = initialization; - this.variable = variable; - this.operator = operator; - this.parent = parent; - position = new Position(sourceStart, sourceEnd); - } - - /** - * Create a variable. - * - * @param variable a variable (in case of $$variablename) - * @param sourceStart the start point - */ - public VariableDeclaration(final Object parent, - final AbstractVariable variable, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.variable = variable; - this.parent = parent; - position = new Position(sourceStart, sourceEnd); - } - - public final void setReference(final boolean reference) { - this.reference = reference; - } - - /** - * Create a variable. - * - * @param initialization the initialization - * @param variable a variable (in case of $$variablename) - * @param sourceStart the start point - */ - public VariableDeclaration(final AbstractVariable variable, - final Expression initialization, - final int operator, - final int sourceStart) { - super(sourceStart, initialization.sourceEnd); - this.variable = variable; - this.initialization = initialization; - this.operator = operator; - } - - /** - * Create a variable. - * - * @param variable a variable (in case of $$variablename) - * @param sourceStart the start point - */ - public VariableDeclaration(final AbstractVariable variable, - final int sourceStart) { - super(sourceStart, variable.sourceEnd); - this.variable = variable; - } - - /** - * Return the operator as String. - * - * @return the operator - */ - private String operatorToString() { - switch (operator) { - case EQUAL: - return "="; //$NON-NLS-1$ - case PLUS_EQUAL: - return "+="; //$NON-NLS-1$ - case MINUS_EQUAL: - return "-="; //$NON-NLS-1$ - case STAR_EQUAL: - return "*="; //$NON-NLS-1$ - case SLASH_EQUAL: - return "/="; //$NON-NLS-1$ - case AND_EQUAL: - return "<="; //$NON-NLS-1$ - case OR_EQUAL: - return "|=";//$NON-NLS-1$ - case XOR_EQUAL: - return "^=";//$NON-NLS-1$ - case DOT_EQUAL: - return ".="; //$NON-NLS-1$ - case REM_EQUAL: - return "%="; //$NON-NLS-1$ - case TILDE_EQUAL: - return "~="; //$NON-NLS-1$ - case LSHIFT_EQUAL: - return "<<="; //$NON-NLS-1$ - case RSIGNEDSHIFT_EQUAL: - return ">>="; //$NON-NLS-1$ - } - return " unknown operator ";//$NON-NLS-1$ - } - - /** - * Return the variable into String. - * - * @return a String - */ - public String toStringExpression() { - final String variableString = variable.toStringExpression(); - if (initialization == null) { - if (reference) return '&' + variableString; else return variableString; - } else { - final String operatorString = operatorToString(); - final String initString = initialization.toStringExpression(); - final StringBuffer buff = new StringBuffer(variableString.length() + - operatorString.length() + - initString.length() + - 1); - buff.append(variableString); - buff.append(operatorString); //$NON-NLS-1$ - buff.append(initString); - return buff.toString(); - } - } - - public final Object getParent() { - return parent; - } - - public final String toString() { - return toStringExpression(); - } - - /** - * Get the image of a variable. - * - * @return the image that represents a php variable - */ - public final ImageDescriptor getImage() { - return PHPUiImages.DESC_VAR; - } - - public final Position getPosition() { - return position; - } - - /** - * Get the name of the field as String. - * - * @return the name of the String - */ - public final String name() { - return variable.getName(); - } - - /** - * Get the variables from outside (parameters, globals ...) - */ - public final void getOutsideVariable(final List list) { - } - - /** - * get the modified variables. - */ - public final void getModifiedVariable(final List list) { - variable.getUsedVariable(list); - if (initialization != null) { - initialization.getModifiedVariable(list); - } - } - - /** - * Get the variables used. - */ - public final void getUsedVariable(final List list) { - if (initialization != null) { - initialization.getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java deleted file mode 100644 index f98367c..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast; - -import java.util.List; - -/** - * A While statement. - * @author Matthieu Casanova - */ -public final class WhileStatement extends Statement { - - /** The condition expression. */ - private final Expression condition; - /** The action of the while. (it could be a block) */ - private final Statement action; - - /** - * Create a While statement. - * @param condition the condition - * @param action the action - * @param sourceStart the starting offset - * @param sourceEnd the ending offset - */ - public WhileStatement(final Expression condition, - final Statement action, - final int sourceStart, - final int sourceEnd) { - super(sourceStart, sourceEnd); - this.condition = condition; - this.action = action; - } - - /** - * Return the object into String. - * @param tab how many tabs (not used here - * @return a String - */ - public String toString(final int tab) { - final String s = tabString(tab); - final StringBuffer buff = new StringBuffer(s).append("while ("); //$NON-NLS-1$ - buff.append(condition.toStringExpression()).append(")"); //$NON-NLS-1$ - if (action == null) { - buff.append(" {} ;"); //$NON-NLS-1$ - } else { - buff.append("\n").append(action.toString(tab + 1)); //$NON-NLS-1$ - } - return buff.toString(); - } - - /** - * Get the variables from outside (parameters, globals ...) - * - * @param list the list where we will put variables - */ - public void getOutsideVariable(final List list) { - condition.getOutsideVariable(list); // todo: check if unuseful - if (action != null) { - action.getOutsideVariable(list); - } - } - - /** - * get the modified variables. - * - * @param list the list where we will put variables - */ - public void getModifiedVariable(final List list) { - condition.getModifiedVariable(list); - if (action != null) { - action.getModifiedVariable(list); - } - } - - /** - * Get the variables used. - * - * @param list the list where we will put variables - */ - public void getUsedVariable(final List list) { - condition.getUsedVariable(list); - if (action != null) { - action.getUsedVariable(list); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/declarations/VariableUsage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/declarations/VariableUsage.java deleted file mode 100644 index 7d9b936..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/declarations/VariableUsage.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.ast.declarations; - -/** - * A variable usage. - * This describe a variable declaration in a php document and his starting offset - * @author Matthieu Casanova - */ -public final class VariableUsage { - - /** the variable name. */ - private final String name; - - /** where the variable is declared. */ - private final int startOffset; - - /** - * create a VariableUsage. - * @param name the name of the variable - * @param startOffset the offset - */ - public VariableUsage(final String name, final int startOffset) { - this.name = name; - this.startOffset = startOffset; - } - - public String toString() { - return name + ' ' + startOffset; - } - - /** - * Get the name of the variable. - * @return the name if the variable - */ - public String getName() { - return name; - } - - /** - * Get the starting offset. - * @return the starting offset - */ - public int getStartOffset() { - return startOffset; - } - - public boolean equals(final Object object) { - return name.equals(object); - } - - public int hashCode() { - return name.hashCode(); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/NLSLine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/NLSLine.java index 18f7135..f6bb64a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/NLSLine.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/NLSLine.java @@ -14,7 +14,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import net.sourceforge.phpdt.internal.compiler.ast.StringLiteral; +import net.sourceforge.phpeclipse.internal.compiler.ast.StringLiteral; public class NLSLine { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPClassDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPClassDeclaration.java deleted file mode 100644 index b198e02..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPClassDeclaration.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; -/** - * A class declaration. - * @author khartlage - */ -public class PHPClassDeclaration extends PHPSegmentWithChildren { - - /** - * Create a class declaration. - * @param parent the parent object (it should be a php class) - * @param name the name of the class - * @param index where the class is in the file - */ - public PHPClassDeclaration(Object parent, String name, int index) { - super(parent, name, index); - } - - /** - * Get the image of a class. - * @return the image that represents a php class - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_CLASS; - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPFunctionDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPFunctionDeclaration.java deleted file mode 100644 index 1c86a3f..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPFunctionDeclaration.java +++ /dev/null @@ -1,130 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import java.util.Enumeration; -import java.util.Hashtable; - -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * A function declaration. - * @author khartlage - */ -public class PHPFunctionDeclaration extends PHPSegmentWithChildren { - - /** The parameters of the function. */ - private final Hashtable parameters; - - /** The parameters of the function. */ - private final Hashtable declaredVariables; - - /** - * A String representation of the function (it's generated once because it needs to iterate - * a hashtable == long. - */ - private String stringRepresentation; - - /** - * Create a function declaration. - * @param parent the parent object (it should be a php class) - * @param name the name of the function - * @param index where the function is in the file - */ - public PHPFunctionDeclaration(Object parent, String name, int index) { - super(parent, name, index); - parameters = null; - declaredVariables = null; - } - - /** - * Create a function declaration. - * @param parent the parent object (it should be a php class) - * @param name the name of the function - * @param index where the function is in the file - * @param parameters the list of parameters (it should contains only PHPVar) - */ - public PHPFunctionDeclaration(Object parent, String name, int index, Hashtable parameters) { - super(parent, name, index); - this.parameters = parameters; - declaredVariables = (Hashtable) parameters.clone(); - createStringView(); - } - - /** - * Get the image of a class. - * @return the image that represents a php class - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_FUN; - } - - /** - * Return the string representation of the function. - * @return the string representation of the function - */ - public String toString() { - if (parameters == null) { - return super.toString(); - } - return stringRepresentation; - } - - /** - * Create the String representation of the function. - */ - private void createStringView() { - StringBuffer buff = new StringBuffer(name).append("("); - Enumeration vars = parameters.elements(); - boolean first = false; - while (vars.hasMoreElements()) { - PHPVarDeclaration o = (PHPVarDeclaration) vars.nextElement(); - if (first) { - buff.append(","); - } else { - first = true; - } - buff.append(o.toString()); - } - buff.append(")"); - stringRepresentation = buff.toString(); - } - - /** - * Return a parameter of the function - * @param parameterName the name of the parameter - * @return it will return the PHPVarDeclaration of the parameter asked, or null - */ - public PHPVarDeclaration getParameter(String parameterName) { - return (PHPVarDeclaration) parameters.get(parameterName); - } - - /** - * Return all parameters of the function. - * @return a hashtable containing all PHPVarDeclaration - */ - public Hashtable getParameters() { - return parameters; - } - - /** - * Return a variable of the function - * @param variableName the name of the parameter - * @return it will return the PHPVarDeclaration of the parameter asked, or null - */ - public PHPVarDeclaration getVariable(String variableName) { - return (PHPVarDeclaration) declaredVariables.get(variableName); - } - - /** - * Return all declared variables of the function. - * @return a hashtable containing all PHPVarDeclaration - */ - public Hashtable getVariables() { - return declaredVariables; - } - - public Object addVariable(PHPVarDeclaration var) { - return declaredVariables.put(var.getVariable().getName(),var); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPGlobalDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPGlobalDeclaration.java deleted file mode 100644 index 1ad7870..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPGlobalDeclaration.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * A require, require_once, include or include_once declaration strongly inspired by the PHPFunctionDeclaration of Khartlage (:. - * @author khartlage, Matthieu Casanova - */ -public class PHPGlobalDeclaration extends PHPSegment { - - /** What is required/included. */ - private String value; - /** - * Create an include declaration. - * @param parent the parent object (it should be a php class or function) - * @param name it should be require, require_once, include or include_once - * @param index where the keyword is in the file - * @param value what is included - */ - public PHPGlobalDeclaration(Object parent, String name, int index, String value) { - super(parent, name, index); - this.value = value; - } - - /** - * Create an include declaration. - * @param parent the parent object (it should be a php class or function) - * @param name it should be require, require_once, include or include_once - * @param index where the keyword is in the file - */ - public PHPGlobalDeclaration(Object parent, String name, int index) { - this(parent, name, index,null); - } - - /** - * Get the image of a variable. - * @return the image that represents a php variable - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_INC; - } - - public String toString() { - return name + " : " + value; - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPOutlineInfo.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPOutlineInfo.java deleted file mode 100644 index 9da892a..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPOutlineInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import java.util.TreeSet; - -/** - * - * @author khartlage - */ -public class PHPOutlineInfo { - TreeSet fVariables; - OutlineableWithChildren fDeclarations; - - public PHPOutlineInfo(Object parent) { - fVariables = new TreeSet(); - fDeclarations = new PHPClassDeclaration(parent, "_root", 1); - } - - public PHPOutlineInfo(Object parent, OutlineableWithChildren phpDocument) { - fVariables = new TreeSet(); - fDeclarations = phpDocument; - } - - public TreeSet getVariables() { - return fVariables; - } - - public OutlineableWithChildren getDeclarations() { - return fDeclarations; - } - - public boolean add(OutlineableWithChildren o) { - return fDeclarations.add(o); - } - - public boolean addVariable(String variable) { - return fVariables.add(variable); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPReqIncDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPReqIncDeclaration.java deleted file mode 100644 index a959fe4..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPReqIncDeclaration.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * A require, require_once, include or include_once declaration strongly inspired by the PHPFunctionDeclaration of Khartlage (:. - * @author khartlage, Matthieu Casanova - */ -public class PHPReqIncDeclaration extends PHPSegment { - - /** What is required/included. */ - private String value; - /** - * Create an include declaration. - * @param parent the parent object (it should be a php class or function) - * @param name it should be require, require_once, include or include_once - * @param index where the keyword is in the file - * @param value what is included - */ - public PHPReqIncDeclaration(Object parent, String name, int index, String value) { - super(parent, name, index); - this.value = value; - } - - /** - * Create an include declaration. - * @param parent the parent object (it should be a php class or function) - * @param name it should be require, require_once, include or include_once - * @param index where the keyword is in the file - */ - public PHPReqIncDeclaration(Object parent, String name, int index) { - this(parent, name, index,null); - } - - /** - * Get the image of a variable. - * @return the image that represents a php variable - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_INC; - } - - public String toString() { - return name + " : " + value; - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java deleted file mode 100644 index 16da5e5..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import org.eclipse.jface.text.Position; - -/** - * - * @author khartlage - */ -public abstract class PHPSegment implements Outlineable { - protected String name; - private Position position; - private Object parent; - - public PHPSegment(Object parent, String name, int index) { - this.parent = parent; - this.name = name; - this.position = new Position(index, name.length()); - } - - /** - * Return the name of the segment. - * @return the name of the segment - */ - public String getName() { - return name; - } - - public String toString() { - return name; - } - - public Position getPosition() { - return position; - } - - public Object getParent() { - return parent; - } - -}; \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegmentWithChildren.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegmentWithChildren.java deleted file mode 100644 index 172b90d..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegmentWithChildren.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import java.util.ArrayList; -import java.util.List; - -/** - * An abstract PHPSegment that can have children. - * @author khartlage, Matthieu Casanova - */ -public abstract class PHPSegmentWithChildren extends PHPSegment implements OutlineableWithChildren { - private ArrayList children; - - /** - * Create a PHPSegment that can have children (class or functions). - * @param parent the parent object (it should be a php class) - * @param name the name of the function - * @param index where the function is in the file - */ - public PHPSegmentWithChildren(Object parent, String name, int index) { - super(parent, name, index); - children = new ArrayList(); - } - - public List getList( ) { - return children; - } - - /** - * Appends the specified PHPSegment declaration - * - * @param o function declaration to be appended to this list. - * @return true (as per the general contract of Collection.add). - */ - public boolean add(Outlineable o) { - return children.add(o); - } - - /** - * Returns the PHPSegment declaration at the specified position in this list. - * - * @param index index of function declaration to return. - * @return the function declaration at the specified position in this list. - * @throws java.lang.IndexOutOfBoundsException if index is out of range (index - * < 0 || index >= size()). - */ - public Outlineable get(int index) { - return (Outlineable) children.get(index); - } - - /** - * Returns the number of declarations in this list. - * - * @return the number of declarations in this list. - */ - public int size() { - return children.size(); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPVarDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPVarDeclaration.java deleted file mode 100644 index 094f97d..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPVarDeclaration.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.sourceforge.phpdt.internal.compiler.parser; - -import net.sourceforge.phpdt.internal.ui.PHPUiImages; - -import org.eclipse.jface.resource.ImageDescriptor; - -import test.PHPVar; - -/** - * A php variable declaration strongly inspired by the PHPFunctionDeclaration of Khartlage (:. - * @author khartlage, Matthieu Casanova - */ -public class PHPVarDeclaration extends PHPSegment { - - /** A PHPVar. */ - private final PHPVar variable; - /** - * Create a php variable declaration. - * @param parent the parent object (it should be a php class) - * @param name the name of the variable - * @param index where the variable is in the file - * @param value the value - */ - public PHPVarDeclaration(Object parent, String name, int index, String value) { - super(parent, name, index); - variable = new PHPVar(name,value); - } - - /** - * Create a php variable declaration. - * @param parent the parent object (it should be a php class) - * @param name the name of the variable - * @param index where the variable is in the file - */ - public PHPVarDeclaration(Object parent, String name, int index) { - this(parent, name, index,null); - } - - /** - * Get the image of a variable. - * @return the image that represents a php variable - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_VAR; - } - - /** - * Get the PHPVar. - * @return a phpvar object - */ - public PHPVar getVariable() { - return variable; - } - - public String toString() { - return variable.toString(); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java index bfbb4d7..af7f65a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java @@ -18,7 +18,9 @@ import net.sourceforge.phpdt.core.compiler.CharOperation; import net.sourceforge.phpdt.core.compiler.IScanner; import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; import net.sourceforge.phpdt.core.compiler.InvalidInputException; -import net.sourceforge.phpdt.internal.compiler.ast.StringLiteral; +import net.sourceforge.phpeclipse.internal.compiler.ast.StringLiteral; + + public class Scanner implements IScanner, ITerminalSymbols { /* * APIs ares - getNextToken() which return the current type of the token diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/ExternalPHPParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/ExternalPHPParser.java new file mode 100644 index 0000000..63704ad --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/ExternalPHPParser.java @@ -0,0 +1,350 @@ +package net.sourceforge.phpeclipse.actions; + +import java.io.IOException; +import java.io.InputStream; +import java.text.MessageFormat; +import java.util.Hashtable; + +//import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; +import net.sourceforge.phpdt.internal.ui.util.StringUtil; +import net.sourceforge.phpdt.ui.PreferenceConstants; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.views.PHPConsole; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ui.texteditor.MarkerUtilities; + +/** + * Calls the external parser and generates problem markers if necessary + */ +public class ExternalPHPParser { + private final static String PROBLEM_ID = "net.sourceforge.phpeclipse.problem"; + // strings for external parser call + private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$ + private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ + public static final int ERROR = 2; + public static final int WARNING = 1; + public static final int INFO = 0; + public static final int TASK = 3; + // TODO design error? Analyze why fileToParse must be static ??? + final protected IFile fFileToParse; + + public ExternalPHPParser(IFile file) { + fFileToParse = file; + } + /** + * Call the php parse command ( php -l -f <filename> ) and create + * markers according to the external parser output. + * + * @param file + * the file that will be parsed + */ + public void phpExternalParse() { + //IFile file = (IFile) resource; + // final IPath path = file.getFullPath(); + final IPreferenceStore store = PHPeclipsePlugin.getDefault() + .getPreferenceStore(); + final String filename = fFileToParse.getLocation().toString(); + + final String[] arguments = {filename}; + final MessageFormat form = new MessageFormat(store + .getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF)); + final String command = form.format(arguments); + + final String parserResult = getParserOutput(command, + "External parser: "); + + try { + // parse the buffer to find the errors and warnings + createMarkers(parserResult, fFileToParse); + } catch (CoreException e) { + } + } + + /** + * Create markers according to the external parser output. + * + * @param output + * the external parser output + * @param file + * the file that was parsed. + */ + protected void createMarkers(final String output, final IFile file) + throws CoreException { + // delete all markers + file.deleteMarkers(PROBLEM_ID, false, 0); + + int indx = 0; + int brIndx; + boolean flag = true; + while ((brIndx = output.indexOf("
", indx)) != -1) { + // newer php error output (tested with 4.2.3) + scanLine(output, file, indx, brIndx); + indx = brIndx + 6; + flag = false; + } + if (flag) { + while ((brIndx = output.indexOf("
", indx)) != -1) { + // older php error output (tested with 4.2.3) + scanLine(output, file, indx, brIndx); + indx = brIndx + 4; + } + } + } + + private void scanLine(final String output, final IFile file, + final int indx, final int brIndx) throws CoreException { + String current; + // String outLineNumberString; never used + final StringBuffer lineNumberBuffer = new StringBuffer(10); + char ch; + current = output.substring(indx, brIndx); + + if (current.indexOf(PARSE_WARNING_STRING) != -1 + || current.indexOf(PARSE_ERROR_STRING) != -1) { + final int onLine = current.indexOf("on line "); + if (onLine != -1) { + lineNumberBuffer.delete(0, lineNumberBuffer.length()); + for (int i = onLine; i < current.length(); i++) { + ch = current.charAt(i); + if ('0' <= ch && '9' >= ch) { + lineNumberBuffer.append(ch); + } + } + + final int lineNumber = Integer.parseInt(lineNumberBuffer + .toString()); + + final Hashtable attributes = new Hashtable(); + + current = StringUtil.replaceAll(current, "\n", ""); + current = StringUtil.replaceAll(current, "", ""); + current = StringUtil.replaceAll(current, "", ""); + MarkerUtilities.setMessage(attributes, current); + + if (current.indexOf(PARSE_ERROR_STRING) != -1) + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_ERROR)); + else if (current.indexOf(PARSE_WARNING_STRING) != -1) + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_WARNING)); + else + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_INFO)); + MarkerUtilities.setLineNumber(attributes, lineNumber); + MarkerUtilities.createMarker(file, attributes, PROBLEM_ID); + } + } + } + + /** + * This will set a marker. + * + * @param file + * the file that generated the marker + * @param message + * the message + * @param charStart + * the starting character + * @param charEnd + * the end character + * @param errorLevel + * the error level ({@link ExternalPHPParser#ERROR}, + * {@link ExternalPHPParser#INFO}, + * {@link ExternalPHPParser#WARNING}), + * {@link ExternalPHPParser#TASK}) + * @throws CoreException + * an exception throwed by the MarkerUtilities + */ + private void setMarker(final IFile file, final String message, + final int charStart, final int charEnd, final int errorLevel) + throws CoreException { + if (file != null) { + final Hashtable attributes = new Hashtable(); + MarkerUtilities.setMessage(attributes, message); + switch (errorLevel) { + case ERROR : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_ERROR)); + break; + case WARNING : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_WARNING)); + break; + case INFO : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_INFO)); + break; + case TASK : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK)); + break; + } + MarkerUtilities.setCharStart(attributes, charStart); + MarkerUtilities.setCharEnd(attributes, charEnd); + MarkerUtilities.createMarker(file, attributes, PROBLEM_ID); + } + } + + /** + * This will set a marker. + * + * @param file + * the file that generated the marker + * @param message + * the message + * @param line + * the line number + * @param errorLevel + * the error level ({@link ExternalPHPParser#ERROR}, + * {@link ExternalPHPParser#INFO}, + * {@link ExternalPHPParser#WARNING}) + * @throws CoreException + * an exception throwed by the MarkerUtilities + */ + private void setMarker(final IFile file, final String message, + final int line, final int errorLevel, final String location) + throws CoreException { + if (file != null) { + String markerKind = PROBLEM_ID; + final Hashtable attributes = new Hashtable(); + MarkerUtilities.setMessage(attributes, message); + switch (errorLevel) { + case ERROR : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_ERROR)); + break; + case WARNING : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_WARNING)); + break; + case INFO : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_INFO)); + break; + case TASK : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_INFO)); + markerKind = IMarker.TASK; + break; + } + attributes.put(IMarker.LOCATION, location); + MarkerUtilities.setLineNumber(attributes, line); + MarkerUtilities.createMarker(file, attributes, markerKind); + } + } + + /** + * This will set a marker. + * + * @param message + * the message + * @param charStart + * the starting character + * @param charEnd + * the end character + * @param errorLevel + * the error level ({@link ExternalPHPParser#ERROR}, + * {@link ExternalPHPParser#INFO}, + * {@link ExternalPHPParser#WARNING}) + * @throws CoreException + * an exception throwed by the MarkerUtilities + */ + private void setMarker(final String message, final int charStart, + final int charEnd, final int errorLevel, final String location) + throws CoreException { + if (fFileToParse != null) { + setMarker(fFileToParse, message, charStart, charEnd, errorLevel, + location); + } + } + + /** + * This will set a marker. + * + * @param file + * the file that generated the marker + * @param message + * the message + * @param charStart + * the starting character + * @param charEnd + * the end character + * @param errorLevel + * the error level ({@link ExternalPHPParser#ERROR}, + * {@link ExternalPHPParser#INFO}, + * {@link ExternalPHPParser#WARNING}) + * @param location + * the location of the error + * @throws CoreException + * an exception throwed by the MarkerUtilities + */ + private void setMarker(final IFile file, final String message, + final int charStart, final int charEnd, final int errorLevel, + final String location) throws CoreException { + if (file != null) { + final Hashtable attributes = new Hashtable(); + MarkerUtilities.setMessage(attributes, message); + switch (errorLevel) { + case ERROR : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_ERROR)); + break; + case WARNING : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_WARNING)); + break; + case INFO : + attributes.put(IMarker.SEVERITY, new Integer( + IMarker.SEVERITY_INFO)); + break; + case TASK : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK)); + break; + } + attributes.put(IMarker.LOCATION, location); + MarkerUtilities.setCharStart(attributes, charStart); + MarkerUtilities.setCharEnd(attributes, charEnd); + MarkerUtilities.createMarker(file, attributes, PROBLEM_ID); //IMarker.PROBLEM); + } + } + + private String getParserOutput(String command, String consoleMessage) { + try { + PHPConsole console = null; + try { + console = PHPConsole.getInstance(); + if (console != null) { + console.write(consoleMessage + command + "\n"); + } + } catch (Throwable th) { + + } + + Runtime runtime = Runtime.getRuntime(); + + // runs the command + Process p = runtime.exec(command); + + // gets the input stream to have the post-compile-time information + InputStream stream = p.getInputStream(); + + // get the string from Stream + String consoleOutput = PHPConsole.getStringFromStream(stream); + + // prints out the information + if (console != null) { + console.write(consoleOutput); + } + return consoleOutput; + + } catch (IOException e) { + MessageDialog + .openInformation(null, "IOException: ", e.getMessage()); + } + return ""; + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java index 86f2b0a..6daa442 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPExternalParserAction.java @@ -22,7 +22,6 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; -import test.PHPParserSuperclass; public class PHPExternalParserAction implements IObjectActionDelegate { @@ -70,11 +69,11 @@ public class PHPExternalParserAction implements IObjectActionDelegate { // check if it's a file resource switch (resource.getType()) { - + case IResource.FILE : // single file: - IFile file = (IFile) resource; - PHPParserSuperclass.phpExternalParse(file); + ExternalPHPParser parser = new ExternalPHPParser((IFile)resource); + parser.phpExternalParse(); } } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java index f6ab554..72e579e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java @@ -11,8 +11,6 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.actions; -import java.io.IOException; -import java.io.InputStream; import java.text.MessageFormat; import net.sourceforge.phpdt.externaltools.launchConfigurations.ExternalToolsUtil; @@ -44,34 +42,6 @@ public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate { store.getBoolean(PHPeclipsePlugin.APACHE_START_BACKGROUND)); } - // public static void execute(String command, String consoleMessage) { - // // MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command); - // try { - // PHPConsole console = PHPConsole.getInstance(); - // console.write(consoleMessage + command + "\n"); - // Runtime runtime = Runtime.getRuntime(); - // - // // runs the command - // Process p = runtime.exec(command); - // - // if (PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE) == true) { - // - // OutputThread out = new OutputThread(p.getInputStream(), console); - // OutputThread err = new OutputThread(p.getErrorStream(), console); - // out.start(); - // err.start(); - // - // } - // - // } catch (IOException e) { - // - // System.err.println("Problem"); - // e.printStackTrace(); - // - // } - // - // } - /** * Executes an external progam and saves the LaunchConfiguration under external tools * @param command external tools command name @@ -106,74 +76,8 @@ public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate { console.write(consoleMessage + "\n"); ExternalToolsUtil.execute(command, executable, arguments, background); - // MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command); - // try { - // PHPConsole console = PHPConsole.getInstance(); - // console.write(consoleMessage + command + "\n"); - // - // ExternalToolsUtil.execute() - // Runtime runtime = Runtime.getRuntime(); - // - // // runs the command - // Process p = runtime.exec(command); - // - // // gets the input stream to have the post-compile-time information - // InputStream stream = p.getInputStream(); - // - // // get the string from Stream - // String consoleOutput = PHPConsole.getStringFromStream(stream); - // - // // prints out the information - // console.write(consoleOutput); - // return consoleOutput; - // - // } catch (IOException e) { - // - // System.err.println("Problem"); - // e.printStackTrace(); - // - // } - // return ""; - } - public static String getParserOutput(String command, String consoleMessage) { - // MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command); - try { - PHPConsole console = null; - try { - console = PHPConsole.getInstance(); - if (console != null) { - console.write(consoleMessage + command + "\n"); - } - } catch (Throwable th) { - - } - - Runtime runtime = Runtime.getRuntime(); - - // runs the command - Process p = runtime.exec(command); - - // gets the input stream to have the post-compile-time information - InputStream stream = p.getInputStream(); - - // get the string from Stream - String consoleOutput = PHPConsole.getStringFromStream(stream); - - // prints out the information - if (console != null) { - console.write(consoleOutput); - } - return consoleOutput; - - } catch (IOException e) { - - System.err.println("Problem"); - e.printStackTrace(); - - } - return ""; } - + public void selectionChanged(IAction action, ISelection selection) { } @@ -186,34 +90,4 @@ public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate { } - // static class OutputThread extends Thread { - // InputStream fInputStream; - // PHPConsole console; - // - // OutputThread(InputStream inputStream, PHPConsole console) { - // this.fInputStream = inputStream; - // this.console = console; - // } - // - // public void run() { - // try { - // BufferedReader bin = new BufferedReader(new InputStreamReader(fInputStream)); - // - // String bufferRow; - // while ((bufferRow = bin.readLine()) != null) { - // - // // prints out the information - // console.write( bufferRow ); - // - // } - // bin.close(); - // - // } catch (IOException e) { - // MessageDialog.openError(null, "Error in output", e.toString()); - // } finally { - // - // } - // } - // } - } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java deleted file mode 100644 index 6d9d031..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ /dev/null @@ -1,301 +0,0 @@ -package net.sourceforge.phpeclipse.phpeditor; - -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation - Klaus Hartlage - www.eclipseproject.de -**********************************************************************/ - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.TreeSet; - -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; -import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; -import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.BadPositionCategoryException; -import org.eclipse.jface.text.DefaultPositionUpdater; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IPositionUpdater; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; - -import test.PHPParserManager; -import test.PHPParserSuperclass; - -/** - * A content outline page which always represents the functions of the - * connected PHPEditor. - */ -public class PHPContentOutlinePage extends AbstractContentOutlinePage { - private static final String ERROR = "error"; //$NON-NLS-1$ - private static final String WARNING = "warning"; //$NON-NLS-1$ - - protected static class SegmentComparator implements Comparator { - public int compare(Object o1, Object o2) { - if (o1 instanceof OutlineableWithChildren && !(o2 instanceof OutlineableWithChildren)) { - return 1; - } - if (o2 instanceof OutlineableWithChildren && !(o1 instanceof OutlineableWithChildren)) { - return -1; - } - return ((Outlineable) o1).toString().compareToIgnoreCase(((Outlineable) o2).toString()); - } - } - - /** - * Divides the editor's document into ten segments and provides elements for them. - */ - protected class ContentProvider implements ITreeContentProvider { - - protected final static String SEGMENTS = "__php_segments"; //$NON-NLS-1$ - protected IPositionUpdater fPositionUpdater = new DefaultPositionUpdater(SEGMENTS); - protected List fContent = new ArrayList(10); - protected TreeSet fVariables = new TreeSet(); - - // private String getIdentifier(String text, int firstIndex) { - // int i = firstIndex; - // char c; - // int textLength = text.length(); - // StringBuffer identifier = new StringBuffer(); - // while (i < textLength) { - // c = text.charAt(i++); - // if (Scanner.isPHPIdentifierPart(c) || (c == '$')) { - // identifier.append(c); - // } else if ((i == firstIndex + 1) && (c == '$')) { - // identifier.append(c); - // } else { - // return identifier.toString(); - // } - // } - // return null; - // } - - protected void parse(IDocument document) { - - // int lines = document.getNumberOfLines(); - // int increment = Math.max(Math.round((float) (lines / 10)), 10); - - String name; - int index; - String text = document.get(); - PHPParserSuperclass parser = PHPParserManager.getParser(null); - - PHPOutlineInfo outlineInfo = parser.parseInfo(fInput, text); - fVariables = outlineInfo.getVariables(); - - OutlineableWithChildren declarations = outlineInfo.getDeclarations(); - Outlineable temp; - for (int i = 0; i < declarations.size(); i++) { - temp = declarations.get(i); - fContent.add(temp); - } - Collections.sort(fContent, new SegmentComparator()); - } - - /* - * @see IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (oldInput != null) { - IDocument document = fDocumentProvider.getDocument(oldInput); - if (document != null) { - try { - document.removePositionCategory(SEGMENTS); - } catch (BadPositionCategoryException x) { - } - document.removePositionUpdater(fPositionUpdater); - } - } - - fContent.clear(); - fVariables.clear(); - - if (newInput != null) { - IDocument document = fDocumentProvider.getDocument(newInput); - if (document != null) { - document.addPositionCategory(SEGMENTS); - document.addPositionUpdater(fPositionUpdater); - - parse(document); - } - } - } - - /* - * @see IContentProvider#dispose - */ - public void dispose() { - if (fContent != null) { - fContent.clear(); - fContent = null; - } - if (fVariables != null) { - fVariables.clear(); - fVariables = null; - } - } - - /* - * @see IContentProvider#isDeleted(Object) - */ - public boolean isDeleted(Object element) { - return false; - } - - /** - * returns all PHP variables - */ - public Object[] getVariables() { - return fVariables.toArray(); - } - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object element) { - return fContent.toArray(); - } - - /* - * @see ITreeContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) { - if (element instanceof OutlineableWithChildren) { - return !((OutlineableWithChildren) element).getList().isEmpty(); - } - return element == fInput; - } - - /* - * @see ITreeContentProvider#getParent(Object) - */ - public Object getParent(Object element) { - if (element instanceof Outlineable) { - return ((Outlineable) element).getParent(); - } - return null; - } - - /* - * @see ITreeContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object element) { - if (element == fInput) - return fContent.toArray(); - if (element instanceof OutlineableWithChildren) - return ((OutlineableWithChildren) element).getList().toArray(); - return new Object[0]; - } - }; - - protected class OutlineLabelProvider extends LabelProvider { - private ImageDescriptorRegistry fRegistry; - - public OutlineLabelProvider() { - fRegistry = PHPeclipsePlugin.getImageDescriptorRegistry(); - } - /** - * The LabelProvider implementation of this - * ILabelProvider method returns null. Subclasses may - * override. - */ - public Image getImage(Object element) { - if (element instanceof Outlineable) { - ImageDescriptor descriptor = ((Outlineable) element).getImage(); - return fRegistry.get(descriptor); - } - return null; - } - } - - protected IDocumentProvider fDocumentProvider; - protected ITextEditor fTextEditor; - protected PHPEditor fEditor; - protected ContentProvider fContentProvider; - - /** - * Creates a content outline page using the given provider and the given editor. - */ - public PHPContentOutlinePage(IDocumentProvider provider, ITextEditor editor) { - super(); - fContentProvider = null; - fDocumentProvider = provider; - fTextEditor = editor; - if (editor instanceof PHPEditor) - fEditor = (PHPEditor) editor; - } - - /* (non-Javadoc) - * Method declared on ContentOutlinePage - */ - public void createControl(Composite parent) { - - super.createControl(parent); - - TreeViewer viewer = getTreeViewer(); - - fContentProvider = new ContentProvider(); - viewer.setContentProvider(fContentProvider); - viewer.setLabelProvider(new OutlineLabelProvider()); - - viewer.addSelectionChangedListener(this); - - if (fInput != null) - viewer.setInput(fInput); - } - - /* (non-Javadoc) - * Method declared on ContentOutlinePage - */ - public void selectionChanged(SelectionChangedEvent event) { - - super.selectionChanged(event); - - ISelection selection = event.getSelection(); - if (selection.isEmpty()) - fTextEditor.resetHighlightRange(); - else { - Outlineable segment = (Outlineable) ((IStructuredSelection) selection).getFirstElement(); - int start = segment.getPosition().getOffset(); - int length = segment.getPosition().getLength(); - try { - fTextEditor.setHighlightRange(start, length, true); - } catch (IllegalArgumentException x) { - fTextEditor.resetHighlightRange(); - } - } - } - - public Object[] getVariables() { - if (fContentProvider != null) { - return fContentProvider.getVariables(); - } - return null; - } - // public ContentProvider getContentProvider() { - // return contentProvider; - // } - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java index 1fdfc76..38534c7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java @@ -21,6 +21,7 @@ import java.util.List; import net.sourceforge.phpdt.internal.compiler.util.Util; import net.sourceforge.phpdt.internal.core.builder.PHPBuilder; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.actions.ExternalPHPParser; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; @@ -30,8 +31,7 @@ import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; -import test.PHPParserManager; -import test.PHPParserSuperclass; +//import test.PHPParserManager; /** * ClassDeclaration that defines the action for parsing the current PHP file @@ -101,7 +101,8 @@ public class PHPParserAction extends TextEditorAction { // } catch (IOException e) { // } } else { - PHPParserSuperclass.phpExternalParse(fileToParse); + ExternalPHPParser parser = new ExternalPHPParser(fileToParse); + parser.phpExternalParse(); } } // } catch (CoreException e) { @@ -126,65 +127,17 @@ public class PHPParserAction extends TextEditorAction { return null; } - /** - * Create marker for the parse error - */ - // protected void setMarker(String message, int lineNumber) throws CoreException { - // - // Hashtable attributes = new Hashtable(); - // MarkerUtilities.setMessage(attributes, message); - // if (message.startsWith(ERROR)) - // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - // else if (message.startsWith(WARNING)) - // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - // else - // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - // MarkerUtilities.setLineNumber(attributes, lineNumber); - // MarkerUtilities.createMarker(fileToParse, attributes, IMarker.PROBLEM); - // } - - // private String getIdentifier(InputStream iStream, int c) { - // // int i = 0; - // // char c; - // // int textLength = text.length(); - // StringBuffer identifier = new StringBuffer(); - // identifier.append((char) c); - // try { - // while ((c = iStream.read()) != (-1)) { - // if (Scanner.isPHPIdentifierPart((char) c)) { - // identifier.append((char) c); - // // } else if ((i == 0) && (c == '$')) { - // // identifier.append((char)c); - // } else { - // return identifier.toString(); - // } - // // i++; - // } - // } catch (IOException e) { - // } - // return identifier.toString(); - // } + + protected static void parse(IFile fileToParse) { - - // StringBuffer buf = new StringBuffer(); - // int c0; - // try { - // while ((c0 = iStream.read()) != (-1)) { - // buf.append((char) c0); - // } - // } catch (IOException e) { - // return; - // } - // String input = buf.toString(); - InputStream stream = null; char[] charArray; try { stream = new BufferedInputStream(fileToParse.getContents()); charArray = Util.getInputStreamAsCharArray(stream, -1, null); - PHPParserSuperclass parser = PHPParserManager.getParser(fileToParse); - parser.parse(new String(charArray)); + ExternalPHPParser parser = new ExternalPHPParser(fileToParse); + parser.phpExternalParse(); } catch (CoreException e) { } catch (IOException e) { } finally { diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java deleted file mode 100644 index 958f0e2..0000000 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ /dev/null @@ -1,7556 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. PHPParser.java */ -package test; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ui.texteditor.MarkerUtilities; -import org.eclipse.jface.preference.IPreferenceStore; - -import java.util.Hashtable; -import java.util.ArrayList; -import java.io.StringReader; -import java.io.*; -import java.text.MessageFormat; - -import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpdt.internal.compiler.ast.*; -import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; -import net.sourceforge.phpdt.internal.corext.Assert; - -/** - * A new php parser. - * This php parser is inspired by the Java 1.2 grammar example - * given with JavaCC. You can get JavaCC at http://www.webgain.com - * You can test the parser with the PHPParserTestCase2.java - * @author Matthieu Casanova - */ -public final class PHPParser extends PHPParserSuperclass implements PHPParserConstants { - -//todo : fix the variables names bug -//todo : handle tilde operator - - - /** The current segment. */ - private static OutlineableWithChildren currentSegment; - - private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$ - private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ - static PHPOutlineInfo outlineInfo; - - /** The error level of the current ParseException. */ - private static int errorLevel = ERROR; - /** The message of the current ParseException. If it's null it's because the parse exception wasn't handled */ - private static String errorMessage; - - private static int errorStart = -1; - private static int errorEnd = -1; - private static PHPDocument phpDocument; - - private static final String SYNTAX_ERROR_CHAR = "syntax error"; - /** - * The point where html starts. - * It will be used by the token manager to create HTMLCode objects - */ - public static int htmlStart; - - //ast stack - private final static int AstStackIncrement = 100; - /** The stack of node. */ - private static AstNode[] nodes; - /** The cursor in expression stack. */ - private static int nodePtr; - - public static final boolean PARSER_DEBUG = false; - - public final void setFileToParse(final IFile fileToParse) { - PHPParser.fileToParse = fileToParse; - } - - public PHPParser() { - } - - public PHPParser(final IFile fileToParse) { - this(new StringReader("")); - PHPParser.fileToParse = fileToParse; - } - - public final void phpParserTester(final String strEval) throws ParseException { - final StringReader stream = new StringReader(strEval); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(new StringReader(strEval)); - init(); - phpDocument = new PHPDocument(null,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(null, currentSegment); - token_source.SwitchTo(PHPParserTokenManager.PHPPARSING); - phpTest(); - } - - public final void htmlParserTester(final File fileName) throws FileNotFoundException, ParseException { - final Reader stream = new FileReader(fileName); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - phpDocument = new PHPDocument(null,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(null, currentSegment); - phpFile(); - } - - public final void htmlParserTester(final String strEval) throws ParseException { - final StringReader stream = new StringReader(strEval); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - phpDocument = new PHPDocument(null,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(null, currentSegment); - phpFile(); - } - - /** - * Reinitialize the parser. - */ - private static final void init() { - nodes = new AstNode[AstStackIncrement]; - nodePtr = -1; - htmlStart = 0; - } - - /** - * Add an php node on the stack. - * @param node the node that will be added to the stack - */ - private static final void pushOnAstNodes(final AstNode node) { - try { - nodes[++nodePtr] = node; - } catch (IndexOutOfBoundsException e) { - final int oldStackLength = nodes.length; - final AstNode[] oldStack = nodes; - nodes = new AstNode[oldStackLength + AstStackIncrement]; - System.arraycopy(oldStack, 0, nodes, 0, oldStackLength); - nodePtr = oldStackLength; - nodes[nodePtr] = node; - } - } - - public final PHPOutlineInfo parseInfo(final Object parent, final String s) { - phpDocument = new PHPDocument(parent,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(parent, currentSegment); - final StringReader stream = new StringReader(s); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - try { - parse(); - phpDocument.nodes = new AstNode[nodes.length]; - System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); - if (PHPeclipsePlugin.DEBUG) { - PHPeclipsePlugin.log(1,phpDocument.toString()); - } - } catch (ParseException e) { - processParseException(e); - } - return outlineInfo; - } - - /** - * This function will throw the exception if we are in debug mode - * and process it if we are in production mode. - * this should be fast since the PARSER_DEBUG is static final so the difference will be at compile time - * @param e the exception - * @throws ParseException the thrown exception - */ - private static void processParseExceptionDebug(final ParseException e) throws ParseException { - if (PARSER_DEBUG) { - throw e; - } - processParseException(e); - } - /** - * This method will process the parse exception. - * If the error message is null, the parse exception wasn't catched and a trace is written in the log - * @param e the ParseException - */ - private static void processParseException(final ParseException e) { - if (errorMessage == null) { - PHPeclipsePlugin.log(e); - errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it"; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - } - setMarker(e); - errorMessage = null; - // if (PHPeclipsePlugin.DEBUG) PHPeclipsePlugin.log(e); - } - - /** - * Create marker for the parse error. - * @param e the ParseException - */ - private static void setMarker(final ParseException e) { - try { - if (errorStart == -1) { - setMarker(fileToParse, - errorMessage, - e.currentToken.sourceStart, - e.currentToken.sourceEnd, - errorLevel, - "Line " + e.currentToken.beginLine+", "+e.currentToken.sourceStart+':'+e.currentToken.sourceEnd); - } else { - setMarker(fileToParse, - errorMessage, - errorStart, - errorEnd, - errorLevel, - "Line " + e.currentToken.beginLine+", "+errorStart+':'+errorEnd); - errorStart = -1; - errorEnd = -1; - } - } catch (CoreException e2) { - PHPeclipsePlugin.log(e2); - } - } - - private static void scanLine(final String output, - final IFile file, - final int indx, - final int brIndx) throws CoreException { - String current; - final StringBuffer lineNumberBuffer = new StringBuffer(10); - char ch; - current = output.substring(indx, brIndx); - - if (current.indexOf(PARSE_WARNING_STRING) != -1 || current.indexOf(PARSE_ERROR_STRING) != -1) { - final int onLine = current.indexOf("on line "); - if (onLine != -1) { - lineNumberBuffer.delete(0, lineNumberBuffer.length()); - for (int i = onLine; i < current.length(); i++) { - ch = current.charAt(i); - if ('0' <= ch && '9' >= ch) { - lineNumberBuffer.append(ch); - } - } - - final int lineNumber = Integer.parseInt(lineNumberBuffer.toString()); - - final Hashtable attributes = new Hashtable(); - - current = current.replaceAll("\n", ""); - current = current.replaceAll("", ""); - current = current.replaceAll("", ""); - MarkerUtilities.setMessage(attributes, current); - - if (current.indexOf(PARSE_ERROR_STRING) != -1) - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - else if (current.indexOf(PARSE_WARNING_STRING) != -1) - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - else - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - MarkerUtilities.setLineNumber(attributes, lineNumber); - MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); - } - } - } - - public final void parse(final String s) { - final StringReader stream = new StringReader(s); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - try { - parse(); - } catch (ParseException e) { - processParseException(e); - } - } - - /** - * Call the php parse command ( php -l -f <filename> ) - * and create markers according to the external parser output - */ - public static void phpExternalParse(final IFile file) { - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - final String filename = file.getLocation().toString(); - - final String[] arguments = { filename }; - final MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF)); - final String command = form.format(arguments); - - final String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: "); - - try { - // parse the buffer to find the errors and warnings - createMarkers(parserResult, file); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - } - } - - /** - * Put a new html block in the stack. - */ - public final void createNewHTMLCode() { - final int currentPosition = token.sourceStart; - if (currentPosition == htmlStart || - currentPosition < htmlStart || - currentPosition > jj_input_stream.getCurrentBuffer().length()) { - return; - } - final String html = jj_input_stream.getCurrentBuffer().substring(htmlStart, currentPosition); - pushOnAstNodes(new HTMLCode(html, htmlStart,currentPosition)); - } - - /** Create a new task. */ - public final void createNewTask(final int todoStart) { - final String todo = jj_input_stream.getCurrentBuffer().substring(todoStart, - jj_input_stream.getCurrentBuffer().indexOf("\n", - todoStart)-1); - if (!PARSER_DEBUG) { - try { - setMarker(fileToParse, - todo, - jj_input_stream.getBeginLine(), - TASK, - "Line "+jj_input_stream.getBeginLine()); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - } - } - } - - private final void parse() throws ParseException { - phpFile(); - } - - final public void todo() throws ParseException { - Token todoToken; - todoToken = jj_consume_token(23); - createNewTask(todoToken.sourceStart); - } - - final public void phpTest() throws ParseException { - Php(); - jj_consume_token(0); - } - - final public void phpFile() throws ParseException { - try { - label_1: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PHPSTARTSHORT: - case PHPSTARTLONG: - case PHPECHOSTART: - case PHPEND: - case CLASS: - case FUNCTION: - case IF: - case ARRAY: - case BREAK: - case LIST: - case PRINT: - case ECHO: - case INCLUDE: - case REQUIRE: - case INCLUDE_ONCE: - case REQUIRE_ONCE: - case GLOBAL: - case DEFINE: - case STATIC: - case CONTINUE: - case DO: - case FOR: - case NEW: - case NULL: - case RETURN: - case SWITCH: - case TRUE: - case FALSE: - case WHILE: - case FOREACH: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - ; - break; - default: - jj_la1[0] = jj_gen; - break label_1; - } - PhpBlock(); - } - createNewHTMLCode(); - } catch (TokenMgrError e) { - PHPeclipsePlugin.log(e); - errorStart = jj_input_stream.getBeginOffset(); - errorEnd = jj_input_stream.getEndOffset(); - errorMessage = e.getMessage(); - errorLevel = ERROR; - {if (true) throw generateParseException();} - } - } - -/** - * A php block is a - * or - * or - */ - final public void PhpBlock() throws ParseException { - final PHPEchoBlock phpEchoBlock; - final Token token,phpEnd; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PHPECHOSTART: - phpEchoBlock = phpEchoBlock(); - pushOnAstNodes(phpEchoBlock); - break; - case PHPSTARTSHORT: - case PHPSTARTLONG: - case PHPEND: - case CLASS: - case FUNCTION: - case IF: - case ARRAY: - case BREAK: - case LIST: - case PRINT: - case ECHO: - case INCLUDE: - case REQUIRE: - case INCLUDE_ONCE: - case REQUIRE_ONCE: - case GLOBAL: - case DEFINE: - case STATIC: - case CONTINUE: - case DO: - case FOR: - case NEW: - case NULL: - case RETURN: - case SWITCH: - case TRUE: - case FALSE: - case WHILE: - case FOREACH: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PHPSTARTSHORT: - case PHPSTARTLONG: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PHPSTARTLONG: - jj_consume_token(PHPSTARTLONG); - break; - case PHPSTARTSHORT: - token = jj_consume_token(PHPSTARTSHORT); - try { - setMarker(fileToParse, - "You should use '' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - break; - default: - jj_la1[3] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public PHPEchoBlock phpEchoBlock() throws ParseException { - final Expression expr; - final PHPEchoBlock echoBlock; - final Token token, token2; - token = jj_consume_token(PHPECHOSTART); - createNewHTMLCode(); - expr = Expression(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SEMICOLON: - jj_consume_token(SEMICOLON); - break; - default: - jj_la1[4] = jj_gen; - ; - } - token2 = jj_consume_token(PHPEND); - htmlStart = token2.sourceEnd; - - echoBlock = new PHPEchoBlock(expr,token.sourceStart,token2.sourceEnd); - pushOnAstNodes(echoBlock); - {if (true) return echoBlock;} - throw new Error("Missing return statement in function"); - } - - final public void Php() throws ParseException { - label_2: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CLASS: - case FUNCTION: - case IF: - case ARRAY: - case BREAK: - case LIST: - case PRINT: - case ECHO: - case INCLUDE: - case REQUIRE: - case INCLUDE_ONCE: - case REQUIRE_ONCE: - case GLOBAL: - case DEFINE: - case STATIC: - case CONTINUE: - case DO: - case FOR: - case NEW: - case NULL: - case RETURN: - case SWITCH: - case TRUE: - case FALSE: - case WHILE: - case FOREACH: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - ; - break; - default: - jj_la1[5] = jj_gen; - break label_2; - } - BlockStatement(); - } - } - - final public ClassDeclaration ClassDeclaration() throws ParseException { - final ClassDeclaration classDeclaration; - Token className = null; - final Token superclassName, token, extendsToken; - String classNameImage = SYNTAX_ERROR_CHAR; - String superclassNameImage = null; - final int classEnd; - token = jj_consume_token(CLASS); - try { - className = jj_consume_token(IDENTIFIER); - classNameImage = className.image; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; - errorLevel = ERROR; - errorStart = token.sourceEnd+1; - errorEnd = token.sourceEnd+1; - processParseExceptionDebug(e); - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case EXTENDS: - extendsToken = jj_consume_token(EXTENDS); - try { - superclassName = jj_consume_token(IDENTIFIER); - superclassNameImage = superclassName.image; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; - errorLevel = ERROR; - errorStart = extendsToken.sourceEnd+1; - errorEnd = extendsToken.sourceEnd+1; - processParseExceptionDebug(e); - superclassNameImage = SYNTAX_ERROR_CHAR; - } - break; - default: - jj_la1[6] = jj_gen; - ; - } - int start, end; - if (className == null) { - start = token.sourceStart; - end = token.sourceEnd; - } else { - start = className.sourceStart; - end = className.sourceEnd; - } - if (superclassNameImage == null) { - - classDeclaration = new ClassDeclaration(currentSegment, - classNameImage, - start, - end); - } else { - classDeclaration = new ClassDeclaration(currentSegment, - classNameImage, - superclassNameImage, - start, - end); - } - currentSegment.add(classDeclaration); - currentSegment = classDeclaration; - classEnd = ClassBody(classDeclaration); - currentSegment = (OutlineableWithChildren) currentSegment.getParent(); - classDeclaration.sourceEnd = classEnd; - pushOnAstNodes(classDeclaration); - {if (true) return classDeclaration;} - throw new Error("Missing return statement in function"); - } - - final public int ClassBody(final ClassDeclaration classDeclaration) throws ParseException { -Token token; - try { - jj_consume_token(LBRACE); - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image + "'. '{' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - label_3: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUNCTION: - case VAR: - ; - break; - default: - jj_la1[7] = jj_gen; - break label_3; - } - ClassBodyDeclaration(classDeclaration); - } - try { - token = jj_consume_token(RBRACE); - {if (true) return token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. 'var', 'function' or '}' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - {if (true) return this.token.sourceEnd;} - } - throw new Error("Missing return statement in function"); - } - -/** - * A class can contain only methods and fields. - */ - final public void ClassBodyDeclaration(final ClassDeclaration classDeclaration) throws ParseException { - final MethodDeclaration method; - final FieldDeclaration field; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUNCTION: - method = MethodDeclaration(); - method.analyzeCode(); - classDeclaration.addMethod(method); - break; - case VAR: - field = FieldDeclaration(); - classDeclaration.addField(field); - break; - default: - jj_la1[8] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - -/** - * A class field declaration : it's var VariableDeclarator() (, VariableDeclarator())*;. - * it is only used by ClassBodyDeclaration() - */ - final public FieldDeclaration FieldDeclaration() throws ParseException { - VariableDeclaration variableDeclaration; - final VariableDeclaration[] list; - final ArrayList arrayList = new ArrayList(); - final Token token; - Token token2 = null; - int pos; - token = jj_consume_token(VAR); - variableDeclaration = VariableDeclaratorNoSuffix(); - arrayList.add(variableDeclaration); - pos = variableDeclaration.sourceEnd; - label_4: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[9] = jj_gen; - break label_4; - } - jj_consume_token(COMMA); - variableDeclaration = VariableDeclaratorNoSuffix(); - arrayList.add(variableDeclaration); - outlineInfo.addVariable(variableDeclaration.name()); - pos = variableDeclaration.sourceEnd; - } - try { - token2 = jj_consume_token(SEMICOLON); - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected after variable declaration"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseExceptionDebug(e); - } - list = new VariableDeclaration[arrayList.size()]; - arrayList.toArray(list); - int end; - if (token2 == null) { - end = list[list.length-1].sourceEnd; - } else { - end = token2.sourceEnd; - } - {if (true) return new FieldDeclaration(list, - token.sourceStart, - end, - currentSegment);} - throw new Error("Missing return statement in function"); - } - -/** - * a strict variable declarator : there cannot be a suffix here. - * It will be used by fields and formal parameters - */ - final public VariableDeclaration VariableDeclaratorNoSuffix() throws ParseException { - final Token token, lbrace,rbrace; - Expression expr, initializer = null; - Token assignToken; - Variable variable; - jj_consume_token(DOLLAR); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IDENTIFIER: - token = jj_consume_token(IDENTIFIER); - variable = new Variable(token.image,token.sourceStart,token.sourceEnd); - break; - case LBRACE: - lbrace = jj_consume_token(LBRACE); - expr = Expression(); - rbrace = jj_consume_token(RBRACE); - variable = new Variable(expr,lbrace.sourceStart,rbrace.sourceEnd); - break; - default: - jj_la1[10] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ASSIGN: - assignToken = jj_consume_token(ASSIGN); - try { - initializer = VariableInitializer(); - } catch (ParseException e) { - errorMessage = "Literal expression expected in variable initializer"; - errorLevel = ERROR; - errorStart = assignToken.sourceEnd +1; - errorEnd = assignToken.sourceEnd +1; - processParseExceptionDebug(e); - } - break; - default: - jj_la1[11] = jj_gen; - ; - } - if (initializer == null) { - {if (true) return new VariableDeclaration(currentSegment, - variable, - variable.sourceStart, - variable.sourceEnd);} - } - {if (true) return new VariableDeclaration(currentSegment, - variable, - initializer, - VariableDeclaration.EQUAL, - variable.sourceStart);} - throw new Error("Missing return statement in function"); - } - -/** - * this will be used by static statement - */ - final public VariableDeclaration VariableDeclarator() throws ParseException { - final AbstractVariable variable; - Expression initializer = null; - final Token token; - variable = VariableDeclaratorId(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ASSIGN: - token = jj_consume_token(ASSIGN); - try { - initializer = VariableInitializer(); - } catch (ParseException e) { - errorMessage = "Literal expression expected in variable initializer"; - errorLevel = ERROR; - errorStart = token.sourceEnd+1; - errorEnd = token.sourceEnd+1; - processParseExceptionDebug(e); - } - break; - default: - jj_la1[12] = jj_gen; - ; - } - if (initializer == null) { - {if (true) return new VariableDeclaration(currentSegment, - variable, - variable.sourceStart, - variable.sourceEnd);} - } - {if (true) return new VariableDeclaration(currentSegment, - variable, - initializer, - VariableDeclaration.EQUAL, - variable.sourceStart);} - throw new Error("Missing return statement in function"); - } - -/** - * A Variable name. - * @return the variable name (with suffix) - */ - final public AbstractVariable VariableDeclaratorId() throws ParseException { - AbstractVariable var; - try { - var = Variable(); - label_5: - while (true) { - if (jj_2_1(2)) { - ; - } else { - break label_5; - } - var = VariableSuffix(var); - } - {if (true) return var;} - } catch (ParseException e) { - errorMessage = "'$' expected for variable identifier"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - {if (true) throw e;} - } - throw new Error("Missing return statement in function"); - } - - final public Variable Variable() throws ParseException { - Variable variable = null; - final Token token; - token = jj_consume_token(DOLLAR); - variable = Var(); - {if (true) return variable;} - throw new Error("Missing return statement in function"); - } - - final public Variable Var() throws ParseException { - Variable variable = null; - final Token token,token2; - ConstantIdentifier constant; - Expression expression; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case DOLLAR: - token = jj_consume_token(DOLLAR); - variable = Var(); - {if (true) return new Variable(variable,variable.sourceStart,variable.sourceEnd);} - break; - case LBRACE: - token = jj_consume_token(LBRACE); - expression = Expression(); - token2 = jj_consume_token(RBRACE); - {if (true) return new Variable(expression, - token.sourceStart, - token2.sourceEnd);} - break; - case IDENTIFIER: - token = jj_consume_token(IDENTIFIER); - outlineInfo.addVariable('$' + token.image); - {if (true) return new Variable(token.image,token.sourceStart,token.sourceEnd);} - break; - default: - jj_la1[13] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression VariableInitializer() throws ParseException { - final Expression expr; - final Token token, token2; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NULL: - case TRUE: - case FALSE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - expr = Literal(); - {if (true) return expr;} - break; - case MINUS: - token2 = jj_consume_token(MINUS); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INTEGER_LITERAL: - token = jj_consume_token(INTEGER_LITERAL); - break; - case FLOATING_POINT_LITERAL: - token = jj_consume_token(FLOATING_POINT_LITERAL); - break; - default: - jj_la1[14] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - {if (true) return new PrefixedUnaryExpression(new NumberLiteral(token), - OperatorIds.MINUS, - token2.sourceStart);} - break; - case PLUS: - token2 = jj_consume_token(PLUS); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INTEGER_LITERAL: - token = jj_consume_token(INTEGER_LITERAL); - break; - case FLOATING_POINT_LITERAL: - token = jj_consume_token(FLOATING_POINT_LITERAL); - break; - default: - jj_la1[15] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - {if (true) return new PrefixedUnaryExpression(new NumberLiteral(token), - OperatorIds.PLUS, - token2.sourceStart);} - break; - case ARRAY: - expr = ArrayDeclarator(); - {if (true) return expr;} - break; - case IDENTIFIER: - token = jj_consume_token(IDENTIFIER); - {if (true) return new ConstantIdentifier(token);} - break; - default: - jj_la1[16] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public ArrayVariableDeclaration ArrayVariable() throws ParseException { -final Expression expr,expr2; - expr = Expression(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAYASSIGN: - jj_consume_token(ARRAYASSIGN); - expr2 = Expression(); - {if (true) return new ArrayVariableDeclaration(expr,expr2);} - break; - default: - jj_la1[17] = jj_gen; - ; - } - {if (true) return new ArrayVariableDeclaration(expr,jj_input_stream.getPosition());} - throw new Error("Missing return statement in function"); - } - - final public ArrayVariableDeclaration[] ArrayInitializer() throws ParseException { - ArrayVariableDeclaration expr; - final ArrayList list = new ArrayList(); - jj_consume_token(LPAREN); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case LIST: - case PRINT: - case NEW: - case NULL: - case TRUE: - case FALSE: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - expr = ArrayVariable(); - list.add(expr); - label_6: - while (true) { - if (jj_2_2(2)) { - ; - } else { - break label_6; - } - jj_consume_token(COMMA); - expr = ArrayVariable(); - list.add(expr); - } - break; - default: - jj_la1[18] = jj_gen; - ; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - list.add(null); - break; - default: - jj_la1[19] = jj_gen; - ; - } - jj_consume_token(RPAREN); - final ArrayVariableDeclaration[] vars = new ArrayVariableDeclaration[list.size()]; - list.toArray(vars); - {if (true) return vars;} - throw new Error("Missing return statement in function"); - } - -/** - * A Method Declaration. - * function MetodDeclarator() Block() - */ - final public MethodDeclaration MethodDeclaration() throws ParseException { - final MethodDeclaration functionDeclaration; - final Block block; - final OutlineableWithChildren seg = currentSegment; - final Token token; - token = jj_consume_token(FUNCTION); - try { - functionDeclaration = MethodDeclarator(token.sourceStart); - outlineInfo.addVariable(functionDeclaration.name); - } catch (ParseException e) { - if (errorMessage != null) {if (true) throw e;} - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - {if (true) throw e;} - } - currentSegment = functionDeclaration; - block = Block(); - functionDeclaration.statements = block.statements; - currentSegment = seg; - {if (true) return functionDeclaration;} - throw new Error("Missing return statement in function"); - } - -/** - * A MethodDeclarator. - * [&] IDENTIFIER(parameters ...). - * @return a function description for the outline - */ - final public MethodDeclaration MethodDeclarator(final int start) throws ParseException { - Token identifier = null; - Token reference = null; - final ArrayList formalParameters = new ArrayList(); - String identifierChar = SYNTAX_ERROR_CHAR; - int end = start; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BIT_AND: - reference = jj_consume_token(BIT_AND); - end = reference.sourceEnd; - break; - default: - jj_la1[20] = jj_gen; - ; - } - try { - identifier = jj_consume_token(IDENTIFIER); - identifierChar = identifier.image; - end = identifier.sourceEnd; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceEnd; - errorEnd = e.currentToken.next.sourceStart; - processParseExceptionDebug(e); - } - end = FormalParameters(formalParameters); - int nameStart, nameEnd; - if (identifier == null) { - if (reference == null) { - nameStart = start + 9; - nameEnd = start + 10; - } else { - nameStart = reference.sourceEnd + 1; - nameEnd = reference.sourceEnd + 2; - } - } else { - nameStart = identifier.sourceStart; - nameEnd = identifier.sourceEnd; - } - {if (true) return new MethodDeclaration(currentSegment, - identifierChar, - formalParameters, - reference != null, - nameStart, - nameEnd, - start, - end);} - throw new Error("Missing return statement in function"); - } - -/** - * FormalParameters follows method identifier. - * (FormalParameter()) - */ - final public int FormalParameters(final ArrayList parameters) throws ParseException { - VariableDeclaration var; - final Token token; - Token tok = this.token; - int end = tok.sourceEnd; - try { - tok = jj_consume_token(LPAREN); - end = tok.sourceEnd; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier"; - errorLevel = ERROR; - errorStart = e.currentToken.next.sourceStart; - errorEnd = e.currentToken.next.sourceEnd; - processParseExceptionDebug(e); - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BIT_AND: - case DOLLAR: - var = FormalParameter(); - parameters.add(var);end = var.sourceEnd; - label_7: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[21] = jj_gen; - break label_7; - } - jj_consume_token(COMMA); - var = FormalParameter(); - parameters.add(var);end = var.sourceEnd; - } - break; - default: - jj_la1[22] = jj_gen; - ; - } - try { - token = jj_consume_token(RPAREN); - end = token.sourceEnd; - } catch (ParseException e) { - errorMessage = "')' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.next.sourceStart; - errorEnd = e.currentToken.next.sourceEnd; - processParseExceptionDebug(e); - } - {if (true) return end;} - throw new Error("Missing return statement in function"); - } - -/** - * A formal parameter. - * $varname[=value] (,$varname[=value]) - */ - final public VariableDeclaration FormalParameter() throws ParseException { - final VariableDeclaration variableDeclaration; - Token token = null; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BIT_AND: - token = jj_consume_token(BIT_AND); - break; - default: - jj_la1[23] = jj_gen; - ; - } - variableDeclaration = VariableDeclaratorNoSuffix(); - outlineInfo.addVariable('$'+variableDeclaration.name()); - if (token != null) { - variableDeclaration.setReference(true); - } - {if (true) return variableDeclaration;} - throw new Error("Missing return statement in function"); - } - - final public ConstantIdentifier Type() throws ParseException { - final Token token; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case STRING: - token = jj_consume_token(STRING); - {if (true) return new ConstantIdentifier(token);} - break; - case BOOL: - token = jj_consume_token(BOOL); - {if (true) return new ConstantIdentifier(token);} - break; - case BOOLEAN: - token = jj_consume_token(BOOLEAN); - {if (true) return new ConstantIdentifier(token);} - break; - case REAL: - token = jj_consume_token(REAL); - {if (true) return new ConstantIdentifier(token);} - break; - case DOUBLE: - token = jj_consume_token(DOUBLE); - {if (true) return new ConstantIdentifier(token);} - break; - case FLOAT: - token = jj_consume_token(FLOAT); - {if (true) return new ConstantIdentifier(token);} - break; - case INT: - token = jj_consume_token(INT); - {if (true) return new ConstantIdentifier(token);} - break; - case INTEGER: - token = jj_consume_token(INTEGER); - {if (true) return new ConstantIdentifier(token);} - break; - case OBJECT: - token = jj_consume_token(OBJECT); - {if (true) return new ConstantIdentifier(token);} - break; - default: - jj_la1[24] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression Expression() throws ParseException { - final Expression expr; - Expression initializer = null; - int assignOperator = -1; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case NEW: - case NULL: - case TRUE: - case FALSE: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - expr = ConditionalExpression(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ASSIGN: - case PLUSASSIGN: - case MINUSASSIGN: - case STARASSIGN: - case SLASHASSIGN: - case ANDASSIGN: - case ORASSIGN: - case XORASSIGN: - case DOTASSIGN: - case REMASSIGN: - case TILDEEQUAL: - case LSHIFTASSIGN: - case RSIGNEDSHIFTASSIGN: - assignOperator = AssignmentOperator(); - try { - initializer = Expression(); - } catch (ParseException e) { - if (errorMessage != null) { - {if (true) throw e;} - } - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorEnd = jj_input_stream.getPosition(); - {if (true) throw e;} - } - break; - default: - jj_la1[25] = jj_gen; - ; - } - if (assignOperator != -1) {// todo : change this, very very bad :( - if (expr instanceof AbstractVariable) { - {if (true) return new VariableDeclaration(currentSegment, - (AbstractVariable) expr, - initializer, - expr.sourceStart, - initializer.sourceEnd);} - } - String varName = expr.toStringExpression().substring(1); - {if (true) return new VariableDeclaration(currentSegment, - new Variable(varName, - expr.sourceStart, - expr.sourceEnd), - expr.sourceStart, - initializer.sourceEnd);} - } - {if (true) return expr;} - break; - case LIST: - case PRINT: - expr = ExpressionWBang(); - {if (true) return expr;} - break; - default: - jj_la1[26] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression ExpressionWBang() throws ParseException { - final Expression expr; - final Token token; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BANG: - token = jj_consume_token(BANG); - expr = ExpressionWBang(); - {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.NOT,token.sourceStart);} - break; - case LIST: - case PRINT: - expr = ExpressionNoBang(); - {if (true) return expr;} - break; - default: - jj_la1[27] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression ExpressionNoBang() throws ParseException { - Expression expr; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LIST: - expr = ListExpression(); - {if (true) return expr;} - break; - case PRINT: - expr = PrintExpression(); - {if (true) return expr;} - break; - default: - jj_la1[28] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - -/** - * Any assignement operator. - * @return the assignement operator id - */ - final public int AssignmentOperator() throws ParseException { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ASSIGN: - jj_consume_token(ASSIGN); - {if (true) return VariableDeclaration.EQUAL;} - break; - case STARASSIGN: - jj_consume_token(STARASSIGN); - {if (true) return VariableDeclaration.STAR_EQUAL;} - break; - case SLASHASSIGN: - jj_consume_token(SLASHASSIGN); - {if (true) return VariableDeclaration.SLASH_EQUAL;} - break; - case REMASSIGN: - jj_consume_token(REMASSIGN); - {if (true) return VariableDeclaration.REM_EQUAL;} - break; - case PLUSASSIGN: - jj_consume_token(PLUSASSIGN); - {if (true) return VariableDeclaration.PLUS_EQUAL;} - break; - case MINUSASSIGN: - jj_consume_token(MINUSASSIGN); - {if (true) return VariableDeclaration.MINUS_EQUAL;} - break; - case LSHIFTASSIGN: - jj_consume_token(LSHIFTASSIGN); - {if (true) return VariableDeclaration.LSHIFT_EQUAL;} - break; - case RSIGNEDSHIFTASSIGN: - jj_consume_token(RSIGNEDSHIFTASSIGN); - {if (true) return VariableDeclaration.RSIGNEDSHIFT_EQUAL;} - break; - case ANDASSIGN: - jj_consume_token(ANDASSIGN); - {if (true) return VariableDeclaration.AND_EQUAL;} - break; - case XORASSIGN: - jj_consume_token(XORASSIGN); - {if (true) return VariableDeclaration.XOR_EQUAL;} - break; - case ORASSIGN: - jj_consume_token(ORASSIGN); - {if (true) return VariableDeclaration.OR_EQUAL;} - break; - case DOTASSIGN: - jj_consume_token(DOTASSIGN); - {if (true) return VariableDeclaration.DOT_EQUAL;} - break; - case TILDEEQUAL: - jj_consume_token(TILDEEQUAL); - {if (true) return VariableDeclaration.TILDE_EQUAL;} - break; - default: - jj_la1[29] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression ConditionalExpression() throws ParseException { - final Expression expr; - Expression expr2 = null; - Expression expr3 = null; - expr = ConditionalOrExpression(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case HOOK: - jj_consume_token(HOOK); - expr2 = Expression(); - jj_consume_token(COLON); - expr3 = ConditionalExpression(); - break; - default: - jj_la1[30] = jj_gen; - ; - } - if (expr3 == null) { - {if (true) return expr;} - } - {if (true) return new ConditionalExpression(expr,expr2,expr3);} - throw new Error("Missing return statement in function"); - } - - final public Expression ConditionalOrExpression() throws ParseException { - Expression expr,expr2; - int operator; - expr = ConditionalAndExpression(); - label_8: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case OR_OR: - case _ORL: - ; - break; - default: - jj_la1[31] = jj_gen; - break label_8; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case OR_OR: - jj_consume_token(OR_OR); - operator = OperatorIds.OR_OR; - break; - case _ORL: - jj_consume_token(_ORL); - operator = OperatorIds.ORL; - break; - default: - jj_la1[32] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - expr2 = ConditionalAndExpression(); - expr = new BinaryExpression(expr,expr2,operator); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression ConditionalAndExpression() throws ParseException { - Expression expr,expr2; - int operator; - expr = ConcatExpression(); - label_9: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AND_AND: - case _ANDL: - ; - break; - default: - jj_la1[33] = jj_gen; - break label_9; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AND_AND: - jj_consume_token(AND_AND); - operator = OperatorIds.AND_AND; - break; - case _ANDL: - jj_consume_token(_ANDL); - operator = OperatorIds.ANDL; - break; - default: - jj_la1[34] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - expr2 = ConcatExpression(); - expr = new BinaryExpression(expr,expr2,operator); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression ConcatExpression() throws ParseException { - Expression expr,expr2; - expr = InclusiveOrExpression(); - label_10: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case DOT: - ; - break; - default: - jj_la1[35] = jj_gen; - break label_10; - } - jj_consume_token(DOT); - expr2 = InclusiveOrExpression(); - expr = new BinaryExpression(expr,expr2,OperatorIds.DOT); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression InclusiveOrExpression() throws ParseException { - Expression expr,expr2; - expr = ExclusiveOrExpression(); - label_11: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BIT_OR: - ; - break; - default: - jj_la1[36] = jj_gen; - break label_11; - } - jj_consume_token(BIT_OR); - expr2 = ExclusiveOrExpression(); - expr = new BinaryExpression(expr,expr2,OperatorIds.OR); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression ExclusiveOrExpression() throws ParseException { - Expression expr,expr2; - expr = AndExpression(); - label_12: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case XOR: - ; - break; - default: - jj_la1[37] = jj_gen; - break label_12; - } - jj_consume_token(XOR); - expr2 = AndExpression(); - expr = new BinaryExpression(expr,expr2,OperatorIds.XOR); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression AndExpression() throws ParseException { - Expression expr,expr2; - expr = EqualityExpression(); - label_13: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BIT_AND: - ; - break; - default: - jj_la1[38] = jj_gen; - break label_13; - } - jj_consume_token(BIT_AND); - expr2 = EqualityExpression(); - expr = new BinaryExpression(expr,expr2,OperatorIds.AND); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression EqualityExpression() throws ParseException { - Expression expr,expr2; - int operator; - Token token; - expr = RelationalExpression(); - label_14: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case EQUAL_EQUAL: - case NOT_EQUAL: - case DIF: - case BANGDOUBLEEQUAL: - case TRIPLEEQUAL: - ; - break; - default: - jj_la1[39] = jj_gen; - break label_14; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case EQUAL_EQUAL: - token = jj_consume_token(EQUAL_EQUAL); - operator = OperatorIds.EQUAL_EQUAL; - break; - case DIF: - token = jj_consume_token(DIF); - operator = OperatorIds.DIF; - break; - case NOT_EQUAL: - token = jj_consume_token(NOT_EQUAL); - operator = OperatorIds.DIF; - break; - case BANGDOUBLEEQUAL: - token = jj_consume_token(BANGDOUBLEEQUAL); - operator = OperatorIds.BANG_EQUAL_EQUAL; - break; - case TRIPLEEQUAL: - token = jj_consume_token(TRIPLEEQUAL); - operator = OperatorIds.EQUAL_EQUAL_EQUAL; - break; - default: - jj_la1[40] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - try { - expr2 = RelationalExpression(); - } catch (ParseException e) { - if (errorMessage != null) { - {if (true) throw e;} - } - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorStart = token.sourceEnd +1; - errorEnd = token.sourceEnd +1; - expr2 = new ConstantIdentifier(SYNTAX_ERROR_CHAR,token.sourceEnd +1,token.sourceEnd +1); - processParseExceptionDebug(e); - } - expr = new BinaryExpression(expr,expr2,operator); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression RelationalExpression() throws ParseException { - Expression expr,expr2; - int operator; - expr = ShiftExpression(); - label_15: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case GT: - case LT: - case LE: - case GE: - ; - break; - default: - jj_la1[41] = jj_gen; - break label_15; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LT: - jj_consume_token(LT); - operator = OperatorIds.LESS; - break; - case GT: - jj_consume_token(GT); - operator = OperatorIds.GREATER; - break; - case LE: - jj_consume_token(LE); - operator = OperatorIds.LESS_EQUAL; - break; - case GE: - jj_consume_token(GE); - operator = OperatorIds.GREATER_EQUAL; - break; - default: - jj_la1[42] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - expr2 = ShiftExpression(); - expr = new BinaryExpression(expr,expr2,operator); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression ShiftExpression() throws ParseException { - Expression expr,expr2; - int operator; - expr = AdditiveExpression(); - label_16: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LSHIFT: - case RSIGNEDSHIFT: - case RUNSIGNEDSHIFT: - ; - break; - default: - jj_la1[43] = jj_gen; - break label_16; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LSHIFT: - jj_consume_token(LSHIFT); - operator = OperatorIds.LEFT_SHIFT; - break; - case RSIGNEDSHIFT: - jj_consume_token(RSIGNEDSHIFT); - operator = OperatorIds.RIGHT_SHIFT; - break; - case RUNSIGNEDSHIFT: - jj_consume_token(RUNSIGNEDSHIFT); - operator = OperatorIds.UNSIGNED_RIGHT_SHIFT; - break; - default: - jj_la1[44] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - expr2 = AdditiveExpression(); - expr = new BinaryExpression(expr,expr2,operator); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression AdditiveExpression() throws ParseException { - Expression expr,expr2; - int operator; - expr = MultiplicativeExpression(); - label_17: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - case MINUS: - ; - break; - default: - jj_la1[45] = jj_gen; - break label_17; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - jj_consume_token(PLUS); - operator = OperatorIds.PLUS; - break; - case MINUS: - jj_consume_token(MINUS); - operator = OperatorIds.MINUS; - break; - default: - jj_la1[46] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - expr2 = MultiplicativeExpression(); - expr = new BinaryExpression(expr,expr2,operator); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression MultiplicativeExpression() throws ParseException { - Expression expr,expr2; - int operator; - try { - expr = UnaryExpression(); - } catch (ParseException e) { - if (errorMessage != null) {if (true) throw e;} - errorMessage = "unexpected token '"+e.currentToken.next.image+'\''; - errorLevel = ERROR; - errorStart = this.token.sourceStart; - errorEnd = this.token.sourceEnd; - {if (true) throw e;} - } - label_18: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case STAR: - case SLASH: - case REMAINDER: - ; - break; - default: - jj_la1[47] = jj_gen; - break label_18; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case STAR: - jj_consume_token(STAR); - operator = OperatorIds.MULTIPLY; - break; - case SLASH: - jj_consume_token(SLASH); - operator = OperatorIds.DIVIDE; - break; - case REMAINDER: - jj_consume_token(REMAINDER); - operator = OperatorIds.REMAINDER; - break; - default: - jj_la1[48] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - expr2 = UnaryExpression(); - expr = new BinaryExpression(expr,expr2,operator); - } - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - -/** - * An unary expression starting with @, & or nothing - */ - final public Expression UnaryExpression() throws ParseException { - final Expression expr; - /* expr = UnaryExpressionNoPrefix() //why did I had that ? - {return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);} - | */ - expr = AtNotTildeUnaryExpression(); - {if (true) return expr;} - throw new Error("Missing return statement in function"); - } - - final public Expression AtNotTildeUnaryExpression() throws ParseException { - final Expression expr; - final Token token; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AT: - token = jj_consume_token(AT); - expr = AtNotTildeUnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.AT,token.sourceStart);} - break; - case TILDE: - token = jj_consume_token(TILDE); - expr = AtNotTildeUnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.TWIDDLE,token.sourceStart);} - break; - case BANG: - token = jj_consume_token(BANG); - expr = AtNotUnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.NOT,token.sourceStart);} - break; - case ARRAY: - case NEW: - case NULL: - case TRUE: - case FALSE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - expr = UnaryExpressionNoPrefix(); - {if (true) return expr;} - break; - default: - jj_la1[49] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - -/** - * An expression prefixed (or not) by one or more @ and !. - * @return the expression - */ - final public Expression AtNotUnaryExpression() throws ParseException { - final Expression expr; - final Token token; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AT: - token = jj_consume_token(AT); - expr = AtNotUnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.AT,token.sourceStart);} - break; - case BANG: - token = jj_consume_token(BANG); - expr = AtNotUnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.NOT,token.sourceStart);} - break; - case ARRAY: - case NEW: - case NULL: - case TRUE: - case FALSE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - expr = UnaryExpressionNoPrefix(); - {if (true) return expr;} - break; - default: - jj_la1[50] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression UnaryExpressionNoPrefix() throws ParseException { - final Expression expr; - final Token token; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - token = jj_consume_token(PLUS); - expr = AtNotTildeUnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr, - OperatorIds.PLUS, - token.sourceStart);} - break; - case MINUS: - token = jj_consume_token(MINUS); - expr = AtNotTildeUnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr, - OperatorIds.MINUS, - token.sourceStart);} - break; - case PLUS_PLUS: - case MINUS_MINUS: - expr = PreIncDecExpression(); - {if (true) return expr;} - break; - case ARRAY: - case NEW: - case NULL: - case TRUE: - case FALSE: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - expr = UnaryExpressionNotPlusMinus(); - {if (true) return expr;} - break; - default: - jj_la1[51] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression PreIncDecExpression() throws ParseException { -final Expression expr; -final int operator; -final Token token; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS_PLUS: - token = jj_consume_token(PLUS_PLUS); - operator = OperatorIds.PLUS_PLUS; - break; - case MINUS_MINUS: - token = jj_consume_token(MINUS_MINUS); - operator = OperatorIds.MINUS_MINUS; - break; - default: - jj_la1[52] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - expr = PrimaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr,operator,token.sourceStart);} - throw new Error("Missing return statement in function"); - } - - final public Expression UnaryExpressionNotPlusMinus() throws ParseException { - final Expression expr; - if (jj_2_3(2147483647)) { - expr = CastExpression(); - {if (true) return expr;} - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case NEW: - case BIT_AND: - case DOLLAR: - case IDENTIFIER: - expr = PostfixExpression(); - {if (true) return expr;} - break; - case NULL: - case TRUE: - case FALSE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - expr = Literal(); - {if (true) return expr;} - break; - case LPAREN: - jj_consume_token(LPAREN); - expr = Expression(); - try { - jj_consume_token(RPAREN); - } catch (ParseException e) { - errorMessage = "')' expected"; - errorLevel = ERROR; - errorStart = expr.sourceEnd +1; - errorEnd = expr.sourceEnd +1; - processParseExceptionDebug(e); - } - {if (true) return expr;} - break; - default: - jj_la1[53] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - throw new Error("Missing return statement in function"); - } - - final public CastExpression CastExpression() throws ParseException { -final ConstantIdentifier type; -final Expression expr; -final Token token,token1; - token1 = jj_consume_token(LPAREN); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case STRING: - case OBJECT: - case BOOL: - case BOOLEAN: - case REAL: - case DOUBLE: - case FLOAT: - case INT: - case INTEGER: - type = Type(); - break; - case ARRAY: - token = jj_consume_token(ARRAY); - type = new ConstantIdentifier(token); - break; - default: - jj_la1[54] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(RPAREN); - expr = UnaryExpression(); - {if (true) return new CastExpression(type,expr,token1.sourceStart,expr.sourceEnd);} - throw new Error("Missing return statement in function"); - } - - final public Expression PostfixExpression() throws ParseException { - final Expression expr; - int operator = -1; - Token token = null; - expr = PrimaryExpression(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS_PLUS: - case MINUS_MINUS: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS_PLUS: - token = jj_consume_token(PLUS_PLUS); - operator = OperatorIds.PLUS_PLUS; - break; - case MINUS_MINUS: - token = jj_consume_token(MINUS_MINUS); - operator = OperatorIds.MINUS_MINUS; - break; - default: - jj_la1[55] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_la1[56] = jj_gen; - ; - } - if (operator == -1) { - {if (true) return expr;} - } - {if (true) return new PostfixedUnaryExpression(expr,operator,token.sourceEnd);} - throw new Error("Missing return statement in function"); - } - - final public Expression PrimaryExpression() throws ParseException { - Expression expr; - Token token = null; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NEW: - case BIT_AND: - case DOLLAR: - case IDENTIFIER: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BIT_AND: - token = jj_consume_token(BIT_AND); - break; - default: - jj_la1[57] = jj_gen; - ; - } - expr = refPrimaryExpression(token); - {if (true) return expr;} - break; - case ARRAY: - expr = ArrayDeclarator(); - {if (true) return expr;} - break; - default: - jj_la1[58] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Expression refPrimaryExpression(final Token reference) throws ParseException { - Expression expr; - Expression expr2 = null; - final Token identifier; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IDENTIFIER: - identifier = jj_consume_token(IDENTIFIER); - expr = new ConstantIdentifier(identifier); - label_19: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case STATICCLASSACCESS: - ; - break; - default: - jj_la1[59] = jj_gen; - break label_19; - } - jj_consume_token(STATICCLASSACCESS); - expr2 = ClassIdentifier(); - expr = new ClassAccess(expr, - expr2, - ClassAccess.STATIC); - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LPAREN: - expr2 = Arguments(expr); - break; - default: - jj_la1[60] = jj_gen; - ; - } - if (expr2 == null) { - if (reference != null) { - ParseException e = generateParseException(); - errorMessage = "you cannot use a constant by reference"; - errorLevel = ERROR; - errorStart = reference.sourceStart; - errorEnd = reference.sourceEnd; - processParseExceptionDebug(e); - } - {if (true) return expr;} - } - {if (true) return expr2;} - break; - case DOLLAR: - expr = VariableDeclaratorId(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LPAREN: - expr = Arguments(expr); - break; - default: - jj_la1[61] = jj_gen; - ; - } - {if (true) return expr;} - break; - case NEW: - token = jj_consume_token(NEW); - expr = ClassIdentifier(); - int start; - if (reference == null) { - start = token.sourceStart; - } else { - start = reference.sourceStart; - } - expr = new ClassInstantiation(expr, - reference != null, - start); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LPAREN: - expr = Arguments(expr); - break; - default: - jj_la1[62] = jj_gen; - ; - } - {if (true) return expr;} - break; - default: - jj_la1[63] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - -/** - * An array declarator. - * array(vars) - * @return an array - */ - final public ArrayInitializer ArrayDeclarator() throws ParseException { - final ArrayVariableDeclaration[] vars; - final Token token; - token = jj_consume_token(ARRAY); - vars = ArrayInitializer(); - {if (true) return new ArrayInitializer(vars, - token.sourceStart, - this.token.sourceEnd);} - throw new Error("Missing return statement in function"); - } - - final public Expression ClassIdentifier() throws ParseException { - final Expression expr; - final Token token; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IDENTIFIER: - token = jj_consume_token(IDENTIFIER); - {if (true) return new ConstantIdentifier(token);} - break; - case STRING: - case OBJECT: - case BOOL: - case BOOLEAN: - case REAL: - case DOUBLE: - case FLOAT: - case INT: - case INTEGER: - expr = Type(); - {if (true) return expr;} - break; - case DOLLAR: - expr = VariableDeclaratorId(); - {if (true) return expr;} - break; - default: - jj_la1[64] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - -/** - * Used by Variabledeclaratorid and primarysuffix - */ - final public AbstractVariable VariableSuffix(final AbstractVariable prefix) throws ParseException { - Expression expression = null; - final Token classAccessToken,lbrace,rbrace; - Token token; - int pos; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CLASSACCESS: - classAccessToken = jj_consume_token(CLASSACCESS); - try { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LBRACE: - lbrace = jj_consume_token(LBRACE); - expression = Expression(); - rbrace = jj_consume_token(RBRACE); - expression = new Variable(expression, - lbrace.sourceStart, - rbrace.sourceEnd); - break; - case IDENTIFIER: - token = jj_consume_token(IDENTIFIER); - expression = new ConstantIdentifier(token.image,token.sourceStart,token.sourceEnd); - break; - case DOLLAR: - expression = Variable(); - break; - default: - jj_la1[65] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected"; - errorLevel = ERROR; - errorStart = classAccessToken.sourceEnd +1; - errorEnd = classAccessToken.sourceEnd +1; - processParseExceptionDebug(e); - } - {if (true) return new ClassAccess(prefix, - expression, - ClassAccess.NORMAL);} - break; - case LBRACKET: - token = jj_consume_token(LBRACKET); - pos = token.sourceEnd+1; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case LIST: - case PRINT: - case NEW: - case NULL: - case TRUE: - case FALSE: - case STRING: - case OBJECT: - case BOOL: - case BOOLEAN: - case REAL: - case DOUBLE: - case FLOAT: - case INT: - case INTEGER: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case LIST: - case PRINT: - case NEW: - case NULL: - case TRUE: - case FALSE: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - expression = Expression(); - pos = expression.sourceEnd+1; - break; - case STRING: - case OBJECT: - case BOOL: - case BOOLEAN: - case REAL: - case DOUBLE: - case FLOAT: - case INT: - case INTEGER: - expression = Type(); - pos = expression.sourceEnd+1; - break; - default: - jj_la1[66] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_la1[67] = jj_gen; - ; - } - try { - token = jj_consume_token(RBRACKET); - pos = token.sourceEnd; - } catch (ParseException e) { - errorMessage = "']' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - {if (true) return new ArrayDeclarator(prefix,expression,pos);} - break; - case LBRACE: - token = jj_consume_token(LBRACE); - pos = token.sourceEnd+1; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case LIST: - case PRINT: - case NEW: - case NULL: - case TRUE: - case FALSE: - case STRING: - case OBJECT: - case BOOL: - case BOOLEAN: - case REAL: - case DOUBLE: - case FLOAT: - case INT: - case INTEGER: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case LIST: - case PRINT: - case NEW: - case NULL: - case TRUE: - case FALSE: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - expression = Expression(); - pos = expression.sourceEnd+1; - break; - case STRING: - case OBJECT: - case BOOL: - case BOOLEAN: - case REAL: - case DOUBLE: - case FLOAT: - case INT: - case INTEGER: - expression = Type(); - pos = expression.sourceEnd+1; - break; - default: - jj_la1[68] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_la1[69] = jj_gen; - ; - } - try { - token = jj_consume_token(RBRACE); - pos = token.sourceEnd; - } catch (ParseException e) { - errorMessage = "']' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - {if (true) return new ArrayDeclarator(prefix,expression,pos);} - break; - default: - jj_la1[70] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public Literal Literal() throws ParseException { - final Token token; - StringLiteral literal; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INTEGER_LITERAL: - token = jj_consume_token(INTEGER_LITERAL); - {if (true) return new NumberLiteral(token);} - break; - case FLOATING_POINT_LITERAL: - token = jj_consume_token(FLOATING_POINT_LITERAL); - {if (true) return new NumberLiteral(token);} - break; - case STRING_LITERAL: - token = jj_consume_token(STRING_LITERAL); - {if (true) return new StringLiteral(token);} - break; - case TRUE: - token = jj_consume_token(TRUE); - {if (true) return new TrueLiteral(token);} - break; - case FALSE: - token = jj_consume_token(FALSE); - {if (true) return new FalseLiteral(token);} - break; - case NULL: - token = jj_consume_token(NULL); - {if (true) return new NullLiteral(token);} - break; - case DOUBLEQUOTE: - literal = evaluableString(); - {if (true) return literal;} - break; - default: - jj_la1[71] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - final public StringLiteral evaluableString() throws ParseException { - ArrayList list = new ArrayList(); - Token start,end; - Token token,lbrace,rbrace; - AbstractVariable var; - Expression expr; - start = jj_consume_token(DOUBLEQUOTE); - label_20: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case DOLLARS: - ; - break; - default: - jj_la1[72] = jj_gen; - break label_20; - } - jj_consume_token(DOLLARS); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IDENTIFIER: - token = jj_consume_token(IDENTIFIER); - list.add(new Variable(token.image, - token.sourceStart, - token.sourceEnd)); - break; - case LBRACE1: - lbrace = jj_consume_token(LBRACE1); - token = jj_consume_token(ID); - list.add(new Variable(token.image, - token.sourceStart, - token.sourceEnd)); - rbrace = jj_consume_token(RBRACE1); - break; - default: - jj_la1[73] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - end = jj_consume_token(DOUBLEQUOTE2); - AbstractVariable[] vars = new AbstractVariable[list.size()]; - list.toArray(vars); - {if (true) return new StringLiteral(jj_input_stream.getCurrentBuffer().substring(start.sourceEnd,end.sourceStart), - start.sourceStart, - end.sourceEnd, - vars);} - throw new Error("Missing return statement in function"); - } - - final public FunctionCall Arguments(final Expression func) throws ParseException { -Expression[] args = null; -final Token token,lparen; - lparen = jj_consume_token(LPAREN); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case LIST: - case PRINT: - case NEW: - case NULL: - case TRUE: - case FALSE: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - args = ArgumentList(); - break; - default: - jj_la1[74] = jj_gen; - ; - } - try { - token = jj_consume_token(RPAREN); - {if (true) return new FunctionCall(func,args,token.sourceEnd);} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list"; - errorLevel = ERROR; - if (args == null) { - errorStart = lparen.sourceEnd+1; - errorEnd = lparen.sourceEnd+2; - } else { - errorStart = args[args.length-1].sourceEnd+1; - errorEnd = args[args.length-1].sourceEnd+2; - } - processParseExceptionDebug(e); - } - int sourceEnd = (args == null && args.length != 0) ? lparen.sourceEnd+1 : args[args.length-1].sourceEnd; - {if (true) return new FunctionCall(func,args,sourceEnd);} - throw new Error("Missing return statement in function"); - } - -/** - * An argument list is a list of arguments separated by comma : - * argumentDeclaration() (, argumentDeclaration)* - * @return an array of arguments - */ - final public Expression[] ArgumentList() throws ParseException { -Expression arg; -final ArrayList list = new ArrayList(); -int pos; -Token token; - arg = Expression(); - list.add(arg);pos = arg.sourceEnd; - label_21: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[75] = jj_gen; - break label_21; - } - token = jj_consume_token(COMMA); - pos = token.sourceEnd; - try { - arg = Expression(); - list.add(arg); - pos = arg.sourceEnd; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseException(e); - } - } - final Expression[] arguments = new Expression[list.size()]; - list.toArray(arguments); - {if (true) return arguments;} - throw new Error("Missing return statement in function"); - } - -/** - * A Statement without break. - * @return a statement - */ - final public Statement StatementNoBreak() throws ParseException { - final Statement statement; - Token token = null; - if (jj_2_4(2)) { - statement = expressionStatement(); - {if (true) return statement;} - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IDENTIFIER: - statement = LabeledStatement(); - {if (true) return statement;} - break; - case LBRACE: - statement = Block(); - {if (true) return statement;} - break; - case SEMICOLON: - statement = EmptyStatement(); - {if (true) return statement;} - break; - case SWITCH: - statement = SwitchStatement(); - {if (true) return statement;} - break; - case IF: - statement = IfStatement(); - {if (true) return statement;} - break; - case WHILE: - statement = WhileStatement(); - {if (true) return statement;} - break; - case DO: - statement = DoStatement(); - {if (true) return statement;} - break; - case FOR: - statement = ForStatement(); - {if (true) return statement;} - break; - case FOREACH: - statement = ForeachStatement(); - {if (true) return statement;} - break; - case CONTINUE: - statement = ContinueStatement(); - {if (true) return statement;} - break; - case RETURN: - statement = ReturnStatement(); - {if (true) return statement;} - break; - case ECHO: - statement = EchoStatement(); - {if (true) return statement;} - break; - case INCLUDE: - case REQUIRE: - case INCLUDE_ONCE: - case REQUIRE_ONCE: - case AT: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AT: - token = jj_consume_token(AT); - break; - default: - jj_la1[76] = jj_gen; - ; - } - statement = IncludeStatement(); - if (token != null) { - ((InclusionStatement)statement).silent = true; - statement.sourceStart = token.sourceStart; - } - {if (true) return statement;} - break; - case STATIC: - statement = StaticStatement(); - {if (true) return statement;} - break; - case GLOBAL: - statement = GlobalStatement(); - {if (true) return statement;} - break; - case DEFINE: - statement = defineStatement(); - currentSegment.add((Outlineable)statement);{if (true) return statement;} - break; - default: - jj_la1[77] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - throw new Error("Missing return statement in function"); - } - -/** - * A statement expression. - * expression ; - * @return an expression - */ - final public Statement expressionStatement() throws ParseException { - final Statement statement; - final Token token; - statement = Expression(); - try { - token = jj_consume_token(SEMICOLON); - statement.sourceEnd = token.sourceEnd; - } catch (ParseException e) { - if (e.currentToken.next.kind != PHPParserConstants.PHPEND) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; - errorLevel = ERROR; - errorStart = statement.sourceEnd+1; - errorEnd = statement.sourceEnd+1; - processParseExceptionDebug(e); - } - } - {if (true) return statement;} - throw new Error("Missing return statement in function"); - } - - final public Define defineStatement() throws ParseException { - Expression defineName,defineValue; - final Token defineToken; - Token token; - int pos; - defineToken = jj_consume_token(DEFINE); - pos = defineToken.sourceEnd+1; - try { - token = jj_consume_token(LPAREN); - pos = token.sourceEnd+1; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - try { - defineName = Expression(); - pos = defineName.sourceEnd+1; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - defineName = new StringLiteral(SYNTAX_ERROR_CHAR,pos,pos); - } - try { - token = jj_consume_token(COMMA); - pos = defineName.sourceEnd+1; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - try { - defineValue = Expression(); - pos = defineValue.sourceEnd+1; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - defineValue = new StringLiteral(SYNTAX_ERROR_CHAR,pos,pos); - } - try { - token = jj_consume_token(RPAREN); - pos = token.sourceEnd+1; - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - {if (true) return new Define(currentSegment, - defineName, - defineValue, - defineToken.sourceStart, - pos);} - throw new Error("Missing return statement in function"); - } - -/** - * A Normal statement. - */ - final public Statement Statement() throws ParseException { - final Statement statement; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IF: - case ARRAY: - case LIST: - case PRINT: - case ECHO: - case INCLUDE: - case REQUIRE: - case INCLUDE_ONCE: - case REQUIRE_ONCE: - case GLOBAL: - case DEFINE: - case STATIC: - case CONTINUE: - case DO: - case FOR: - case NEW: - case NULL: - case RETURN: - case SWITCH: - case TRUE: - case FALSE: - case WHILE: - case FOREACH: - case AT: - case BANG: - case TILDE: - case PLUS_PLUS: - case MINUS_MINUS: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case DOUBLEQUOTE: - case DOLLAR: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - statement = StatementNoBreak(); - {if (true) return statement;} - break; - case BREAK: - statement = BreakStatement(); - {if (true) return statement;} - break; - default: - jj_la1[78] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - -/** - * An html block inside a php syntax. - */ - final public HTMLBlock htmlBlock() throws ParseException { - final int startIndex = nodePtr; - final AstNode[] blockNodes; - final int nbNodes; - final Token phpEnd; - phpEnd = jj_consume_token(PHPEND); - htmlStart = phpEnd.sourceEnd; - label_22: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PHPECHOSTART: - ; - break; - default: - jj_la1[79] = jj_gen; - break label_22; - } - phpEchoBlock(); - } - try { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PHPSTARTLONG: - jj_consume_token(PHPSTARTLONG); - break; - case PHPSTARTSHORT: - jj_consume_token(PHPSTARTSHORT); - break; - default: - jj_la1[80] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - createNewHTMLCode(); - } catch (ParseException e) { - errorMessage = "unexpected end of file , ' 100) { - jj_gc = 0; - for (int i = 0; i < jj_2_rtns.length; i++) { - JJCalls c = jj_2_rtns[i]; - while (c != null) { - if (c.gen < jj_gen) c.first = null; - c = c.next; - } - } - } - return token; - } - token = oldToken; - jj_kind = kind; - throw generateParseException(); - } - - final private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); - } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; - } - } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_rescan) { - int i = 0; Token tok = token; - while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } - if (tok != null) jj_add_error_token(kind, i); - } - return (jj_scanpos.kind != kind); - } - - final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - jj_gen++; - return token; - } - - final public Token getToken(int index) { - Token t = lookingAhead ? jj_scanpos : token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; - } - - final private int jj_ntk() { - if ((jj_nt=token.next) == null) - return (jj_ntk = (token.next=token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); - } - - private java.util.Vector jj_expentries = new java.util.Vector(); - private int[] jj_expentry; - private int jj_kind = -1; - private int[] jj_lasttokens = new int[100]; - private int jj_endpos; - - private void jj_add_error_token(int kind, int pos) { - if (pos >= 100) return; - if (pos == jj_endpos + 1) { - jj_lasttokens[jj_endpos++] = kind; - } else if (jj_endpos != 0) { - jj_expentry = new int[jj_endpos]; - for (int i = 0; i < jj_endpos; i++) { - jj_expentry[i] = jj_lasttokens[i]; - } - boolean exists = false; - for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) { - int[] oldentry = (int[])(enum.nextElement()); - if (oldentry.length == jj_expentry.length) { - exists = true; - for (int i = 0; i < jj_expentry.length; i++) { - if (oldentry[i] != jj_expentry[i]) { - exists = false; - break; - } - } - if (exists) break; - } - } - if (!exists) jj_expentries.addElement(jj_expentry); - if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; - } - } - - public ParseException generateParseException() { - jj_expentries.removeAllElements(); - boolean[] la1tokens = new boolean[160]; - for (int i = 0; i < 160; i++) { - la1tokens[i] = false; - } - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 128; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1< jj_gen) { - jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: jj_3_1(); break; - case 1: jj_3_2(); break; - case 2: jj_3_3(); break; - case 3: jj_3_4(); break; - case 4: jj_3_5(); break; - } - } - p = p.next; - } while (p != null); - } - jj_rescan = false; - } - - final private void jj_save(int index, int xla) { - JJCalls p = jj_2_rtns[index]; - while (p.gen > jj_gen) { - if (p.next == null) { p = p.next = new JJCalls(); break; } - p = p.next; - } - p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; - } - - static final class JJCalls { - int gen; - Token first; - int arg; - JJCalls next; - } - -} diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj deleted file mode 100644 index b61df9a..0000000 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ /dev/null @@ -1,3437 +0,0 @@ - -options { - LOOKAHEAD = 1; - CHOICE_AMBIGUITY_CHECK = 2; - OTHER_AMBIGUITY_CHECK = 1; - STATIC = false; - DEBUG_PARSER = false; - DEBUG_LOOKAHEAD = false; - DEBUG_TOKEN_MANAGER = false; - OPTIMIZE_TOKEN_MANAGER = false; - ERROR_REPORTING = true; - JAVA_UNICODE_ESCAPE = false; - UNICODE_INPUT = false; - IGNORE_CASE = true; - USER_TOKEN_MANAGER = false; - USER_CHAR_STREAM = false; - BUILD_PARSER = true; - BUILD_TOKEN_MANAGER = true; - SANITY_CHECK = true; - FORCE_LA_CHECK = false; - COMMON_TOKEN_ACTION = true; -} - -PARSER_BEGIN(PHPParser) -package test; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ui.texteditor.MarkerUtilities; -import org.eclipse.jface.preference.IPreferenceStore; - -import java.util.Hashtable; -import java.util.ArrayList; -import java.io.StringReader; -import java.io.*; -import java.text.MessageFormat; - -import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpdt.internal.compiler.ast.*; -import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; -import net.sourceforge.phpdt.internal.corext.Assert; - -/** - * A new php parser. - * This php parser is inspired by the Java 1.2 grammar example - * given with JavaCC. You can get JavaCC at http://www.webgain.com - * You can test the parser with the PHPParserTestCase2.java - * @author Matthieu Casanova - */ -public final class PHPParser extends PHPParserSuperclass { - -//todo : fix the variables names bug -//todo : handle tilde operator - - - /** The current segment. */ - private static OutlineableWithChildren currentSegment; - - private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$ - private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ - static PHPOutlineInfo outlineInfo; - - /** The error level of the current ParseException. */ - private static int errorLevel = ERROR; - /** The message of the current ParseException. If it's null it's because the parse exception wasn't handled */ - private static String errorMessage; - - private static int errorStart = -1; - private static int errorEnd = -1; - private static PHPDocument phpDocument; - - private static final String SYNTAX_ERROR_CHAR = "syntax error"; - /** - * The point where html starts. - * It will be used by the token manager to create HTMLCode objects - */ - public static int htmlStart; - - //ast stack - private final static int AstStackIncrement = 100; - /** The stack of node. */ - private static AstNode[] nodes; - /** The cursor in expression stack. */ - private static int nodePtr; - - public static final boolean PARSER_DEBUG = false; - - public final void setFileToParse(final IFile fileToParse) { - PHPParser.fileToParse = fileToParse; - } - - public PHPParser() { - } - - public PHPParser(final IFile fileToParse) { - this(new StringReader("")); - PHPParser.fileToParse = fileToParse; - } - - public final void phpParserTester(final String strEval) throws ParseException { - final StringReader stream = new StringReader(strEval); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(new StringReader(strEval)); - init(); - phpDocument = new PHPDocument(null,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(null, currentSegment); - token_source.SwitchTo(PHPParserTokenManager.PHPPARSING); - phpTest(); - } - - public final void htmlParserTester(final File fileName) throws FileNotFoundException, ParseException { - final Reader stream = new FileReader(fileName); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - phpDocument = new PHPDocument(null,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(null, currentSegment); - phpFile(); - } - - public final void htmlParserTester(final String strEval) throws ParseException { - final StringReader stream = new StringReader(strEval); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - phpDocument = new PHPDocument(null,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(null, currentSegment); - phpFile(); - } - - /** - * Reinitialize the parser. - */ - private static final void init() { - nodes = new AstNode[AstStackIncrement]; - nodePtr = -1; - htmlStart = 0; - } - - /** - * Add an php node on the stack. - * @param node the node that will be added to the stack - */ - private static final void pushOnAstNodes(final AstNode node) { - try { - nodes[++nodePtr] = node; - } catch (IndexOutOfBoundsException e) { - final int oldStackLength = nodes.length; - final AstNode[] oldStack = nodes; - nodes = new AstNode[oldStackLength + AstStackIncrement]; - System.arraycopy(oldStack, 0, nodes, 0, oldStackLength); - nodePtr = oldStackLength; - nodes[nodePtr] = node; - } - } - - public final PHPOutlineInfo parseInfo(final Object parent, final String s) { - phpDocument = new PHPDocument(parent,"_root".toCharArray()); - currentSegment = phpDocument; - outlineInfo = new PHPOutlineInfo(parent, currentSegment); - final StringReader stream = new StringReader(s); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - try { - parse(); - phpDocument.nodes = new AstNode[nodes.length]; - System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); - if (PHPeclipsePlugin.DEBUG) { - PHPeclipsePlugin.log(1,phpDocument.toString()); - } - } catch (ParseException e) { - processParseException(e); - } - return outlineInfo; - } - - /** - * This function will throw the exception if we are in debug mode - * and process it if we are in production mode. - * this should be fast since the PARSER_DEBUG is static final so the difference will be at compile time - * @param e the exception - * @throws ParseException the thrown exception - */ - private static void processParseExceptionDebug(final ParseException e) throws ParseException { - if (PARSER_DEBUG) { - throw e; - } - processParseException(e); - } - /** - * This method will process the parse exception. - * If the error message is null, the parse exception wasn't catched and a trace is written in the log - * @param e the ParseException - */ - private static void processParseException(final ParseException e) { - if (errorMessage == null) { - PHPeclipsePlugin.log(e); - errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it"; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - } - setMarker(e); - errorMessage = null; - // if (PHPeclipsePlugin.DEBUG) PHPeclipsePlugin.log(e); - } - - /** - * Create marker for the parse error. - * @param e the ParseException - */ - private static void setMarker(final ParseException e) { - try { - if (errorStart == -1) { - setMarker(fileToParse, - errorMessage, - e.currentToken.sourceStart, - e.currentToken.sourceEnd, - errorLevel, - "Line " + e.currentToken.beginLine+", "+e.currentToken.sourceStart+':'+e.currentToken.sourceEnd); - } else { - setMarker(fileToParse, - errorMessage, - errorStart, - errorEnd, - errorLevel, - "Line " + e.currentToken.beginLine+", "+errorStart+':'+errorEnd); - errorStart = -1; - errorEnd = -1; - } - } catch (CoreException e2) { - PHPeclipsePlugin.log(e2); - } - } - - private static void scanLine(final String output, - final IFile file, - final int indx, - final int brIndx) throws CoreException { - String current; - final StringBuffer lineNumberBuffer = new StringBuffer(10); - char ch; - current = output.substring(indx, brIndx); - - if (current.indexOf(PARSE_WARNING_STRING) != -1 || current.indexOf(PARSE_ERROR_STRING) != -1) { - final int onLine = current.indexOf("on line "); - if (onLine != -1) { - lineNumberBuffer.delete(0, lineNumberBuffer.length()); - for (int i = onLine; i < current.length(); i++) { - ch = current.charAt(i); - if ('0' <= ch && '9' >= ch) { - lineNumberBuffer.append(ch); - } - } - - final int lineNumber = Integer.parseInt(lineNumberBuffer.toString()); - - final Hashtable attributes = new Hashtable(); - - current = current.replaceAll("\n", ""); - current = current.replaceAll("", ""); - current = current.replaceAll("", ""); - MarkerUtilities.setMessage(attributes, current); - - if (current.indexOf(PARSE_ERROR_STRING) != -1) - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - else if (current.indexOf(PARSE_WARNING_STRING) != -1) - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - else - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - MarkerUtilities.setLineNumber(attributes, lineNumber); - MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); - } - } - } - - public final void parse(final String s) { - final StringReader stream = new StringReader(s); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new PHPParserTokenManager(jj_input_stream); - } - ReInit(stream); - init(); - try { - parse(); - } catch (ParseException e) { - processParseException(e); - } - } - - /** - * Call the php parse command ( php -l -f <filename> ) - * and create markers according to the external parser output - */ - public static void phpExternalParse(final IFile file) { - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - final String filename = file.getLocation().toString(); - - final String[] arguments = { filename }; - final MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF)); - final String command = form.format(arguments); - - final String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: "); - - try { - // parse the buffer to find the errors and warnings - createMarkers(parserResult, file); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - } - } - - /** - * Put a new html block in the stack. - */ - public final void createNewHTMLCode() { - final int currentPosition = token.sourceStart; - if (currentPosition == htmlStart || - currentPosition < htmlStart || - currentPosition > jj_input_stream.getCurrentBuffer().length()) { - return; - } - final String html = jj_input_stream.getCurrentBuffer().substring(htmlStart, currentPosition); - pushOnAstNodes(new HTMLCode(html, htmlStart,currentPosition)); - } - - /** Create a new task. */ - public final void createNewTask(final int todoStart) { - final String todo = jj_input_stream.getCurrentBuffer().substring(todoStart, - jj_input_stream.getCurrentBuffer().indexOf("\n", - todoStart)-1); - if (!PARSER_DEBUG) { - try { - setMarker(fileToParse, - todo, - jj_input_stream.getBeginLine(), - TASK, - "Line "+jj_input_stream.getBeginLine()); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - } - } - } - - private final void parse() throws ParseException { - phpFile(); - } -} - -PARSER_END(PHPParser) - -TOKEN_MGR_DECLS: -{ - // CommonTokenAction: use the begins/ends fields added to the Jack - // CharStream class to set corresponding fields in each Token (which was - // also extended with new fields). By default Jack doesn't supply absolute - // offsets, just line/column offsets - void CommonTokenAction(Token t) { - t.sourceStart = input_stream.getBeginOffset(); - t.sourceEnd = input_stream.getBeginOffset(); - } // CommonTokenAction -} // TOKEN_MGR_DECLS - - TOKEN : -{ - : PHPPARSING -| : PHPPARSING -| "> : DEFAULT -} - -/* Skip any character if we are not in php mode */ - SKIP : -{ - < ~[] > -} - - -/* WHITE SPACE */ - SKIP : -{ - " " -| "\t" -| "\n" -| "\r" -| "\f" -} - - SPECIAL_TOKEN : -{ - " " : PHPPARSING -| "\t" : PHPPARSING -| "\n" : PHPPARSING -| "\r" : PHPPARSING -| "\f" : PHPPARSING -} -/* COMMENTS */ - SPECIAL_TOKEN : -{ - "//" : IN_SINGLE_LINE_COMMENT -| "#" : IN_SINGLE_LINE_COMMENT -| <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT -| "/*" : IN_MULTI_LINE_COMMENT -} - - SPECIAL_TOKEN : -{ - : PHPPARSING -| < ~[] > -} - - SPECIAL_TOKEN : -{ - "todo" -} - -void todo() : -{Token todoToken;} -{ - todoToken = "TODO" {createNewTask(todoToken.sourceStart);} -} - SPECIAL_TOKEN : -{ - "*/" : PHPPARSING -} - - SPECIAL_TOKEN : -{ - "*/" : PHPPARSING -} - - -MORE : -{ - < ~[] > -} - -/* KEYWORDS */ - TOKEN : -{ - -| -| -| -| -| -| -| -| -} - -/* LANGUAGE CONSTRUCT */ - TOKEN : -{ - -| -| -| -| -| -| -| -| -} - - TOKEN : -{ - "> : PHPPARSING -| : PHPPARSING -| "> : PHPPARSING -} - -/* RESERVED WORDS AND LITERALS */ - - TOKEN : -{ - -| -| -| <_DEFAULT : "default"> -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -} - -/* TYPES */ - TOKEN : -{ - -| -| -| -| -| -| -| -| -} - -//Misc token - TOKEN : -{ - : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -} - -/* OPERATORS */ - TOKEN : -{ - : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| >"> : PHPPARSING -| >>"> : PHPPARSING -| <_ORL : "OR"> : PHPPARSING -| <_ANDL : "AND"> : PHPPARSING -} - -/* LITERALS */ - TOKEN : -{ - (["l","L"])? - | (["l","L"])? - | (["l","L"])? - > -| - <#DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > -| - <#HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > -| - <#OCTAL_LITERAL: "0" (["0"-"7"])* > -| - )? (["f","F","d","D"])? - | "." (["0"-"9"])+ ()? (["f","F","d","D"])? - | (["0"-"9"])+ (["f","F","d","D"])? - | (["0"-"9"])+ ()? ["f","F","d","D"] - > -| - <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > -| - | )> -//| -| -| -} - - SKIP : -{ - : IN_STRING -} - - TOKEN : -{ - : IN_STRING -} - - - TOKEN : -{ - : DOLLAR_IN_STRING -} - - TOKEN : -{ - : PHPPARSING -} - - TOKEN : -{ - : DOLLAR_IN_STRING_EXPR -} - - SPECIAL_TOKEN : -{ - <"{"> : SKIPSTRING -} - - SPECIAL_TOKEN : -{ - <"}"> : IN_STRING -} - - SKIP : -{ - <~[]> -} - - TOKEN : -{ - : DOLLAR_IN_STRING -} - - TOKEN : -{ - -} - - SKIP : -{ - <~[]> -} - - SKIP : -{ - <~[]> -} -/* IDENTIFIERS */ - - - TOKEN : { : IN_VARIABLE} - - - TOKEN : -{ - |) (||)* > -| - < #LETTER: - ["a"-"z"] | ["A"-"Z"] - > -| - < #DIGIT: - ["0"-"9"] - > -| - < #SPECIAL: - "_" | ["\u007f"-"\u00ff"] - > -} - - SPECIAL_TOKEN : -{ - < ~[] > : IN_STRING -} -/* SEPARATORS */ - - TOKEN : -{ - : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| : PHPPARSING -} - - -/* COMPARATOR */ - TOKEN : -{ - "> : PHPPARSING -| : PHPPARSING -| : PHPPARSING -| ="> : PHPPARSING -| "> : PHPPARSING -| : PHPPARSING -| : PHPPARSING -} - -/* ASSIGNATION */ - TOKEN : -{ - : PHPPARSING -| >="> : PHPPARSING -} - -void phpTest() : -{} -{ - Php() - -} - -void phpFile() : -{} -{ - try { - (PhpBlock())* - {createNewHTMLCode();} - } catch (TokenMgrError e) { - PHPeclipsePlugin.log(e); - errorStart = jj_input_stream.getBeginOffset(); - errorEnd = jj_input_stream.getEndOffset(); - errorMessage = e.getMessage(); - errorLevel = ERROR; - throw generateParseException(); - } -} - -/** - * A php block is a - * or - * or - */ -void PhpBlock() : -{ - final PHPEchoBlock phpEchoBlock; - final Token token,phpEnd; -} -{ - phpEchoBlock = phpEchoBlock() - {pushOnAstNodes(phpEchoBlock);} -| - [ - | token = - {try { - setMarker(fileToParse, - "You should use ' - {htmlStart = phpEnd.sourceEnd;} - } catch (ParseException e) { - errorMessage = "'?>' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } -} - -PHPEchoBlock phpEchoBlock() : -{ - final Expression expr; - final PHPEchoBlock echoBlock; - final Token token, token2; -} -{ - token = {createNewHTMLCode();} - expr = Expression() [ ] token2 = - { - htmlStart = token2.sourceEnd; - - echoBlock = new PHPEchoBlock(expr,token.sourceStart,token2.sourceEnd); - pushOnAstNodes(echoBlock); - return echoBlock;} -} - -void Php() : -{} -{ - (BlockStatement())* -} - -ClassDeclaration ClassDeclaration() : -{ - final ClassDeclaration classDeclaration; - Token className = null; - final Token superclassName, token, extendsToken; - String classNameImage = SYNTAX_ERROR_CHAR; - String superclassNameImage = null; - final int classEnd; -} -{ - token = - try { - className = - {classNameImage = className.image;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; - errorLevel = ERROR; - errorStart = token.sourceEnd+1; - errorEnd = token.sourceEnd+1; - processParseExceptionDebug(e); - } - [ - extendsToken = - try { - superclassName = - {superclassNameImage = superclassName.image;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; - errorLevel = ERROR; - errorStart = extendsToken.sourceEnd+1; - errorEnd = extendsToken.sourceEnd+1; - processParseExceptionDebug(e); - superclassNameImage = SYNTAX_ERROR_CHAR; - } - ] - { - int start, end; - if (className == null) { - start = token.sourceStart; - end = token.sourceEnd; - } else { - start = className.sourceStart; - end = className.sourceEnd; - } - if (superclassNameImage == null) { - - classDeclaration = new ClassDeclaration(currentSegment, - classNameImage, - start, - end); - } else { - classDeclaration = new ClassDeclaration(currentSegment, - classNameImage, - superclassNameImage, - start, - end); - } - currentSegment.add(classDeclaration); - currentSegment = classDeclaration; - } - classEnd = ClassBody(classDeclaration) - {currentSegment = (OutlineableWithChildren) currentSegment.getParent(); - classDeclaration.sourceEnd = classEnd; - pushOnAstNodes(classDeclaration); - return classDeclaration;} -} - -int ClassBody(final ClassDeclaration classDeclaration) : -{ -Token token; -} -{ - try { - - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image + "'. '{' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - ( ClassBodyDeclaration(classDeclaration) )* - try { - token = - {return token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. 'var', 'function' or '}' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - return this.token.sourceEnd; - } -} - -/** - * A class can contain only methods and fields. - */ -void ClassBodyDeclaration(final ClassDeclaration classDeclaration) : -{ - final MethodDeclaration method; - final FieldDeclaration field; -} -{ - method = MethodDeclaration() {method.analyzeCode(); - classDeclaration.addMethod(method);} -| field = FieldDeclaration() {classDeclaration.addField(field);} -} - -/** - * A class field declaration : it's var VariableDeclarator() (, VariableDeclarator())*;. - * it is only used by ClassBodyDeclaration() - */ -FieldDeclaration FieldDeclaration() : -{ - VariableDeclaration variableDeclaration; - final VariableDeclaration[] list; - final ArrayList arrayList = new ArrayList(); - final Token token; - Token token2 = null; - int pos; -} -{ - token = variableDeclaration = VariableDeclaratorNoSuffix() - { - arrayList.add(variableDeclaration); - pos = variableDeclaration.sourceEnd; - } - ( - variableDeclaration = VariableDeclaratorNoSuffix() - { - arrayList.add(variableDeclaration); - outlineInfo.addVariable(variableDeclaration.name()); - pos = variableDeclaration.sourceEnd; - } - )* - try { - token2 = - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected after variable declaration"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseExceptionDebug(e); - } - - {list = new VariableDeclaration[arrayList.size()]; - arrayList.toArray(list); - int end; - if (token2 == null) { - end = list[list.length-1].sourceEnd; - } else { - end = token2.sourceEnd; - } - return new FieldDeclaration(list, - token.sourceStart, - end, - currentSegment);} -} - -/** - * a strict variable declarator : there cannot be a suffix here. - * It will be used by fields and formal parameters - */ -VariableDeclaration VariableDeclaratorNoSuffix() : -{ - final Token token, lbrace,rbrace; - Expression expr, initializer = null; - Token assignToken; - Variable variable; -} -{ - - ( - token = - {variable = new Variable(token.image,token.sourceStart,token.sourceEnd);} - | - lbrace = expr = Expression() rbrace = - {variable = new Variable(expr,lbrace.sourceStart,rbrace.sourceEnd);} - ) - [ - assignToken = - try { - initializer = VariableInitializer() - } catch (ParseException e) { - errorMessage = "Literal expression expected in variable initializer"; - errorLevel = ERROR; - errorStart = assignToken.sourceEnd +1; - errorEnd = assignToken.sourceEnd +1; - processParseExceptionDebug(e); - } - ] - { - if (initializer == null) { - return new VariableDeclaration(currentSegment, - variable, - variable.sourceStart, - variable.sourceEnd); - } - return new VariableDeclaration(currentSegment, - variable, - initializer, - VariableDeclaration.EQUAL, - variable.sourceStart); - } -} - -/** - * this will be used by static statement - */ -VariableDeclaration VariableDeclarator() : -{ - final AbstractVariable variable; - Expression initializer = null; - final Token token; -} -{ - variable = VariableDeclaratorId() - [ - token = - try { - initializer = VariableInitializer() - } catch (ParseException e) { - errorMessage = "Literal expression expected in variable initializer"; - errorLevel = ERROR; - errorStart = token.sourceEnd+1; - errorEnd = token.sourceEnd+1; - processParseExceptionDebug(e); - } - ] - { - if (initializer == null) { - return new VariableDeclaration(currentSegment, - variable, - variable.sourceStart, - variable.sourceEnd); - } - return new VariableDeclaration(currentSegment, - variable, - initializer, - VariableDeclaration.EQUAL, - variable.sourceStart); - } -} - -/** - * A Variable name. - * @return the variable name (with suffix) - */ -AbstractVariable VariableDeclaratorId() : -{ - AbstractVariable var; -} -{ - try { - var = Variable() - ( - LOOKAHEAD(2) - var = VariableSuffix(var) - )* - { - return var; - } - } catch (ParseException e) { - errorMessage = "'$' expected for variable identifier"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } -} - -Variable Variable() : -{ - Variable variable = null; - final Token token; -} -{ - token = variable = Var() - { - return variable; - } -} - -Variable Var() : -{ - Variable variable = null; - final Token token,token2; - ConstantIdentifier constant; - Expression expression; -} -{ - token = variable = Var() - {return new Variable(variable,variable.sourceStart,variable.sourceEnd);} -| - token = expression = Expression() token2 = - { - return new Variable(expression, - token.sourceStart, - token2.sourceEnd); - } -| - token = - { - outlineInfo.addVariable('$' + token.image); - return new Variable(token.image,token.sourceStart,token.sourceEnd); - } -} - -Expression VariableInitializer() : -{ - final Expression expr; - final Token token, token2; -} -{ - expr = Literal() - {return expr;} -| - token2 = (token = | token = ) - {return new PrefixedUnaryExpression(new NumberLiteral(token), - OperatorIds.MINUS, - token2.sourceStart);} -| - token2 = (token = | token = ) - {return new PrefixedUnaryExpression(new NumberLiteral(token), - OperatorIds.PLUS, - token2.sourceStart);} -| - expr = ArrayDeclarator() - {return expr;} -| - token = - {return new ConstantIdentifier(token);} -} - -ArrayVariableDeclaration ArrayVariable() : -{ -final Expression expr,expr2; -} -{ - expr = Expression() - [ - expr2 = Expression() - {return new ArrayVariableDeclaration(expr,expr2);} - ] - {return new ArrayVariableDeclaration(expr,jj_input_stream.getPosition());} -} - -ArrayVariableDeclaration[] ArrayInitializer() : -{ - ArrayVariableDeclaration expr; - final ArrayList list = new ArrayList(); -} -{ - - [ - expr = ArrayVariable() - {list.add(expr);} - ( LOOKAHEAD(2) expr = ArrayVariable() - {list.add(expr);} - )* - ] - [ - {list.add(null);} - ] - - { - final ArrayVariableDeclaration[] vars = new ArrayVariableDeclaration[list.size()]; - list.toArray(vars); - return vars;} -} - -/** - * A Method Declaration. - * function MetodDeclarator() Block() - */ -MethodDeclaration MethodDeclaration() : -{ - final MethodDeclaration functionDeclaration; - final Block block; - final OutlineableWithChildren seg = currentSegment; - final Token token; -} -{ - token = - try { - functionDeclaration = MethodDeclarator(token.sourceStart) - {outlineInfo.addVariable(functionDeclaration.name);} - } catch (ParseException e) { - if (errorMessage != null) throw e; - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } - {currentSegment = functionDeclaration;} - block = Block() - {functionDeclaration.statements = block.statements; - currentSegment = seg; - return functionDeclaration;} -} - -/** - * A MethodDeclarator. - * [&] IDENTIFIER(parameters ...). - * @return a function description for the outline - */ -MethodDeclaration MethodDeclarator(final int start) : -{ - Token identifier = null; - Token reference = null; - final ArrayList formalParameters = new ArrayList(); - String identifierChar = SYNTAX_ERROR_CHAR; - int end = start; -} -{ - [reference = {end = reference.sourceEnd;}] - try { - identifier = - { - identifierChar = identifier.image; - end = identifier.sourceEnd; - } - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceEnd; - errorEnd = e.currentToken.next.sourceStart; - processParseExceptionDebug(e); - } - end = FormalParameters(formalParameters) - { - int nameStart, nameEnd; - if (identifier == null) { - if (reference == null) { - nameStart = start + 9; - nameEnd = start + 10; - } else { - nameStart = reference.sourceEnd + 1; - nameEnd = reference.sourceEnd + 2; - } - } else { - nameStart = identifier.sourceStart; - nameEnd = identifier.sourceEnd; - } - return new MethodDeclaration(currentSegment, - identifierChar, - formalParameters, - reference != null, - nameStart, - nameEnd, - start, - end); - } -} - -/** - * FormalParameters follows method identifier. - * (FormalParameter()) - */ -int FormalParameters(final ArrayList parameters) : -{ - VariableDeclaration var; - final Token token; - Token tok = this.token; - int end = tok.sourceEnd; -} -{ - try { - tok = - {end = tok.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier"; - errorLevel = ERROR; - errorStart = e.currentToken.next.sourceStart; - errorEnd = e.currentToken.next.sourceEnd; - processParseExceptionDebug(e); - } - [ - var = FormalParameter() - {parameters.add(var);end = var.sourceEnd;} - ( - var = FormalParameter() - {parameters.add(var);end = var.sourceEnd;} - )* - ] - try { - token = - {end = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "')' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.next.sourceStart; - errorEnd = e.currentToken.next.sourceEnd; - processParseExceptionDebug(e); - } - {return end;} -} - -/** - * A formal parameter. - * $varname[=value] (,$varname[=value]) - */ -VariableDeclaration FormalParameter() : -{ - final VariableDeclaration variableDeclaration; - Token token = null; -} -{ - [token = ] variableDeclaration = VariableDeclaratorNoSuffix() - { - outlineInfo.addVariable('$'+variableDeclaration.name()); - if (token != null) { - variableDeclaration.setReference(true); - } - return variableDeclaration;} -} - -ConstantIdentifier Type() : -{final Token token;} -{ - token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -| token = {return new ConstantIdentifier(token);} -} - -Expression Expression() : -{ - final Expression expr; - Expression initializer = null; - int assignOperator = -1; -} -{ - LOOKAHEAD(1) - expr = ConditionalExpression() - [ - assignOperator = AssignmentOperator() - try { - initializer = Expression() - } catch (ParseException e) { - if (errorMessage != null) { - throw e; - } - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorEnd = jj_input_stream.getPosition(); - throw e; - } - ] - { - if (assignOperator != -1) {// todo : change this, very very bad :( - if (expr instanceof AbstractVariable) { - return new VariableDeclaration(currentSegment, - (AbstractVariable) expr, - initializer, - expr.sourceStart, - initializer.sourceEnd); - } - String varName = expr.toStringExpression().substring(1); - return new VariableDeclaration(currentSegment, - new Variable(varName, - expr.sourceStart, - expr.sourceEnd), - expr.sourceStart, - initializer.sourceEnd); - } - return expr; - } -| expr = ExpressionWBang() {return expr;} -} - -Expression ExpressionWBang() : -{ - final Expression expr; - final Token token; -} -{ - token = expr = ExpressionWBang() - {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,token.sourceStart);} -| expr = ExpressionNoBang() {return expr;} -} - -Expression ExpressionNoBang() : -{ - Expression expr; -} -{ - expr = ListExpression() {return expr;} -| - expr = PrintExpression() {return expr;} -} - -/** - * Any assignement operator. - * @return the assignement operator id - */ -int AssignmentOperator() : -{} -{ - {return VariableDeclaration.EQUAL;} -| {return VariableDeclaration.STAR_EQUAL;} -| {return VariableDeclaration.SLASH_EQUAL;} -| {return VariableDeclaration.REM_EQUAL;} -| {return VariableDeclaration.PLUS_EQUAL;} -| {return VariableDeclaration.MINUS_EQUAL;} -| {return VariableDeclaration.LSHIFT_EQUAL;} -| {return VariableDeclaration.RSIGNEDSHIFT_EQUAL;} -| {return VariableDeclaration.AND_EQUAL;} -| {return VariableDeclaration.XOR_EQUAL;} -| {return VariableDeclaration.OR_EQUAL;} -| {return VariableDeclaration.DOT_EQUAL;} -| {return VariableDeclaration.TILDE_EQUAL;} -} - -Expression ConditionalExpression() : -{ - final Expression expr; - Expression expr2 = null; - Expression expr3 = null; -} -{ - expr = ConditionalOrExpression() [ expr2 = Expression() expr3 = ConditionalExpression() ] -{ - if (expr3 == null) { - return expr; - } - return new ConditionalExpression(expr,expr2,expr3); -} -} - -Expression ConditionalOrExpression() : -{ - Expression expr,expr2; - int operator; -} -{ - expr = ConditionalAndExpression() - ( - ( - {operator = OperatorIds.OR_OR;} - | <_ORL> {operator = OperatorIds.ORL;} - ) - expr2 = ConditionalAndExpression() - { - expr = new BinaryExpression(expr,expr2,operator); - } - )* - {return expr;} -} - -Expression ConditionalAndExpression() : -{ - Expression expr,expr2; - int operator; -} -{ - expr = ConcatExpression() - ( - ( {operator = OperatorIds.AND_AND;} - | <_ANDL> {operator = OperatorIds.ANDL;}) - expr2 = ConcatExpression() {expr = new BinaryExpression(expr,expr2,operator);} - )* - {return expr;} -} - -Expression ConcatExpression() : -{ - Expression expr,expr2; -} -{ - expr = InclusiveOrExpression() - ( - expr2 = InclusiveOrExpression() - {expr = new BinaryExpression(expr,expr2,OperatorIds.DOT);} - )* - {return expr;} -} - -Expression InclusiveOrExpression() : -{ - Expression expr,expr2; -} -{ - expr = ExclusiveOrExpression() - ( expr2 = ExclusiveOrExpression() - {expr = new BinaryExpression(expr,expr2,OperatorIds.OR);} - )* - {return expr;} -} - -Expression ExclusiveOrExpression() : -{ - Expression expr,expr2; -} -{ - expr = AndExpression() - ( - expr2 = AndExpression() - {expr = new BinaryExpression(expr,expr2,OperatorIds.XOR);} - )* - {return expr;} -} - -Expression AndExpression() : -{ - Expression expr,expr2; -} -{ - expr = EqualityExpression() - ( - LOOKAHEAD(1) - expr2 = EqualityExpression() - {expr = new BinaryExpression(expr,expr2,OperatorIds.AND);} - )* - {return expr;} -} - -Expression EqualityExpression() : -{ - Expression expr,expr2; - int operator; - Token token; -} -{ - expr = RelationalExpression() - ( - ( token = {operator = OperatorIds.EQUAL_EQUAL;} - | token = {operator = OperatorIds.DIF;} - | token = {operator = OperatorIds.DIF;} - | token = {operator = OperatorIds.BANG_EQUAL_EQUAL;} - | token = {operator = OperatorIds.EQUAL_EQUAL_EQUAL;} - ) - try { - expr2 = RelationalExpression() - } catch (ParseException e) { - if (errorMessage != null) { - throw e; - } - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorStart = token.sourceEnd +1; - errorEnd = token.sourceEnd +1; - expr2 = new ConstantIdentifier(SYNTAX_ERROR_CHAR,token.sourceEnd +1,token.sourceEnd +1); - processParseExceptionDebug(e); - } - { - expr = new BinaryExpression(expr,expr2,operator); - } - )* - {return expr;} -} - -Expression RelationalExpression() : -{ - Expression expr,expr2; - int operator; -} -{ - expr = ShiftExpression() - ( - ( {operator = OperatorIds.LESS;} - | {operator = OperatorIds.GREATER;} - | {operator = OperatorIds.LESS_EQUAL;} - | {operator = OperatorIds.GREATER_EQUAL;}) - expr2 = ShiftExpression() - {expr = new BinaryExpression(expr,expr2,operator);} - )* - {return expr;} -} - -Expression ShiftExpression() : -{ - Expression expr,expr2; - int operator; -} -{ - expr = AdditiveExpression() - ( - ( {operator = OperatorIds.LEFT_SHIFT;} - | {operator = OperatorIds.RIGHT_SHIFT;} - | {operator = OperatorIds.UNSIGNED_RIGHT_SHIFT;}) - expr2 = AdditiveExpression() - {expr = new BinaryExpression(expr,expr2,operator);} - )* - {return expr;} -} - -Expression AdditiveExpression() : -{ - Expression expr,expr2; - int operator; -} -{ - expr = MultiplicativeExpression() - ( - LOOKAHEAD(1) - ( {operator = OperatorIds.PLUS;} - | {operator = OperatorIds.MINUS;} - ) - expr2 = MultiplicativeExpression() - {expr = new BinaryExpression(expr,expr2,operator);} - )* - {return expr;} -} - -Expression MultiplicativeExpression() : -{ - Expression expr,expr2; - int operator; -} -{ - try { - expr = UnaryExpression() - } catch (ParseException e) { - if (errorMessage != null) throw e; - errorMessage = "unexpected token '"+e.currentToken.next.image+'\''; - errorLevel = ERROR; - errorStart = this.token.sourceStart; - errorEnd = this.token.sourceEnd; - throw e; - } - ( - ( {operator = OperatorIds.MULTIPLY;} - | {operator = OperatorIds.DIVIDE;} - | {operator = OperatorIds.REMAINDER;}) - expr2 = UnaryExpression() - {expr = new BinaryExpression(expr,expr2,operator);} - )* - {return expr;} -} - -/** - * An unary expression starting with @, & or nothing - */ -Expression UnaryExpression() : -{ - final Expression expr; -} -{ - /* expr = UnaryExpressionNoPrefix() //why did I had that ? - {return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);} -| */ - expr = AtNotTildeUnaryExpression() {return expr;} -} - -Expression AtNotTildeUnaryExpression() : -{ - final Expression expr; - final Token token; -} -{ - token = - expr = AtNotTildeUnaryExpression() - {return new PrefixedUnaryExpression(expr,OperatorIds.AT,token.sourceStart);} -| - token = - expr = AtNotTildeUnaryExpression() - {return new PrefixedUnaryExpression(expr,OperatorIds.TWIDDLE,token.sourceStart);} -| - token = - expr = AtNotUnaryExpression() - {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,token.sourceStart);} -| - expr = UnaryExpressionNoPrefix() - {return expr;} -} - -/** - * An expression prefixed (or not) by one or more @ and !. - * @return the expression - */ -Expression AtNotUnaryExpression() : -{ - final Expression expr; - final Token token; -} -{ - token = - expr = AtNotUnaryExpression() - {return new PrefixedUnaryExpression(expr,OperatorIds.AT,token.sourceStart);} -| - token = - expr = AtNotUnaryExpression() - {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,token.sourceStart);} -| - expr = UnaryExpressionNoPrefix() - {return expr;} -} - -Expression UnaryExpressionNoPrefix() : -{ - final Expression expr; - final Token token; -} -{ - token = expr = AtNotTildeUnaryExpression() {return new PrefixedUnaryExpression(expr, - OperatorIds.PLUS, - token.sourceStart);} -| - token = expr = AtNotTildeUnaryExpression() {return new PrefixedUnaryExpression(expr, - OperatorIds.MINUS, - token.sourceStart);} -| - expr = PreIncDecExpression() - {return expr;} -| - expr = UnaryExpressionNotPlusMinus() - {return expr;} -} - - -Expression PreIncDecExpression() : -{ -final Expression expr; -final int operator; -final Token token; -} -{ - ( - token = {operator = OperatorIds.PLUS_PLUS;} - | - token = {operator = OperatorIds.MINUS_MINUS;} - ) - expr = PrimaryExpression() - {return new PrefixedUnaryExpression(expr,operator,token.sourceStart);} -} - -Expression UnaryExpressionNotPlusMinus() : -{ - final Expression expr; -} -{ - LOOKAHEAD( (Type() | ) ) - expr = CastExpression() {return expr;} -| expr = PostfixExpression() {return expr;} -| expr = Literal() {return expr;} -| expr = Expression() - try { - - } catch (ParseException e) { - errorMessage = "')' expected"; - errorLevel = ERROR; - errorStart = expr.sourceEnd +1; - errorEnd = expr.sourceEnd +1; - processParseExceptionDebug(e); - } - {return expr;} -} - -CastExpression CastExpression() : -{ -final ConstantIdentifier type; -final Expression expr; -final Token token,token1; -} -{ - token1 = - ( - type = Type() - | - token = {type = new ConstantIdentifier(token);} - ) - expr = UnaryExpression() - {return new CastExpression(type,expr,token1.sourceStart,expr.sourceEnd);} -} - -Expression PostfixExpression() : -{ - final Expression expr; - int operator = -1; - Token token = null; -} -{ - expr = PrimaryExpression() - [ - token = {operator = OperatorIds.PLUS_PLUS;} - | - token = {operator = OperatorIds.MINUS_MINUS;} - ] - { - if (operator == -1) { - return expr; - } - return new PostfixedUnaryExpression(expr,operator,token.sourceEnd); - } -} - -Expression PrimaryExpression() : -{ - Expression expr; - Token token = null; -} -{ - [token = ] expr = refPrimaryExpression(token) - {return expr;} -| - expr = ArrayDeclarator() - {return expr;} -} - -Expression refPrimaryExpression(final Token reference) : -{ - Expression expr; - Expression expr2 = null; - final Token identifier; -} -{ - identifier = - { - expr = new ConstantIdentifier(identifier); - } - ( - expr2 = ClassIdentifier() - {expr = new ClassAccess(expr, - expr2, - ClassAccess.STATIC);} - )* - [ expr2 = Arguments(expr) ] - { - if (expr2 == null) { - if (reference != null) { - ParseException e = generateParseException(); - errorMessage = "you cannot use a constant by reference"; - errorLevel = ERROR; - errorStart = reference.sourceStart; - errorEnd = reference.sourceEnd; - processParseExceptionDebug(e); - } - return expr; - } - return expr2; - } -| - expr = VariableDeclaratorId() //todo use the reference parameter ... - [ expr = Arguments(expr) ] - {return expr;} -| - token = - expr = ClassIdentifier() - { - int start; - if (reference == null) { - start = token.sourceStart; - } else { - start = reference.sourceStart; - } - expr = new ClassInstantiation(expr, - reference != null, - start); - } - [ expr = Arguments(expr) ] - {return expr;} -} - -/** - * An array declarator. - * array(vars) - * @return an array - */ -ArrayInitializer ArrayDeclarator() : -{ - final ArrayVariableDeclaration[] vars; - final Token token; -} -{ - token = vars = ArrayInitializer() - {return new ArrayInitializer(vars, - token.sourceStart, - this.token.sourceEnd);} -} - -Expression ClassIdentifier(): -{ - final Expression expr; - final Token token; -} -{ - token = {return new ConstantIdentifier(token);} -| expr = Type() {return expr;} -| expr = VariableDeclaratorId() {return expr;} -} - -/** - * Used by Variabledeclaratorid and primarysuffix - */ -AbstractVariable VariableSuffix(final AbstractVariable prefix) : -{ - Expression expression = null; - final Token classAccessToken,lbrace,rbrace; - Token token; - int pos; -} -{ - classAccessToken = - try { - ( - lbrace = expression = Expression() rbrace = - { - expression = new Variable(expression, - lbrace.sourceStart, - rbrace.sourceEnd); - } - | - token = - {expression = new ConstantIdentifier(token.image,token.sourceStart,token.sourceEnd);} - | - expression = Variable() - ) - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected"; - errorLevel = ERROR; - errorStart = classAccessToken.sourceEnd +1; - errorEnd = classAccessToken.sourceEnd +1; - processParseExceptionDebug(e); - } - {return new ClassAccess(prefix, - expression, - ClassAccess.NORMAL);} -| - token = {pos = token.sourceEnd+1;} - [ expression = Expression() {pos = expression.sourceEnd+1;} - | expression = Type() {pos = expression.sourceEnd+1;}] //Not good - try { - token = - {pos = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "']' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - {return new ArrayDeclarator(prefix,expression,pos);} -| - token = {pos = token.sourceEnd+1;} - [ expression = Expression() {pos = expression.sourceEnd+1;} - | expression = Type() {pos = expression.sourceEnd+1;}] //Not good - try { - token = - {pos = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "']' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - {return new ArrayDeclarator(prefix,expression,pos);}//todo : check braces here -} - -Literal Literal() : -{ - final Token token; - StringLiteral literal; -} -{ - token = {return new NumberLiteral(token);} -| token = {return new NumberLiteral(token);} -| token = {return new StringLiteral(token);} -| token = {return new TrueLiteral(token);} -| token = {return new FalseLiteral(token);} -| token = {return new NullLiteral(token);} -| literal = evaluableString() {return literal;} -} - -StringLiteral evaluableString() : -{ - ArrayList list = new ArrayList(); - Token start,end; - Token token,lbrace,rbrace; - AbstractVariable var; - Expression expr; -} -{ - start = - ( - - ( - token = {list.add(new Variable(token.image, - token.sourceStart, - token.sourceEnd));} - | - lbrace = - token = - {list.add(new Variable(token.image, - token.sourceStart, - token.sourceEnd));} - rbrace = - ) - )* - end = - { - AbstractVariable[] vars = new AbstractVariable[list.size()]; - list.toArray(vars); - return new StringLiteral(jj_input_stream.getCurrentBuffer().substring(start.sourceEnd,end.sourceStart), - start.sourceStart, - end.sourceEnd, - vars); - } -} - -FunctionCall Arguments(final Expression func) : -{ -Expression[] args = null; -final Token token,lparen; -} -{ - lparen = [ args = ArgumentList() ] - try { - token = - {return new FunctionCall(func,args,token.sourceEnd);} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list"; - errorLevel = ERROR; - if (args == null) { - errorStart = lparen.sourceEnd+1; - errorEnd = lparen.sourceEnd+2; - } else { - errorStart = args[args.length-1].sourceEnd+1; - errorEnd = args[args.length-1].sourceEnd+2; - } - processParseExceptionDebug(e); - } - { - int sourceEnd = (args == null && args.length != 0) ? lparen.sourceEnd+1 : args[args.length-1].sourceEnd; - return new FunctionCall(func,args,sourceEnd);} -} - -/** - * An argument list is a list of arguments separated by comma : - * argumentDeclaration() (, argumentDeclaration)* - * @return an array of arguments - */ -Expression[] ArgumentList() : -{ -Expression arg; -final ArrayList list = new ArrayList(); -int pos; -Token token; -} -{ - arg = Expression() - {list.add(arg);pos = arg.sourceEnd;} - ( token = {pos = token.sourceEnd;} - try { - arg = Expression() - {list.add(arg); - pos = arg.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseException(e); - } - )* - { - final Expression[] arguments = new Expression[list.size()]; - list.toArray(arguments); - return arguments;} -} - -/** - * A Statement without break. - * @return a statement - */ -Statement StatementNoBreak() : -{ - final Statement statement; - Token token = null; -} -{ - LOOKAHEAD(2) - statement = expressionStatement() {return statement;} -| LOOKAHEAD(1) - statement = LabeledStatement() {return statement;} -| statement = Block() {return statement;} -| statement = EmptyStatement() {return statement;} -| statement = SwitchStatement() {return statement;} -| statement = IfStatement() {return statement;} -| statement = WhileStatement() {return statement;} -| statement = DoStatement() {return statement;} -| statement = ForStatement() {return statement;} -| statement = ForeachStatement() {return statement;} -| statement = ContinueStatement() {return statement;} -| statement = ReturnStatement() {return statement;} -| statement = EchoStatement() {return statement;} -| [token=] statement = IncludeStatement() - {if (token != null) { - ((InclusionStatement)statement).silent = true; - statement.sourceStart = token.sourceStart; - } - return statement;} -| statement = StaticStatement() {return statement;} -| statement = GlobalStatement() {return statement;} -| statement = defineStatement() {currentSegment.add((Outlineable)statement);return statement;} -} - -/** - * A statement expression. - * expression ; - * @return an expression - */ -Statement expressionStatement() : -{ - final Statement statement; - final Token token; -} -{ - statement = Expression() - try { - token = - {statement.sourceEnd = token.sourceEnd;} - } catch (ParseException e) { - if (e.currentToken.next.kind != PHPParserConstants.PHPEND) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; - errorLevel = ERROR; - errorStart = statement.sourceEnd+1; - errorEnd = statement.sourceEnd+1; - processParseExceptionDebug(e); - } - } - {return statement;} -} - -Define defineStatement() : -{ - Expression defineName,defineValue; - final Token defineToken; - Token token; - int pos; -} -{ - defineToken = {pos = defineToken.sourceEnd+1;} - try { - token = - {pos = token.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - try { - defineName = Expression() - {pos = defineName.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - defineName = new StringLiteral(SYNTAX_ERROR_CHAR,pos,pos); - } - try { - token = - {pos = defineName.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - try { - defineValue = Expression() - {pos = defineValue.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - defineValue = new StringLiteral(SYNTAX_ERROR_CHAR,pos,pos); - } - try { - token = - {pos = token.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - {return new Define(currentSegment, - defineName, - defineValue, - defineToken.sourceStart, - pos);} -} - -/** - * A Normal statement. - */ -Statement Statement() : -{ - final Statement statement; -} -{ - statement = StatementNoBreak() {return statement;} -| statement = BreakStatement() {return statement;} -} - -/** - * An html block inside a php syntax. - */ -HTMLBlock htmlBlock() : -{ - final int startIndex = nodePtr; - final AstNode[] blockNodes; - final int nbNodes; - final Token phpEnd; -} -{ - phpEnd = - {htmlStart = phpEnd.sourceEnd;} - (phpEchoBlock())* - try { - ( | ) - {createNewHTMLCode();} - } catch (ParseException e) { - errorMessage = "unexpected end of file , ' {keyword = InclusionStatement.REQUIRE;pos=token.sourceEnd;} - | token = {keyword = InclusionStatement.REQUIRE_ONCE;pos=token.sourceEnd;} - | token = {keyword = InclusionStatement.INCLUDE;pos=token.sourceEnd;} - | token = {keyword = InclusionStatement.INCLUDE_ONCE;pos=token.sourceEnd;}) - try { - expr = Expression() - {pos = expr.sourceEnd;} - } catch (ParseException e) { - if (errorMessage != null) { - throw e; - } - errorMessage = "unexpected token '"+ e.currentToken.next.image+"', expression expected"; - errorLevel = ERROR; - errorStart = e.currentToken.next.sourceStart; - errorEnd = e.currentToken.next.sourceEnd; - expr = new ConstantIdentifier(SYNTAX_ERROR_CHAR,pos,pos); - processParseExceptionDebug(e); - } - try { - token2 = - {pos=token2.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; - errorLevel = ERROR; - errorStart = e.currentToken.next.sourceStart; - errorEnd = e.currentToken.next.sourceEnd; - processParseExceptionDebug(e); - } - { - inclusionStatement = new InclusionStatement(currentSegment, - keyword, - expr, - token.sourceStart, - pos); - currentSegment.add(inclusionStatement); - return inclusionStatement; - } -} - -PrintExpression PrintExpression() : -{ - final Expression expr; - final Token printToken; -} -{ - token = expr = Expression() - {return new PrintExpression(expr,token.sourceStart,expr.sourceEnd);} -} - -ListExpression ListExpression() : -{ - Expression expr = null; - final Expression expression; - final ArrayList list = new ArrayList(); - int pos; - final Token listToken, rParen; - Token token; -} -{ - listToken = {pos = listToken.sourceEnd;} - try { - token = {pos = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected"; - errorLevel = ERROR; - errorStart = listToken.sourceEnd+1; - errorEnd = listToken.sourceEnd+1; - processParseExceptionDebug(e); - } - [ - expr = VariableDeclaratorId() - {list.add(expr);pos = expr.sourceEnd;} - ] - {if (expr == null) list.add(null);} - ( - try { - token = - {pos = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseExceptionDebug(e); - } - [expr = VariableDeclaratorId() {list.add(expr);pos = expr.sourceEnd;}] - )* - try { - rParen = - {pos = rParen.sourceEnd;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseExceptionDebug(e); - } - [ expression = Expression() - { - final AbstractVariable[] vars = new AbstractVariable[list.size()]; - list.toArray(vars); - return new ListExpression(vars, - expression, - listToken.sourceStart, - expression.sourceEnd);} - ] - { - final AbstractVariable[] vars = new AbstractVariable[list.size()]; - list.toArray(vars); - return new ListExpression(vars,listToken.sourceStart,pos);} -} - -/** - * An echo statement. - * echo anyexpression (, otherexpression)* - */ -EchoStatement EchoStatement() : -{ - final ArrayList expressions = new ArrayList(); - Expression expr; - Token token; - Token token2 = null; -} -{ - token = expr = Expression() - {expressions.add(expr);} - ( - expr = Expression() - {expressions.add(expr);} - )* - try { - token2 = - } catch (ParseException e) { - if (e.currentToken.next.kind != 4) { - errorMessage = "';' expected after 'echo' statement"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceEnd; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - } - { - final Expression[] exprs = new Expression[expressions.size()]; - expressions.toArray(exprs); - if (token2 == null) { - return new EchoStatement(exprs,token.sourceStart, exprs[exprs.length-1].sourceEnd); - } - return new EchoStatement(exprs,token.sourceStart, token2.sourceEnd); - } -} - -GlobalStatement GlobalStatement() : -{ - Variable expr; - final ArrayList vars = new ArrayList(); - final GlobalStatement global; - final Token token, token2; - int pos; -} -{ - token = - expr = Variable() - {vars.add(expr);pos = expr.sourceEnd+1;} - ( - expr = Variable() - {vars.add(expr);pos = expr.sourceEnd+1;} - )* - try { - token2 = - {pos = token2.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - { - final Variable[] variables = new Variable[vars.size()]; - vars.toArray(variables); - global = new GlobalStatement(currentSegment, - variables, - token.sourceStart, - pos); - currentSegment.add(global); - return global;} -} - -StaticStatement StaticStatement() : -{ - final ArrayList vars = new ArrayList(); - VariableDeclaration expr; - final Token token, token2; - int pos; -} -{ - token = expr = VariableDeclarator() {vars.add(expr);pos = expr.sourceEnd+1;} - ( - expr = VariableDeclarator() {vars.add(expr);pos = expr.sourceEnd+1;} - )* - try { - token2 = - {pos = token2.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseException(e); - } - { - final VariableDeclaration[] variables = new VariableDeclaration[vars.size()]; - vars.toArray(variables); - return new StaticStatement(variables, - token.sourceStart, - pos);} -} - -LabeledStatement LabeledStatement() : -{ - final Token label; - final Statement statement; -} -{ - label = statement = Statement() - {return new LabeledStatement(label.image,statement,label.sourceStart,statement.sourceEnd);} -} - -/** - * A Block is - * { - * statements - * }. - * @return a block - */ -Block Block() : -{ - final ArrayList list = new ArrayList(); - Statement statement; - final Token token, token2; - int pos,start; -} -{ - try { - token = - {pos = token.sourceEnd+1;start=token.sourceStart;} - } catch (ParseException e) { - errorMessage = "'{' expected"; - errorLevel = ERROR; - pos = this.token.sourceEnd+1; - start=pos; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - ( statement = BlockStatement() {list.add(statement);pos = statement.sourceEnd+1;} - | statement = htmlBlock() {if (statement != null) { - list.add(statement); - pos = statement.sourceEnd+1; - } - pos = this.token.sourceEnd+1; - } - )* - try { - token2 = - {pos = token2.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.image +"', '}' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - { - final Statement[] statements = new Statement[list.size()]; - list.toArray(statements); - return new Block(statements,start,pos);} -} - -Statement BlockStatement() : -{ - final Statement statement; -} -{ - try { - statement = Statement() {if (phpDocument == currentSegment) pushOnAstNodes(statement); - return statement;} - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.image +"', a statement was expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } -| statement = ClassDeclaration() {return statement;} -| statement = MethodDeclaration() {if (phpDocument == currentSegment) pushOnAstNodes(statement); - currentSegment.add((MethodDeclaration) statement); - ((MethodDeclaration) statement).analyzeCode(); - return statement;} -} - -/** - * A Block statement that will not contain any 'break' - */ -Statement BlockStatementNoBreak() : -{ - final Statement statement; -} -{ - statement = StatementNoBreak() {return statement;} -| statement = ClassDeclaration() {return statement;} -| statement = MethodDeclaration() {currentSegment.add((MethodDeclaration) statement); - ((MethodDeclaration) statement).analyzeCode(); - return statement;} -} - -/** - * used only by ForInit() - */ -Expression[] LocalVariableDeclaration() : -{ - final ArrayList list = new ArrayList(); - Expression var; -} -{ - var = Expression() - {list.add(var);} - ( var = Expression() {list.add(var);})* - { - final Expression[] vars = new Expression[list.size()]; - list.toArray(vars); - return vars; - } -} - -/** - * used only by LocalVariableDeclaration(). - */ -VariableDeclaration LocalVariableDeclarator() : -{ - final Variable varName; - Expression initializer = null; -} -{ - varName = Variable() [ initializer = Expression() ] - { - if (initializer == null) { - return new VariableDeclaration(currentSegment, - varName, - varName.sourceStart, - varName.sourceEnd); - } - return new VariableDeclaration(currentSegment, - varName, - initializer, - VariableDeclaration.EQUAL, - varName.sourceStart); - } -} - -EmptyStatement EmptyStatement() : -{ - final Token token; -} -{ - token = - {return new EmptyStatement(token.sourceStart,token.sourceEnd);} -} - -/** - * used only by StatementExpressionList() which is used only by ForInit() and ForStatement() - */ -Expression StatementExpression() : -{ - final Expression expr; - final Token operator; -} -{ - expr = PreIncDecExpression() {return expr;} -| - expr = PrimaryExpression() - [ operator = {return new PostfixedUnaryExpression(expr, - OperatorIds.PLUS_PLUS, - operator.sourceEnd);} - | operator = {return new PostfixedUnaryExpression(expr, - OperatorIds.MINUS_MINUS, - operator.sourceEnd);} - ] - {return expr;} -} - -SwitchStatement SwitchStatement() : -{ - Expression variable; - final AbstractCase[] cases; - final Token switchToken,lparenToken,rparenToken; - int pos; -} -{ - switchToken = {pos = switchToken.sourceEnd+1;} - try { - lparenToken = - {pos = lparenToken.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "'(' expected after 'switch'"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - try { - variable = Expression() {pos = variable.sourceEnd+1;} - } catch (ParseException e) { - if (errorMessage != null) { - throw e; - } - errorMessage = "expression expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - variable = new ConstantIdentifier(SYNTAX_ERROR_CHAR,pos,pos); - } - try { - rparenToken = {pos = rparenToken.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "')' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - ( cases = switchStatementBrace() - | cases = switchStatementColon(switchToken.sourceStart, switchToken.sourceEnd)) - {return new SwitchStatement(variable, - cases, - switchToken.sourceStart, - this.token.sourceEnd);} -} - -AbstractCase[] switchStatementBrace() : -{ - AbstractCase cas; - final ArrayList cases = new ArrayList(); - Token token; - int pos; -} -{ - token = {pos = token.sourceEnd;} - ( cas = switchLabel0() {cases.add(cas);pos = cas.sourceEnd;})* - try { - token = - {pos = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "'}' expected"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseExceptionDebug(e); - } - { - final AbstractCase[] abcase = new AbstractCase[cases.size()]; - cases.toArray(abcase); - return abcase; - } -} - -/** - * A Switch statement with : ... endswitch; - * @param start the begin offset of the switch - * @param end the end offset of the switch - */ -AbstractCase[] switchStatementColon(final int start, final int end) : -{ - AbstractCase cas; - final ArrayList cases = new ArrayList(); - Token token; - int pos; -} -{ - token = {pos = token.sourceEnd;} - {try { - setMarker(fileToParse, - "Ugly syntax detected, you should switch () {...} instead of switch (): ... enswitch;", - start, - end, - INFO, - "Line " + token.beginLine); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - }} - ( cas = switchLabel0() {cases.add(cas);pos = cas.sourceEnd;})* - try { - token = {pos = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "'endswitch' expected"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseExceptionDebug(e); - } - try { - token = {pos = token.sourceEnd;} - } catch (ParseException e) { - errorMessage = "';' expected after 'endswitch' keyword"; - errorLevel = ERROR; - errorStart = pos+1; - errorEnd = pos+1; - processParseExceptionDebug(e); - } - { - final AbstractCase[] abcase = new AbstractCase[cases.size()]; - cases.toArray(abcase); - return abcase; - } -} - -AbstractCase switchLabel0() : -{ - final Expression expr; - Statement statement; - final ArrayList stmts = new ArrayList(); - final Token token = this.token; - final int start = this.token.next.sourceStart; -} -{ - expr = SwitchLabel() - ( statement = BlockStatementNoBreak() {stmts.add(statement);} - | statement = htmlBlock() {if (statement != null) {stmts.add(statement);}} - | statement = BreakStatement() {stmts.add(statement);})* - //[ statement = BreakStatement() {stmts.add(statement);}] - { - final int listSize = stmts.size(); - final Statement[] stmtsArray = new Statement[listSize]; - stmts.toArray(stmtsArray); - if (expr == null) {//it's a default - final int end = this.token.next.sourceStart; - return new DefaultCase(stmtsArray,start,end); - } - if (listSize != 0) { - return new Case(expr,stmtsArray,expr.sourceStart,stmtsArray[listSize-1].sourceEnd); - } else { - return new Case(expr,stmtsArray,expr.sourceStart,expr.sourceEnd); - } - } -} - -/** - * A SwitchLabel. - * case Expression() : - * default : - * @return the if it was a case and null if not - */ -Expression SwitchLabel() : -{ - final Expression expr; -} -{ - token = - try { - expr = Expression() - } catch (ParseException e) { - if (errorMessage != null) throw e; - errorMessage = "expression expected after 'case' keyword"; - errorLevel = ERROR; - errorStart = token.sourceEnd +1; - errorEnd = token.sourceEnd +1; - throw e; - } - try { - token = - } catch (ParseException e) { - errorMessage = "':' expected after case expression"; - errorLevel = ERROR; - errorStart = expr.sourceEnd+1; - errorEnd = expr.sourceEnd+1; - processParseExceptionDebug(e); - } - {return expr;} -| - token = <_DEFAULT> - try { - - } catch (ParseException e) { - errorMessage = "':' expected after 'default' keyword"; - errorLevel = ERROR; - errorStart = token.sourceEnd+1; - errorEnd = token.sourceEnd+1; - processParseExceptionDebug(e); - } - {return null;} -} - -Break BreakStatement() : -{ - Expression expression = null; - final Token token, token2; - int pos; -} -{ - token = {pos = token.sourceEnd+1;} - [ expression = Expression() {pos = expression.sourceEnd+1;}] - try { - token2 = - {pos = token2.sourceEnd;} - } catch (ParseException e) { - errorMessage = "';' expected after 'break' keyword"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - {return new Break(expression, token.sourceStart, pos);} -} - -IfStatement IfStatement() : -{ - final Expression condition; - final IfStatement ifStatement; - Token token; -} -{ - token = condition = Condition("if") - ifStatement = IfStatement0(condition,token.sourceStart,token.sourceEnd) - {return ifStatement;} -} - - -Expression Condition(final String keyword) : -{ - final Expression condition; -} -{ - try { - - } catch (ParseException e) { - errorMessage = "'(' expected after " + keyword + " keyword"; - errorLevel = ERROR; - errorStart = this.token.sourceEnd + 1; - errorEnd = this.token.sourceEnd + 1; - processParseExceptionDebug(e); - } - condition = Expression() - try { - - } catch (ParseException e) { - errorMessage = "')' expected after " + keyword + " keyword"; - errorLevel = ERROR; - errorStart = condition.sourceEnd+1; - errorEnd = condition.sourceEnd+1; - processParseExceptionDebug(e); - } - {return condition;} -} - -IfStatement IfStatement0(final Expression condition, final int start,final int end) : -{ - Statement statement; - final Statement stmt; - final Statement[] statementsArray; - ElseIf elseifStatement; - Else elseStatement = null; - final ArrayList stmts; - final ArrayList elseIfList = new ArrayList(); - final ElseIf[] elseIfs; - int pos = jj_input_stream.getPosition(); - final int endStatements; -} -{ - - {stmts = new ArrayList();} - ( statement = Statement() {stmts.add(statement);} - | statement = htmlBlock() {if (statement != null) {stmts.add(statement);}})* - {endStatements = jj_input_stream.getPosition();} - (elseifStatement = ElseIfStatementColon() {elseIfList.add(elseifStatement);})* - [elseStatement = ElseStatementColon()] - - {try { - setMarker(fileToParse, - "Ugly syntax detected, you should if () {...} instead of if (): ... endif;", - start, - end, - INFO, - "Line " + token.beginLine); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - }} - try { - - } catch (ParseException e) { - errorMessage = "'endif' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } - try { - - } catch (ParseException e) { - errorMessage = "';' expected after 'endif' keyword"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } - { - elseIfs = new ElseIf[elseIfList.size()]; - elseIfList.toArray(elseIfs); - if (stmts.size() == 1) { - return new IfStatement(condition, - (Statement) stmts.get(0), - elseIfs, - elseStatement, - pos, - jj_input_stream.getPosition()); - } else { - statementsArray = new Statement[stmts.size()]; - stmts.toArray(statementsArray); - return new IfStatement(condition, - new Block(statementsArray,pos,endStatements), - elseIfs, - elseStatement, - pos, - jj_input_stream.getPosition()); - } - } - -| - (stmt = Statement() | stmt = htmlBlock()) - ( LOOKAHEAD(1) elseifStatement = ElseIfStatement() {elseIfList.add(elseifStatement);})* - [ LOOKAHEAD(1) - - try { - {pos = jj_input_stream.getPosition();} - statement = Statement() - {elseStatement = new Else(statement,pos,jj_input_stream.getPosition());} - } catch (ParseException e) { - if (errorMessage != null) { - throw e; - } - errorMessage = "unexpected token '"+e.currentToken.next.image+"', a statement was expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } - ] - { - elseIfs = new ElseIf[elseIfList.size()]; - elseIfList.toArray(elseIfs); - return new IfStatement(condition, - stmt, - elseIfs, - elseStatement, - pos, - jj_input_stream.getPosition());} -} - -ElseIf ElseIfStatementColon() : -{ - final Expression condition; - Statement statement; - final ArrayList list = new ArrayList(); - final Token elseifToken; -} -{ - elseifToken = condition = Condition("elseif") - ( statement = Statement() {list.add(statement);} - | statement = htmlBlock() {if (statement != null) {list.add(statement);}})* - { - final int sizeList = list.size(); - final Statement[] stmtsArray = new Statement[sizeList]; - list.toArray(stmtsArray); - return new ElseIf(condition,stmtsArray , - elseifToken.sourceStart, - stmtsArray[sizeList-1].sourceEnd);} -} - -Else ElseStatementColon() : -{ - Statement statement; - final ArrayList list = new ArrayList(); - final Token elseToken; -} -{ - elseToken = ( statement = Statement() {list.add(statement);} - | statement = htmlBlock() {if (statement != null) {list.add(statement);}})* - { - final int sizeList = list.size(); - final Statement[] stmtsArray = new Statement[sizeList]; - list.toArray(stmtsArray); - return new Else(stmtsArray,elseToken.sourceStart,stmtsArray[sizeList-1].sourceEnd);} -} - -ElseIf ElseIfStatement() : -{ - final Expression condition; - //final Statement statement; - final Token elseifToken; - final Statement[] statement = new Statement[1]; -} -{ - elseifToken = condition = Condition("elseif") statement[0] = Statement() - { - return new ElseIf(condition,statement,elseifToken.sourceStart,statement[0].sourceEnd);} -} - -WhileStatement WhileStatement() : -{ - final Expression condition; - final Statement action; - final Token whileToken; -} -{ - whileToken = - condition = Condition("while") - action = WhileStatement0(whileToken.sourceStart,whileToken.sourceEnd) - {return new WhileStatement(condition,action,whileToken.sourceStart,action.sourceEnd);} -} - -Statement WhileStatement0(final int start, final int end) : -{ - Statement statement; - final ArrayList stmts = new ArrayList(); - final int pos = jj_input_stream.getPosition(); -} -{ - (statement = Statement() {stmts.add(statement);})* - {try { - setMarker(fileToParse, - "Ugly syntax detected, you should while () {...} instead of while (): ... endwhile;", - start, - end, - INFO, - "Line " + token.beginLine); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - }} - try { - - } catch (ParseException e) { - errorMessage = "'endwhile' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } - try { - - { - final Statement[] stmtsArray = new Statement[stmts.size()]; - stmts.toArray(stmtsArray); - return new Block(stmtsArray,pos,jj_input_stream.getPosition());} - } catch (ParseException e) { - errorMessage = "';' expected after 'endwhile' keyword"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - throw e; - } -| - statement = Statement() - {return statement;} -} - -DoStatement DoStatement() : -{ - final Statement action; - final Expression condition; - final Token token; - Token token2 = null; -} -{ - token = action = Statement() condition = Condition("while") - try { - token2 = - } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; - errorLevel = ERROR; - errorStart = condition.sourceEnd+1; - errorEnd = condition.sourceEnd+1; - processParseExceptionDebug(e); - } - { - if (token2 == null) { - return new DoStatement(condition,action,token.sourceStart,condition.sourceEnd); - } - return new DoStatement(condition,action,token.sourceStart,token2.sourceEnd); - } -} - -ForeachStatement ForeachStatement() : -{ - Statement statement = null; - Expression expression = null; - ArrayVariableDeclaration variable = null; - Token foreachToken; - Token lparenToken = null; - Token asToken = null; - Token rparenToken = null; - int pos; -} -{ - foreachToken = - try { - lparenToken = - {pos = lparenToken.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "'(' expected after 'foreach' keyword"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - {pos = foreachToken.sourceEnd+1;} - } - try { - expression = Expression() - {pos = expression.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "variable expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - try { - asToken = - {pos = asToken.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "'as' expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - try { - variable = ArrayVariable() - {pos = variable.sourceEnd+1;} - } catch (ParseException e) { - if (errorMessage != null) throw e; - errorMessage = "variable expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - try { - rparenToken = - {pos = rparenToken.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "')' expected after 'foreach' keyword"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - try { - statement = Statement() - {pos = statement.sourceEnd+1;} - } catch (ParseException e) { - if (errorMessage != null) throw e; - errorMessage = "statement expected"; - errorLevel = ERROR; - errorStart = e.currentToken.sourceStart; - errorEnd = e.currentToken.sourceEnd; - processParseExceptionDebug(e); - } - { - return new ForeachStatement(expression, - variable, - statement, - foreachToken.sourceStart, - pos);} - -} - -/** - * a for declaration. - * @return a node representing the for statement - */ -ForStatement ForStatement() : -{ -final Token token,tokenEndFor,token2,tokenColon; -int pos; -Expression[] initializations = null; -Expression condition = null; -Expression[] increments = null; -Statement action; -final ArrayList list = new ArrayList(); -} -{ - token = - try { - - } catch (ParseException e) { - errorMessage = "'(' expected after 'for' keyword"; - errorLevel = ERROR; - errorStart = token.sourceEnd; - errorEnd = token.sourceEnd +1; - processParseExceptionDebug(e); - } - [ initializations = ForInit() ] - [ condition = Expression() ] - [ increments = StatementExpressionList() ] - ( - action = Statement() - {return new ForStatement(initializations, - condition, - increments, - action, - token.sourceStart, - action.sourceEnd);} - | - tokenColon = {pos = tokenColon.sourceEnd+1;} - (action = Statement() {list.add(action);pos = action.sourceEnd+1;})* - { - try { - setMarker(fileToParse, - "Ugly syntax detected, you should for () {...} instead of for (): ... endfor;", - token.sourceStart, - token.sourceEnd, - INFO, - "Line " + token.beginLine); - } catch (CoreException e) { - PHPeclipsePlugin.log(e); - } - } - try { - tokenEndFor = - {pos = tokenEndFor.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "'endfor' expected"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - try { - token2 = - {pos = token2.sourceEnd+1;} - } catch (ParseException e) { - errorMessage = "';' expected after 'endfor' keyword"; - errorLevel = ERROR; - errorStart = pos; - errorEnd = pos; - processParseExceptionDebug(e); - } - { - final Statement[] stmtsArray = new Statement[list.size()]; - list.toArray(stmtsArray); - return new ForStatement(initializations, - condition, - increments, - new Block(stmtsArray, - stmtsArray[0].sourceStart, - stmtsArray[stmtsArray.length-1].sourceEnd), - token.sourceStart, - pos);} - ) -} - -Expression[] ForInit() : -{ - final Expression[] exprs; -} -{ - LOOKAHEAD(LocalVariableDeclaration()) - exprs = LocalVariableDeclaration() - {return exprs;} -| - exprs = StatementExpressionList() - {return exprs;} -} - -Expression[] StatementExpressionList() : -{ - final ArrayList list = new ArrayList(); - final Expression expr; -} -{ - expr = Expression() {list.add(expr);} - ( Expression() {list.add(expr);})* - { - final Expression[] exprsArray = new Expression[list.size()]; - list.toArray(exprsArray); - return exprsArray; - } -} - -Continue ContinueStatement() : -{ - Expression expr = null; - final Token token; - Token token2 = null; -} -{ - token = [ expr = Expression() ] - try { - token2 = - } catch (ParseException e) { - errorMessage = "';' expected after 'continue' statement"; - errorLevel = ERROR; - if (expr == null) { - errorStart = token.sourceEnd+1; - errorEnd = token.sourceEnd+1; - } else { - errorStart = expr.sourceEnd+1; - errorEnd = expr.sourceEnd+1; - } - processParseExceptionDebug(e); - } - { - if (token2 == null) { - if (expr == null) { - return new Continue(expr,token.sourceStart,token.sourceEnd); - } - return new Continue(expr,token.sourceStart,expr.sourceEnd); - } - return new Continue(expr,token.sourceStart,token2.sourceEnd); - } -} - -ReturnStatement ReturnStatement() : -{ - Expression expr = null; - final Token token; - Token token2 = null; -} -{ - token = [ expr = Expression() ] - try { - token2 = - } catch (ParseException e) { - errorMessage = "';' expected after 'return' statement"; - errorLevel = ERROR; - if (expr == null) { - errorStart = token.sourceEnd+1; - errorEnd = token.sourceEnd+1; - } else { - errorStart = expr.sourceEnd+1; - errorEnd = expr.sourceEnd+1; - } - processParseExceptionDebug(e); - } - { - if (token2 == null) { - if (expr == null) { - return new ReturnStatement(expr,token.sourceStart,token.sourceEnd); - } - return new ReturnStatement(expr,token.sourceStart,expr.sourceEnd); - } - return new ReturnStatement(expr,token.sourceStart,token2.sourceEnd); - } -} - diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserConstants.java b/net.sourceforge.phpeclipse/src/test/PHPParserConstants.java deleted file mode 100644 index 6fc6c54..0000000 --- a/net.sourceforge.phpeclipse/src/test/PHPParserConstants.java +++ /dev/null @@ -1,314 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. PHPParserConstants.java */ -package test; - -public interface PHPParserConstants { - - int EOF = 0; - int PHPSTARTSHORT = 1; - int PHPSTARTLONG = 2; - int PHPECHOSTART = 3; - int PHPEND = 4; - int SINGLE_LINE_COMMENT = 20; - int CLASS = 27; - int FUNCTION = 28; - int VAR = 29; - int IF = 30; - int ELSEIF = 31; - int ELSE = 32; - int ARRAY = 33; - int BREAK = 34; - int LIST = 35; - int PRINT = 36; - int ECHO = 37; - int INCLUDE = 38; - int REQUIRE = 39; - int INCLUDE_ONCE = 40; - int REQUIRE_ONCE = 41; - int GLOBAL = 42; - int DEFINE = 43; - int STATIC = 44; - int CLASSACCESS = 45; - int STATICCLASSACCESS = 46; - int ARRAYASSIGN = 47; - int CASE = 48; - int CONST = 49; - int CONTINUE = 50; - int _DEFAULT = 51; - int DO = 52; - int EXTENDS = 53; - int FOR = 54; - int GOTO = 55; - int NEW = 56; - int NULL = 57; - int RETURN = 58; - int SUPER = 59; - int SWITCH = 60; - int THIS = 61; - int TRUE = 62; - int FALSE = 63; - int WHILE = 64; - int ENDWHILE = 65; - int ENDSWITCH = 66; - int ENDIF = 67; - int ENDFOR = 68; - int FOREACH = 69; - int AS = 70; - int STRING = 71; - int OBJECT = 72; - int BOOL = 73; - int BOOLEAN = 74; - int REAL = 75; - int DOUBLE = 76; - int FLOAT = 77; - int INT = 78; - int INTEGER = 79; - int AT = 80; - int BANG = 81; - int TILDE = 82; - int HOOK = 83; - int COLON = 84; - int OR_OR = 85; - int AND_AND = 86; - int PLUS_PLUS = 87; - int MINUS_MINUS = 88; - int PLUS = 89; - int MINUS = 90; - int STAR = 91; - int SLASH = 92; - int BIT_AND = 93; - int BIT_OR = 94; - int XOR = 95; - int REMAINDER = 96; - int LSHIFT = 97; - int RSIGNEDSHIFT = 98; - int RUNSIGNEDSHIFT = 99; - int _ORL = 100; - int _ANDL = 101; - int INTEGER_LITERAL = 102; - int DECIMAL_LITERAL = 103; - int HEX_LITERAL = 104; - int OCTAL_LITERAL = 105; - int FLOATING_POINT_LITERAL = 106; - int EXPONENT = 107; - int STRING_LITERAL = 108; - int STRING_2 = 109; - int STRING_3 = 110; - int ESCAPED = 111; - int DOUBLEQUOTE = 112; - int DOLLARS = 113; - int DOUBLEQUOTE2 = 114; - int LBRACE1 = 115; - int RBRACE1 = 119; - int ID = 120; - int DOLLAR = 123; - int IDENTIFIER = 124; - int LETTER = 125; - int DIGIT = 126; - int SPECIAL = 127; - int LPAREN = 129; - int RPAREN = 130; - int LBRACE = 131; - int RBRACE = 132; - int LBRACKET = 133; - int RBRACKET = 134; - int SEMICOLON = 135; - int COMMA = 136; - int DOT = 137; - int GT = 138; - int LT = 139; - int EQUAL_EQUAL = 140; - int LE = 141; - int GE = 142; - int NOT_EQUAL = 143; - int DIF = 144; - int BANGDOUBLEEQUAL = 145; - int TRIPLEEQUAL = 146; - int ASSIGN = 147; - int PLUSASSIGN = 148; - int MINUSASSIGN = 149; - int STARASSIGN = 150; - int SLASHASSIGN = 151; - int ANDASSIGN = 152; - int ORASSIGN = 153; - int XORASSIGN = 154; - int DOTASSIGN = 155; - int REMASSIGN = 156; - int TILDEEQUAL = 157; - int LSHIFTASSIGN = 158; - int RSIGNEDSHIFTASSIGN = 159; - - int DEFAULT = 0; - int PHPPARSING = 1; - int IN_SINGLE_LINE_COMMENT = 2; - int IN_VARIABLE = 3; - int IN_FORMAL_COMMENT = 4; - int IN_MULTI_LINE_COMMENT = 5; - int IN_STRING = 6; - int DOLLAR_IN_STRING = 7; - int SKIPSTRING = 8; - int DOLLAR_IN_STRING_EXPR = 9; - - String[] tokenImage = { - "", - "\"\"", - "", - "\" \"", - "\"\\t\"", - "\"\\n\"", - "\"\\r\"", - "\"\\f\"", - "\" \"", - "\"\\t\"", - "\"\\n\"", - "\"\\r\"", - "\"\\f\"", - "\"//\"", - "\"#\"", - "", - "\"/*\"", - "", - "", - "\"todo\"", - "\"TODO\"", - "\"*/\"", - "\"*/\"", - "", - "\"class\"", - "\"function\"", - "\"var\"", - "\"if\"", - "\"elseif\"", - "\"else\"", - "\"array\"", - "\"break\"", - "\"list\"", - "\"print\"", - "\"echo\"", - "\"include\"", - "\"require\"", - "\"include_once\"", - "\"require_once\"", - "\"global\"", - "\"define\"", - "\"static\"", - "\"->\"", - "\"::\"", - "\"=>\"", - "\"case\"", - "\"const\"", - "\"continue\"", - "\"default\"", - "\"do\"", - "\"extends\"", - "\"for\"", - "\"goto\"", - "\"new\"", - "\"null\"", - "\"return\"", - "\"super\"", - "\"switch\"", - "\"this\"", - "\"true\"", - "\"false\"", - "\"while\"", - "\"endwhile\"", - "\"endswitch\"", - "\"endif\"", - "\"endfor\"", - "\"foreach\"", - "\"as\"", - "\"string\"", - "\"object\"", - "\"bool\"", - "\"boolean\"", - "\"real\"", - "\"double\"", - "\"float\"", - "\"int\"", - "\"integer\"", - "\"@\"", - "\"!\"", - "\"~\"", - "\"?\"", - "\":\"", - "\"||\"", - "\"&&\"", - "\"++\"", - "\"--\"", - "\"+\"", - "\"-\"", - "\"*\"", - "\"/\"", - "\"&\"", - "\"|\"", - "\"^\"", - "\"%\"", - "\"<<\"", - "\">>\"", - "\">>>\"", - "\"OR\"", - "\"AND\"", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "\"\\\"\"", - "\"$\"", - "\"\\\"\"", - "\"{\"", - "\"{\"", - "\"}\"", - "", - "\"}\"", - "", - "", - "", - "\"$\"", - "", - "", - "", - "", - "", - "\"(\"", - "\")\"", - "\"{\"", - "\"}\"", - "\"[\"", - "\"]\"", - "\";\"", - "\",\"", - "\".\"", - "\">\"", - "\"<\"", - "\"==\"", - "\"<=\"", - "\">=\"", - "\"!=\"", - "\"<>\"", - "\"!==\"", - "\"===\"", - "\"=\"", - "\"+=\"", - "\"-=\"", - "\"*=\"", - "\"/=\"", - "\"&=\"", - "\"|=\"", - "\"^=\"", - "\".=\"", - "\"%=\"", - "\"~=\"", - "\"<<=\"", - "\">>=\"", - }; - -} diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserManager.java b/net.sourceforge.phpeclipse/src/test/PHPParserManager.java deleted file mode 100644 index 4f42264..0000000 --- a/net.sourceforge.phpeclipse/src/test/PHPParserManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package test; - -import net.sourceforge.phpeclipse.PHPeclipsePlugin; - -import org.eclipse.core.resources.IFile; - -public class PHPParserManager { - - - public static PHPParserSuperclass getParser(IFile fileToParse) { - try { - PHPParserSuperclass actualParser; - if (PHPeclipsePlugin.PHPPARSER == PHPeclipsePlugin.PHPPARSER_ORIGINAL) { - actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); - } else { - actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); - } - actualParser.setFileToParse(fileToParse); - return actualParser; - } catch (InstantiationException e) { - PHPeclipsePlugin.log(e); - } catch (IllegalAccessException e) { - PHPeclipsePlugin.log(e); - } catch (ClassNotFoundException e) { - PHPeclipsePlugin.log(e); - } - return null; - } - - public static PHPParserSuperclass getParser() { - try { - PHPParserSuperclass actualParser; - if (PHPeclipsePlugin.PHPPARSER == PHPeclipsePlugin.PHPPARSER_ORIGINAL) { - actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); - } else { - actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); - } - return actualParser; - } catch (InstantiationException e) { - PHPeclipsePlugin.log(e); - } catch (IllegalAccessException e) { - PHPeclipsePlugin.log(e); - } catch (ClassNotFoundException e) { - PHPeclipsePlugin.log(e); - } - return null; - } - - /** - * To avoid instantiation. - */ - private PHPParserManager() { - } -} diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java b/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java deleted file mode 100644 index 88b2e8a..0000000 --- a/net.sourceforge.phpeclipse/src/test/PHPParserSuperclass.java +++ /dev/null @@ -1,292 +0,0 @@ -package test; - -import java.text.MessageFormat; -import java.util.Hashtable; - -import net.sourceforge.phpdt.core.IJavaModelMarker; -import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; -import net.sourceforge.phpdt.internal.core.builder.PHPBuilder; -import net.sourceforge.phpdt.internal.ui.util.StringUtil; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.texteditor.MarkerUtilities; - -/** - * The superclass for our PHP parsers. - * @author Matthieu Casanova - */ -public abstract class PHPParserSuperclass { - // strings for external parser call - private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$ - private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ - public static final int ERROR = 2; - public static final int WARNING = 1; - public static final int INFO = 0; - public static final int TASK = 3; - // TODO design error? Analyze why fileToParse must be static ??? - protected static IFile fileToParse; - - /** - * Call the php parse command ( php -l -f <filename> ) - * and create markers according to the external parser output. - * @param file the file that will be parsed - */ - public static void phpExternalParse(final IFile file) { - //IFile file = (IFile) resource; - // final IPath path = file.getFullPath(); - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - final String filename = file.getLocation().toString(); - - final String[] arguments = {filename}; - final MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF)); - final String command = form.format(arguments); - - final String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: "); - - try { - // parse the buffer to find the errors and warnings - createMarkers(parserResult, file); - } catch (CoreException e) { - } - } - - /** - * Create markers according to the external parser output. - * @param output the external parser output - * @param file the file that was parsed. - */ - protected static void createMarkers(final String output, final IFile file) throws CoreException { - // delete all markers -// file.deleteMarkers(IMarker.PROBLEM, false, 0); - PHPBuilder.removeProblemsAndTasksFor(file); - - int indx = 0; - int brIndx; - boolean flag = true; - while ((brIndx = output.indexOf("
", indx)) != -1) { - // newer php error output (tested with 4.2.3) - scanLine(output, file, indx, brIndx); - indx = brIndx + 6; - flag = false; - } - if (flag) { - while ((brIndx = output.indexOf("
", indx)) != -1) { - // older php error output (tested with 4.2.3) - scanLine(output, file, indx, brIndx); - indx = brIndx + 4; - } - } - } - - private static void scanLine(final String output, final IFile file, final int indx, final int brIndx) throws CoreException { - String current; - // String outLineNumberString; never used - final StringBuffer lineNumberBuffer = new StringBuffer(10); - char ch; - current = output.substring(indx, brIndx); - - if (current.indexOf(PARSE_WARNING_STRING) != -1 || current.indexOf(PARSE_ERROR_STRING) != -1) { - final int onLine = current.indexOf("on line "); - if (onLine != -1) { - lineNumberBuffer.delete(0, lineNumberBuffer.length()); - for (int i = onLine; i < current.length(); i++) { - ch = current.charAt(i); - if ('0' <= ch && '9' >= ch) { - lineNumberBuffer.append(ch); - } - } - - final int lineNumber = Integer.parseInt(lineNumberBuffer.toString()); - - final Hashtable attributes = new Hashtable(); - - current = StringUtil.replaceAll(current, "\n", ""); - current = StringUtil.replaceAll(current, "", ""); - current = StringUtil.replaceAll(current, "", ""); - MarkerUtilities.setMessage(attributes, current); - - if (current.indexOf(PARSE_ERROR_STRING) != -1) - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - else if (current.indexOf(PARSE_WARNING_STRING) != -1) - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - else - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - MarkerUtilities.setLineNumber(attributes, lineNumber); -// MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); - MarkerUtilities.createMarker(file, attributes, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); - } - } - } - - /** - * This will parse the file and generate the outline info - * @param parent the parent object - * @param s the string that should be parsed - * @return the outline info - */ - public abstract PHPOutlineInfo parseInfo(Object parent, String s); - - /** - * This will change the file to parse. - * @param fileToParse the file that should be parsed - */ - public abstract void setFileToParse(IFile fileToParse); - - /** - * This will parse the given string - * @param s the string to parse - * @throws CoreException an exception that can be launched - */ - public abstract void parse(String s) throws CoreException; - - /** - * This will set a marker. - * @param file the file that generated the marker - * @param message the message - * @param charStart the starting character - * @param charEnd the end character - * @param errorLevel the error level ({@link PHPParserSuperclass#ERROR}, - * {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}),{@link PHPParserSuperclass#TASK}) - * @throws CoreException an exception throwed by the MarkerUtilities - */ - public static void setMarker( - final IFile file, - final String message, - final int charStart, - final int charEnd, - final int errorLevel) - throws CoreException { - if (file != null) { - final Hashtable attributes = new Hashtable(); - MarkerUtilities.setMessage(attributes, message); - switch (errorLevel) { - case ERROR: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - break; - case WARNING: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - break; - case INFO: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - break; - case TASK: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK)); - break; - } - MarkerUtilities.setCharStart(attributes, charStart); - MarkerUtilities.setCharEnd(attributes, charEnd); -// MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); - MarkerUtilities.createMarker(file, attributes, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); - } - } - - /** - * This will set a marker. - * @param file the file that generated the marker - * @param message the message - * @param line the line number - * @param errorLevel the error level ({@link PHPParserSuperclass#ERROR}, - * {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}) - * @throws CoreException an exception throwed by the MarkerUtilities - */ - public static void setMarker(final IFile file, - final String message, - final int line, - final int errorLevel, - final String location) - throws CoreException { - if (file != null) { -// String markerKind = IMarker.PROBLEM; - String markerKind = IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER; - final Hashtable attributes = new Hashtable(); - MarkerUtilities.setMessage(attributes, message); - switch (errorLevel) { - case ERROR: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - break; - case WARNING: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - break; - case INFO: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - break; - case TASK: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); -// markerKind = IMarker.TASK; - markerKind = IJavaModelMarker.TASK_MARKER; - break; - } - attributes.put(IMarker.LOCATION, location); - MarkerUtilities.setLineNumber(attributes, line); - MarkerUtilities.createMarker(file, attributes, markerKind); - } - } - - /** - * This will set a marker. - * @param message the message - * @param charStart the starting character - * @param charEnd the end character - * @param errorLevel the error level ({@link PHPParserSuperclass#ERROR}, - * {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}) - * @throws CoreException an exception throwed by the MarkerUtilities - */ - public static void setMarker(final String message, - final int charStart, - final int charEnd, - final int errorLevel, - final String location) - throws CoreException { - if (fileToParse != null) { - setMarker(fileToParse, message, charStart, charEnd, errorLevel, location); - } - } - - /** - * This will set a marker. - * @param file the file that generated the marker - * @param message the message - * @param charStart the starting character - * @param charEnd the end character - * @param errorLevel the error level ({@link PHPParserSuperclass#ERROR}, - * {@link PHPParserSuperclass#INFO},{@link PHPParserSuperclass#WARNING}) - * @param location the location of the error - * @throws CoreException an exception throwed by the MarkerUtilities - */ - public static void setMarker(final IFile file, - final String message, - final int charStart, - final int charEnd, - final int errorLevel, - final String location) - throws CoreException { - if (file != null) { - final Hashtable attributes = new Hashtable(); - MarkerUtilities.setMessage(attributes, message); - switch (errorLevel) { - case ERROR: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - break; - case WARNING: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - break; - case INFO: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - break; - case TASK: - attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK)); - break; - } - attributes.put(IMarker.LOCATION, location); - MarkerUtilities.setCharStart(attributes, charStart); - MarkerUtilities.setCharEnd(attributes, charEnd); -// MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); - MarkerUtilities.createMarker(file, attributes, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); - } - } -} diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java b/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java deleted file mode 100644 index d651379..0000000 --- a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java +++ /dev/null @@ -1,2880 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. PHPParserTokenManager.java */ -package test; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ui.texteditor.MarkerUtilities; -import org.eclipse.jface.preference.IPreferenceStore; -import java.util.Hashtable; -import java.util.ArrayList; -import java.io.StringReader; -import java.io.*; -import java.text.MessageFormat; -import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpdt.internal.compiler.ast.*; -import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; -import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; -import net.sourceforge.phpdt.internal.corext.Assert; - -public class PHPParserTokenManager implements PHPParserConstants -{ - // CommonTokenAction: use the begins/ends fields added to the Jack - // CharStream class to set corresponding fields in each Token (which was - // also extended with new fields). By default Jack doesn't supply absolute - // offsets, just line/column offsets - void CommonTokenAction(Token t) { - t.sourceStart = input_stream.getBeginOffset(); - t.sourceEnd = input_stream.getBeginOffset(); - } - public java.io.PrintStream debugStream = System.out; - public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private final int jjStopAtPos(int pos, int kind) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; -} -private final int jjMoveStringLiteralDfa0_5() -{ - switch(curChar) - { - case 42: - return jjMoveStringLiteralDfa1_5(0x2000000L); - case 84: - case 116: - return jjMoveStringLiteralDfa1_5(0x400000L); - default : - return 1; - } -} -private final int jjMoveStringLiteralDfa1_5(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 1; - } - switch(curChar) - { - case 47: - if ((active0 & 0x2000000L) != 0L) - return jjStopAtPos(1, 25); - break; - case 79: - case 111: - return jjMoveStringLiteralDfa2_5(active0, 0x400000L); - default : - return 2; - } - return 2; -} -private final int jjMoveStringLiteralDfa2_5(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return 2; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 2; - } - switch(curChar) - { - case 68: - case 100: - return jjMoveStringLiteralDfa3_5(active0, 0x400000L); - default : - return 3; - } -} -private final int jjMoveStringLiteralDfa3_5(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return 3; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 3; - } - switch(curChar) - { - case 79: - case 111: - if ((active0 & 0x400000L) != 0L) - return jjStopAtPos(3, 22); - break; - default : - return 4; - } - return 4; -} -private final int jjMoveStringLiteralDfa0_8() -{ - switch(curChar) - { - case 125: - return jjStopAtPos(0, 117); - default : - return 1; - } -} -private final int jjStopStringLiteralDfa_9(int pos, long active0, long active1) -{ - switch (pos) - { - default : - return -1; - } -} -private final int jjStartNfa_9(int pos, long active0, long active1) -{ - return jjMoveNfa_9(jjStopStringLiteralDfa_9(pos, active0, active1), pos + 1); -} -private final int jjStartNfaWithStates_9(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_9(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_9() -{ - switch(curChar) - { - case 125: - return jjStopAtPos(0, 119); - default : - return jjMoveNfa_9(0, 0); - } -} -private final void jjCheckNAdd(int state) -{ - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } -} -private final void jjAddStates(int start, int end) -{ - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); -} -private final void jjCheckNAddTwoStates(int state1, int state2) -{ - jjCheckNAdd(state1); - jjCheckNAdd(state2); -} -private final void jjCheckNAddStates(int start, int end) -{ - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); -} -private final void jjCheckNAddStates(int start) -{ - jjCheckNAdd(jjnextStates[start]); - jjCheckNAdd(jjnextStates[start + 1]); -} -static final long[] jjbitVec0 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL -}; -private final int jjMoveNfa_9(int startState, int curPos) -{ - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 1; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - kind = 120; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0xdfffffffffffffffL & l) == 0L) - break; - kind = 120; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : break; - } - } while(i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 120) - kind = 120; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 1 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private final int jjMoveStringLiteralDfa0_0() -{ - switch(curChar) - { - case 60: - return jjMoveStringLiteralDfa1_0(0xeL); - case 84: - case 116: - return jjMoveStringLiteralDfa1_0(0x800000L); - default : - return 1; - } -} -private final int jjMoveStringLiteralDfa1_0(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 1; - } - switch(curChar) - { - case 63: - if ((active0 & 0x2L) != 0L) - { - jjmatchedKind = 1; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0xcL); - case 79: - case 111: - return jjMoveStringLiteralDfa2_0(active0, 0x800000L); - default : - return 2; - } -} -private final int jjMoveStringLiteralDfa2_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return 2; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 2; - } - switch(curChar) - { - case 61: - if ((active0 & 0x8L) != 0L) - return jjStopAtPos(2, 3); - break; - case 68: - case 100: - return jjMoveStringLiteralDfa3_0(active0, 0x800000L); - case 80: - case 112: - return jjMoveStringLiteralDfa3_0(active0, 0x4L); - default : - return 3; - } - return 3; -} -private final int jjMoveStringLiteralDfa3_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return 3; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 3; - } - switch(curChar) - { - case 72: - case 104: - return jjMoveStringLiteralDfa4_0(active0, 0x4L); - case 79: - case 111: - if ((active0 & 0x800000L) != 0L) - return jjStopAtPos(3, 23); - break; - default : - return 4; - } - return 4; -} -private final int jjMoveStringLiteralDfa4_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return 4; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 4; - } - switch(curChar) - { - case 80: - case 112: - if ((active0 & 0x4L) != 0L) - return jjStopAtPos(4, 2); - break; - default : - return 5; - } - return 5; -} -private final int jjMoveStringLiteralDfa0_4() -{ - switch(curChar) - { - case 42: - return jjMoveStringLiteralDfa1_4(0x1000000L); - case 84: - case 116: - return jjMoveStringLiteralDfa1_4(0x400000L); - default : - return 1; - } -} -private final int jjMoveStringLiteralDfa1_4(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 1; - } - switch(curChar) - { - case 47: - if ((active0 & 0x1000000L) != 0L) - return jjStopAtPos(1, 24); - break; - case 79: - case 111: - return jjMoveStringLiteralDfa2_4(active0, 0x400000L); - default : - return 2; - } - return 2; -} -private final int jjMoveStringLiteralDfa2_4(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return 2; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 2; - } - switch(curChar) - { - case 68: - case 100: - return jjMoveStringLiteralDfa3_4(active0, 0x400000L); - default : - return 3; - } -} -private final int jjMoveStringLiteralDfa3_4(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return 3; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 3; - } - switch(curChar) - { - case 79: - case 111: - if ((active0 & 0x400000L) != 0L) - return jjStopAtPos(3, 22); - break; - default : - return 4; - } - return 4; -} -private final int jjStopStringLiteralDfa_3(int pos, long active0, long active1, long active2) -{ - switch (pos) - { - case 0: - if ((active1 & 0x3000000000L) != 0L) - { - jjmatchedKind = 124; - return 1; - } - return -1; - case 1: - if ((active1 & 0x1000000000L) != 0L) - return 1; - if ((active1 & 0x2000000000L) != 0L) - { - if (jjmatchedPos != 1) - { - jjmatchedKind = 124; - jjmatchedPos = 1; - } - return 1; - } - return -1; - default : - return -1; - } -} -private final int jjStartNfa_3(int pos, long active0, long active1, long active2) -{ - return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0, active1, active2), pos + 1); -} -private final int jjStartNfaWithStates_3(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_3(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_3() -{ - switch(curChar) - { - case 9: - return jjStopAtPos(0, 12); - case 10: - return jjStopAtPos(0, 13); - case 12: - return jjStopAtPos(0, 15); - case 13: - return jjStopAtPos(0, 14); - case 32: - return jjStopAtPos(0, 11); - case 33: - jjmatchedKind = 81; - return jjMoveStringLiteralDfa1_3(0x0L, 0x0L, 0x28000L); - case 36: - return jjStopAtPos(0, 123); - case 37: - jjmatchedKind = 96; - return jjMoveStringLiteralDfa1_3(0x0L, 0x0L, 0x10000000L); - case 38: - jjmatchedKind = 93; - return jjMoveStringLiteralDfa1_3(0x0L, 0x400000L, 0x1000000L); - case 40: - return jjStopAtPos(0, 129); - case 41: - return jjStopAtPos(0, 130); - case 42: - jjmatchedKind = 91; - return jjMoveStringLiteralDfa1_3(0x0L, 0x0L, 0x400000L); - case 43: - jjmatchedKind = 89; - return jjMoveStringLiteralDfa1_3(0x0L, 0x800000L, 0x100000L); - case 44: - return jjStopAtPos(0, 136); - case 45: - jjmatchedKind = 90; - return jjMoveStringLiteralDfa1_3(0x200000000000L, 0x1000000L, 0x200000L); - case 46: - jjmatchedKind = 137; - return jjMoveStringLiteralDfa1_3(0x0L, 0x0L, 0x8000000L); - case 47: - jjmatchedKind = 92; - return jjMoveStringLiteralDfa1_3(0x0L, 0x0L, 0x800000L); - case 58: - jjmatchedKind = 84; - return jjMoveStringLiteralDfa1_3(0x400000000000L, 0x0L, 0x0L); - case 59: - return jjStopAtPos(0, 135); - case 60: - jjmatchedKind = 139; - return jjMoveStringLiteralDfa1_3(0x0L, 0x200000000L, 0x40012000L); - case 61: - jjmatchedKind = 147; - return jjMoveStringLiteralDfa1_3(0x800000000000L, 0x0L, 0x41000L); - case 62: - jjmatchedKind = 138; - return jjMoveStringLiteralDfa1_3(0x0L, 0xc00000000L, 0x80004000L); - case 63: - jjmatchedKind = 83; - return jjMoveStringLiteralDfa1_3(0x10L, 0x0L, 0x0L); - case 64: - return jjStopAtPos(0, 80); - case 91: - return jjStopAtPos(0, 133); - case 93: - return jjStopAtPos(0, 134); - case 94: - jjmatchedKind = 95; - return jjMoveStringLiteralDfa1_3(0x0L, 0x0L, 0x4000000L); - case 65: - case 97: - return jjMoveStringLiteralDfa1_3(0x0L, 0x2000000000L, 0x0L); - case 79: - case 111: - return jjMoveStringLiteralDfa1_3(0x0L, 0x1000000000L, 0x0L); - case 123: - return jjStopAtPos(0, 131); - case 124: - jjmatchedKind = 94; - return jjMoveStringLiteralDfa1_3(0x0L, 0x200000L, 0x2000000L); - case 125: - return jjStopAtPos(0, 132); - case 126: - jjmatchedKind = 82; - return jjMoveStringLiteralDfa1_3(0x0L, 0x0L, 0x20000000L); - default : - return jjMoveNfa_3(0, 0); - } -} -private final int jjMoveStringLiteralDfa1_3(long active0, long active1, long active2) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_3(0, active0, active1, active2); - return 1; - } - switch(curChar) - { - case 38: - if ((active1 & 0x400000L) != 0L) - return jjStopAtPos(1, 86); - break; - case 43: - if ((active1 & 0x800000L) != 0L) - return jjStopAtPos(1, 87); - break; - case 45: - if ((active1 & 0x1000000L) != 0L) - return jjStopAtPos(1, 88); - break; - case 58: - if ((active0 & 0x400000000000L) != 0L) - return jjStopAtPos(1, 46); - break; - case 60: - if ((active1 & 0x200000000L) != 0L) - { - jjmatchedKind = 97; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_3(active0, 0L, active1, 0L, active2, 0x40000000L); - case 61: - if ((active2 & 0x1000L) != 0L) - { - jjmatchedKind = 140; - jjmatchedPos = 1; - } - else if ((active2 & 0x2000L) != 0L) - return jjStopAtPos(1, 141); - else if ((active2 & 0x4000L) != 0L) - return jjStopAtPos(1, 142); - else if ((active2 & 0x8000L) != 0L) - { - jjmatchedKind = 143; - jjmatchedPos = 1; - } - else if ((active2 & 0x100000L) != 0L) - return jjStopAtPos(1, 148); - else if ((active2 & 0x200000L) != 0L) - return jjStopAtPos(1, 149); - else if ((active2 & 0x400000L) != 0L) - return jjStopAtPos(1, 150); - else if ((active2 & 0x800000L) != 0L) - return jjStopAtPos(1, 151); - else if ((active2 & 0x1000000L) != 0L) - return jjStopAtPos(1, 152); - else if ((active2 & 0x2000000L) != 0L) - return jjStopAtPos(1, 153); - else if ((active2 & 0x4000000L) != 0L) - return jjStopAtPos(1, 154); - else if ((active2 & 0x8000000L) != 0L) - return jjStopAtPos(1, 155); - else if ((active2 & 0x10000000L) != 0L) - return jjStopAtPos(1, 156); - else if ((active2 & 0x20000000L) != 0L) - return jjStopAtPos(1, 157); - return jjMoveStringLiteralDfa2_3(active0, 0L, active1, 0L, active2, 0x60000L); - case 62: - if ((active0 & 0x10L) != 0L) - return jjStopAtPos(1, 4); - else if ((active0 & 0x200000000000L) != 0L) - return jjStopAtPos(1, 45); - else if ((active0 & 0x800000000000L) != 0L) - return jjStopAtPos(1, 47); - else if ((active1 & 0x400000000L) != 0L) - { - jjmatchedKind = 98; - jjmatchedPos = 1; - } - else if ((active2 & 0x10000L) != 0L) - return jjStopAtPos(1, 144); - return jjMoveStringLiteralDfa2_3(active0, 0L, active1, 0x800000000L, active2, 0x80000000L); - case 78: - case 110: - return jjMoveStringLiteralDfa2_3(active0, 0L, active1, 0x2000000000L, active2, 0L); - case 82: - case 114: - if ((active1 & 0x1000000000L) != 0L) - return jjStartNfaWithStates_3(1, 100, 1); - break; - case 124: - if ((active1 & 0x200000L) != 0L) - return jjStopAtPos(1, 85); - break; - default : - break; - } - return jjStartNfa_3(0, active0, active1, active2); -} -private final int jjMoveStringLiteralDfa2_3(long old0, long active0, long old1, long active1, long old2, long active2) -{ - if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) - return jjStartNfa_3(0, old0, old1, old2); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_3(1, 0L, active1, active2); - return 2; - } - switch(curChar) - { - case 61: - if ((active2 & 0x20000L) != 0L) - return jjStopAtPos(2, 145); - else if ((active2 & 0x40000L) != 0L) - return jjStopAtPos(2, 146); - else if ((active2 & 0x40000000L) != 0L) - return jjStopAtPos(2, 158); - else if ((active2 & 0x80000000L) != 0L) - return jjStopAtPos(2, 159); - break; - case 62: - if ((active1 & 0x800000000L) != 0L) - return jjStopAtPos(2, 99); - break; - case 68: - case 100: - if ((active1 & 0x2000000000L) != 0L) - return jjStartNfaWithStates_3(2, 101, 1); - break; - default : - break; - } - return jjStartNfa_3(1, 0L, active1, active2); -} -private final int jjMoveNfa_3(int startState, int curPos) -{ - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 2; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 1: - if ((0x3ff000000000000L & l) == 0L) - break; - kind = 124; - jjstateSet[jjnewStateCnt++] = 1; - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - case 1: - if ((0x87fffffe87fffffeL & l) == 0L) - break; - if (kind > 124) - kind = 124; - jjCheckNAdd(1); - break; - default : break; - } - } while(i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - case 1: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 124) - kind = 124; - jjCheckNAdd(1); - break; - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 2 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private final int jjStopStringLiteralDfa_6(int pos, long active0, long active1) -{ - switch (pos) - { - default : - return -1; - } -} -private final int jjStartNfa_6(int pos, long active0, long active1) -{ - return jjMoveNfa_6(jjStopStringLiteralDfa_6(pos, active0, active1), pos + 1); -} -private final int jjStartNfaWithStates_6(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_6(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_6() -{ - switch(curChar) - { - case 34: - return jjStopAtPos(0, 114); - case 36: - return jjStopAtPos(0, 113); - case 123: - return jjStopAtPos(0, 116); - default : - return jjMoveNfa_6(0, 0); - } -} -private final int jjMoveNfa_6(int startState, int curPos) -{ - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 2; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 1: - kind = 111; - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 1; - break; - case 1: - if (kind > 111) - kind = 111; - break; - default : break; - } - } while(i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 1: - if ((jjbitVec0[i2] & l2) != 0L && kind > 111) - kind = 111; - break; - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 2 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private final int jjStopStringLiteralDfa_2(int pos, long active0) -{ - switch (pos) - { - default : - return -1; - } -} -private final int jjStartNfa_2(int pos, long active0) -{ - return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); -} -private final int jjStartNfaWithStates_2(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_2(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_2() -{ - switch(curChar) - { - case 63: - return jjMoveStringLiteralDfa1_2(0x10L); - case 84: - case 116: - return jjMoveStringLiteralDfa1_2(0x400000L); - default : - return jjMoveNfa_2(0, 0); - } -} -private final int jjMoveStringLiteralDfa1_2(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_2(0, active0); - return 1; - } - switch(curChar) - { - case 62: - if ((active0 & 0x10L) != 0L) - return jjStopAtPos(1, 4); - break; - case 79: - case 111: - return jjMoveStringLiteralDfa2_2(active0, 0x400000L); - default : - break; - } - return jjStartNfa_2(0, active0); -} -private final int jjMoveStringLiteralDfa2_2(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjStartNfa_2(0, old0); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_2(1, active0); - return 2; - } - switch(curChar) - { - case 68: - case 100: - return jjMoveStringLiteralDfa3_2(active0, 0x400000L); - default : - break; - } - return jjStartNfa_2(1, active0); -} -private final int jjMoveStringLiteralDfa3_2(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjStartNfa_2(1, old0); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_2(2, active0); - return 3; - } - switch(curChar) - { - case 79: - case 111: - if ((active0 & 0x400000L) != 0L) - return jjStopAtPos(3, 22); - break; - default : - break; - } - return jjStartNfa_2(2, active0); -} -private final int jjMoveNfa_2(int startState, int curPos) -{ - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 3; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0x2400L & l) != 0L) - { - if (kind > 20) - kind = 20; - } - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 1; - break; - case 1: - if (curChar == 10 && kind > 20) - kind = 20; - break; - case 2: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 1; - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - default : break; - } - } while(i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private final int jjStopStringLiteralDfa_1(int pos, long active0, long active1, long active2) -{ - switch (pos) - { - case 0: - if ((active0 & 0xffff1ffff8000000L) != 0L || (active1 & 0x300000ffffL) != 0L) - { - jjmatchedKind = 124; - return 14; - } - if ((active0 & 0x90000L) != 0L || (active1 & 0x10000000L) != 0L || (active2 & 0x800000L) != 0L) - return 2; - if ((active2 & 0x8000200L) != 0L) - return 8; - return -1; - case 1: - if ((active0 & 0x80000L) != 0L) - return 0; - if ((active0 & 0x10000040000000L) != 0L || (active1 & 0x1000001040L) != 0L) - return 14; - if ((active0 & 0xffef1fffb8000000L) != 0L || (active1 & 0x200000efbfL) != 0L) - { - if (jjmatchedPos != 1) - { - jjmatchedKind = 124; - jjmatchedPos = 1; - } - return 14; - } - return -1; - case 2: - if ((active0 & 0x140000020000000L) != 0L || (active1 & 0x200000c020L) != 0L) - return 14; - if ((active0 & 0xfeaf1fff98000000L) != 0L || (active1 & 0x3f9fL) != 0L) - { - if (jjmatchedPos != 2) - { - jjmatchedKind = 124; - jjmatchedPos = 2; - } - return 14; - } - return -1; - case 3: - if ((active0 & 0x9c2e1fd618000000L) != 0L || (active1 & 0xb1bfL) != 0L) - { - if (jjmatchedPos != 3) - { - jjmatchedKind = 124; - jjmatchedPos = 3; - } - return 14; - } - if ((active0 & 0x6281002980000000L) != 0L || (active1 & 0xe00L) != 0L) - return 14; - return -1; - case 4: - if ((active0 & 0x8802001608000000L) != 0L || (active1 & 0x2009L) != 0L) - return 14; - if ((active0 & 0x142c1fc090000000L) != 0L || (active1 & 0x95b6L) != 0L) - { - jjmatchedKind = 124; - jjmatchedPos = 4; - return 14; - } - return -1; - case 5: - if ((active0 & 0x14001c0080000000L) != 0L || (active1 & 0x1190L) != 0L) - return 14; - if ((active0 & 0x2c03c010000000L) != 0L || (active1 & 0x8426L) != 0L) - { - jjmatchedKind = 124; - jjmatchedPos = 5; - return 14; - } - return -1; - case 6: - if ((active0 & 0x2803c000000000L) != 0L || (active1 & 0x8420L) != 0L) - return 14; - if ((active0 & 0x4000010000000L) != 0L || (active1 & 0x6L) != 0L) - { - if (jjmatchedPos != 6) - { - jjmatchedKind = 124; - jjmatchedPos = 6; - } - return 14; - } - return -1; - case 7: - if ((active0 & 0x30000000000L) != 0L || (active1 & 0x4L) != 0L) - { - jjmatchedKind = 124; - jjmatchedPos = 7; - return 14; - } - if ((active0 & 0x4000010000000L) != 0L || (active1 & 0x2L) != 0L) - return 14; - return -1; - case 8: - if ((active1 & 0x4L) != 0L) - return 14; - if ((active0 & 0x30000000000L) != 0L) - { - jjmatchedKind = 124; - jjmatchedPos = 8; - return 14; - } - return -1; - case 9: - if ((active0 & 0x30000000000L) != 0L) - { - jjmatchedKind = 124; - jjmatchedPos = 9; - return 14; - } - return -1; - case 10: - if ((active0 & 0x30000000000L) != 0L) - { - jjmatchedKind = 124; - jjmatchedPos = 10; - return 14; - } - return -1; - default : - return -1; - } -} -private final int jjStartNfa_1(int pos, long active0, long active1, long active2) -{ - return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0, active1, active2), pos + 1); -} -private final int jjStartNfaWithStates_1(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_1(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_1() -{ - switch(curChar) - { - case 33: - jjmatchedKind = 81; - return jjMoveStringLiteralDfa1_1(0x0L, 0x0L, 0x28000L); - case 34: - return jjStopAtPos(0, 112); - case 35: - return jjStopAtPos(0, 17); - case 36: - return jjStopAtPos(0, 123); - case 37: - jjmatchedKind = 96; - return jjMoveStringLiteralDfa1_1(0x0L, 0x0L, 0x10000000L); - case 38: - jjmatchedKind = 93; - return jjMoveStringLiteralDfa1_1(0x0L, 0x400000L, 0x1000000L); - case 40: - return jjStopAtPos(0, 129); - case 41: - return jjStopAtPos(0, 130); - case 42: - jjmatchedKind = 91; - return jjMoveStringLiteralDfa1_1(0x0L, 0x0L, 0x400000L); - case 43: - jjmatchedKind = 89; - return jjMoveStringLiteralDfa1_1(0x0L, 0x800000L, 0x100000L); - case 44: - return jjStopAtPos(0, 136); - case 45: - jjmatchedKind = 90; - return jjMoveStringLiteralDfa1_1(0x200000000000L, 0x1000000L, 0x200000L); - case 46: - jjmatchedKind = 137; - return jjMoveStringLiteralDfa1_1(0x0L, 0x0L, 0x8000000L); - case 47: - jjmatchedKind = 92; - return jjMoveStringLiteralDfa1_1(0x90000L, 0x0L, 0x800000L); - case 58: - jjmatchedKind = 84; - return jjMoveStringLiteralDfa1_1(0x400000000000L, 0x0L, 0x0L); - case 59: - return jjStopAtPos(0, 135); - case 60: - jjmatchedKind = 139; - return jjMoveStringLiteralDfa1_1(0x0L, 0x200000000L, 0x40012000L); - case 61: - jjmatchedKind = 147; - return jjMoveStringLiteralDfa1_1(0x800000000000L, 0x0L, 0x41000L); - case 62: - jjmatchedKind = 138; - return jjMoveStringLiteralDfa1_1(0x0L, 0xc00000000L, 0x80004000L); - case 63: - jjmatchedKind = 83; - return jjMoveStringLiteralDfa1_1(0x10L, 0x0L, 0x0L); - case 64: - return jjStopAtPos(0, 80); - case 91: - return jjStopAtPos(0, 133); - case 93: - return jjStopAtPos(0, 134); - case 94: - jjmatchedKind = 95; - return jjMoveStringLiteralDfa1_1(0x0L, 0x0L, 0x4000000L); - case 65: - case 97: - return jjMoveStringLiteralDfa1_1(0x200000000L, 0x2000000040L, 0x0L); - case 66: - case 98: - return jjMoveStringLiteralDfa1_1(0x400000000L, 0x600L, 0x0L); - case 67: - case 99: - return jjMoveStringLiteralDfa1_1(0x7000008000000L, 0x0L, 0x0L); - case 68: - case 100: - return jjMoveStringLiteralDfa1_1(0x18080000000000L, 0x1000L, 0x0L); - case 69: - case 101: - return jjMoveStringLiteralDfa1_1(0x20002180000000L, 0x1eL, 0x0L); - case 70: - case 102: - return jjMoveStringLiteralDfa1_1(0x8040000010000000L, 0x2020L, 0x0L); - case 71: - case 103: - return jjMoveStringLiteralDfa1_1(0x80040000000000L, 0x0L, 0x0L); - case 73: - case 105: - return jjMoveStringLiteralDfa1_1(0x14040000000L, 0xc000L, 0x0L); - case 76: - case 108: - return jjMoveStringLiteralDfa1_1(0x800000000L, 0x0L, 0x0L); - case 78: - case 110: - return jjMoveStringLiteralDfa1_1(0x300000000000000L, 0x0L, 0x0L); - case 79: - case 111: - return jjMoveStringLiteralDfa1_1(0x0L, 0x1000000100L, 0x0L); - case 80: - case 112: - return jjMoveStringLiteralDfa1_1(0x1000000000L, 0x0L, 0x0L); - case 82: - case 114: - return jjMoveStringLiteralDfa1_1(0x400028000000000L, 0x800L, 0x0L); - case 83: - case 115: - return jjMoveStringLiteralDfa1_1(0x1800100000000000L, 0x80L, 0x0L); - case 84: - case 116: - return jjMoveStringLiteralDfa1_1(0x6000000000000000L, 0x0L, 0x0L); - case 86: - case 118: - return jjMoveStringLiteralDfa1_1(0x20000000L, 0x0L, 0x0L); - case 87: - case 119: - return jjMoveStringLiteralDfa1_1(0x0L, 0x1L, 0x0L); - case 123: - return jjStopAtPos(0, 131); - case 124: - jjmatchedKind = 94; - return jjMoveStringLiteralDfa1_1(0x0L, 0x200000L, 0x2000000L); - case 125: - return jjStopAtPos(0, 132); - case 126: - jjmatchedKind = 82; - return jjMoveStringLiteralDfa1_1(0x0L, 0x0L, 0x20000000L); - default : - return jjMoveNfa_1(3, 0); - } -} -private final int jjMoveStringLiteralDfa1_1(long active0, long active1, long active2) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(0, active0, active1, active2); - return 1; - } - switch(curChar) - { - case 38: - if ((active1 & 0x400000L) != 0L) - return jjStopAtPos(1, 86); - break; - case 42: - if ((active0 & 0x80000L) != 0L) - return jjStartNfaWithStates_1(1, 19, 0); - break; - case 43: - if ((active1 & 0x800000L) != 0L) - return jjStopAtPos(1, 87); - break; - case 45: - if ((active1 & 0x1000000L) != 0L) - return jjStopAtPos(1, 88); - break; - case 47: - if ((active0 & 0x10000L) != 0L) - return jjStopAtPos(1, 16); - break; - case 58: - if ((active0 & 0x400000000000L) != 0L) - return jjStopAtPos(1, 46); - break; - case 60: - if ((active1 & 0x200000000L) != 0L) - { - jjmatchedKind = 97; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_1(active0, 0L, active1, 0L, active2, 0x40000000L); - case 61: - if ((active2 & 0x1000L) != 0L) - { - jjmatchedKind = 140; - jjmatchedPos = 1; - } - else if ((active2 & 0x2000L) != 0L) - return jjStopAtPos(1, 141); - else if ((active2 & 0x4000L) != 0L) - return jjStopAtPos(1, 142); - else if ((active2 & 0x8000L) != 0L) - { - jjmatchedKind = 143; - jjmatchedPos = 1; - } - else if ((active2 & 0x100000L) != 0L) - return jjStopAtPos(1, 148); - else if ((active2 & 0x200000L) != 0L) - return jjStopAtPos(1, 149); - else if ((active2 & 0x400000L) != 0L) - return jjStopAtPos(1, 150); - else if ((active2 & 0x800000L) != 0L) - return jjStopAtPos(1, 151); - else if ((active2 & 0x1000000L) != 0L) - return jjStopAtPos(1, 152); - else if ((active2 & 0x2000000L) != 0L) - return jjStopAtPos(1, 153); - else if ((active2 & 0x4000000L) != 0L) - return jjStopAtPos(1, 154); - else if ((active2 & 0x8000000L) != 0L) - return jjStopAtPos(1, 155); - else if ((active2 & 0x10000000L) != 0L) - return jjStopAtPos(1, 156); - else if ((active2 & 0x20000000L) != 0L) - return jjStopAtPos(1, 157); - return jjMoveStringLiteralDfa2_1(active0, 0L, active1, 0L, active2, 0x60000L); - case 62: - if ((active0 & 0x10L) != 0L) - return jjStopAtPos(1, 4); - else if ((active0 & 0x200000000000L) != 0L) - return jjStopAtPos(1, 45); - else if ((active0 & 0x800000000000L) != 0L) - return jjStopAtPos(1, 47); - else if ((active1 & 0x400000000L) != 0L) - { - jjmatchedKind = 98; - jjmatchedPos = 1; - } - else if ((active2 & 0x10000L) != 0L) - return jjStopAtPos(1, 144); - return jjMoveStringLiteralDfa2_1(active0, 0L, active1, 0x800000000L, active2, 0x80000000L); - case 65: - case 97: - return jjMoveStringLiteralDfa2_1(active0, 0x8001000020000000L, active1, 0L, active2, 0L); - case 66: - case 98: - return jjMoveStringLiteralDfa2_1(active0, 0L, active1, 0x100L, active2, 0L); - case 67: - case 99: - return jjMoveStringLiteralDfa2_1(active0, 0x2000000000L, active1, 0L, active2, 0L); - case 69: - case 101: - return jjMoveStringLiteralDfa2_1(active0, 0x5080a8000000000L, active1, 0x800L, active2, 0L); - case 70: - case 102: - if ((active0 & 0x40000000L) != 0L) - return jjStartNfaWithStates_1(1, 30, 14); - break; - case 72: - case 104: - return jjMoveStringLiteralDfa2_1(active0, 0x2000000000000000L, active1, 0x1L, active2, 0L); - case 73: - case 105: - return jjMoveStringLiteralDfa2_1(active0, 0x800000000L, active1, 0L, active2, 0L); - case 76: - case 108: - return jjMoveStringLiteralDfa2_1(active0, 0x40188000000L, active1, 0x2000L, active2, 0L); - case 78: - case 110: - return jjMoveStringLiteralDfa2_1(active0, 0x14000000000L, active1, 0x200000c01eL, active2, 0L); - case 79: - case 111: - if ((active0 & 0x10000000000000L) != 0L) - { - jjmatchedKind = 52; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_1(active0, 0xc6000000000000L, active1, 0x1620L, active2, 0L); - case 82: - case 114: - if ((active1 & 0x1000000000L) != 0L) - return jjStartNfaWithStates_1(1, 100, 14); - return jjMoveStringLiteralDfa2_1(active0, 0x4000001600000000L, active1, 0L, active2, 0L); - case 83: - case 115: - if ((active1 & 0x40L) != 0L) - return jjStartNfaWithStates_1(1, 70, 14); - break; - case 84: - case 116: - return jjMoveStringLiteralDfa2_1(active0, 0x100000000000L, active1, 0x80L, active2, 0L); - case 85: - case 117: - return jjMoveStringLiteralDfa2_1(active0, 0xa00000010000000L, active1, 0L, active2, 0L); - case 87: - case 119: - return jjMoveStringLiteralDfa2_1(active0, 0x1000000000000000L, active1, 0L, active2, 0L); - case 88: - case 120: - return jjMoveStringLiteralDfa2_1(active0, 0x20000000000000L, active1, 0L, active2, 0L); - case 124: - if ((active1 & 0x200000L) != 0L) - return jjStopAtPos(1, 85); - break; - default : - break; - } - return jjStartNfa_1(0, active0, active1, active2); -} -private final int jjMoveStringLiteralDfa2_1(long old0, long active0, long old1, long active1, long old2, long active2) -{ - if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) - return jjStartNfa_1(0, old0, old1, old2); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(1, active0, active1, active2); - return 2; - } - switch(curChar) - { - case 61: - if ((active2 & 0x20000L) != 0L) - return jjStopAtPos(2, 145); - else if ((active2 & 0x40000L) != 0L) - return jjStopAtPos(2, 146); - else if ((active2 & 0x40000000L) != 0L) - return jjStopAtPos(2, 158); - else if ((active2 & 0x80000000L) != 0L) - return jjStopAtPos(2, 159); - break; - case 62: - if ((active1 & 0x800000000L) != 0L) - return jjStopAtPos(2, 99); - break; - case 65: - case 97: - return jjMoveStringLiteralDfa3_1(active0, 0x100008000000L, active1, 0x800L, active2, 0L); - case 67: - case 99: - return jjMoveStringLiteralDfa3_1(active0, 0x14000000000L, active1, 0L, active2, 0L); - case 68: - case 100: - if ((active1 & 0x2000000000L) != 0L) - return jjStartNfaWithStates_1(2, 101, 14); - return jjMoveStringLiteralDfa3_1(active0, 0L, active1, 0x1eL, active2, 0L); - case 69: - case 101: - return jjMoveStringLiteralDfa3_1(active0, 0x400000000L, active1, 0L, active2, 0L); - case 70: - case 102: - return jjMoveStringLiteralDfa3_1(active0, 0x8080000000000L, active1, 0L, active2, 0L); - case 72: - case 104: - return jjMoveStringLiteralDfa3_1(active0, 0x2000000000L, active1, 0L, active2, 0L); - case 73: - case 105: - return jjMoveStringLiteralDfa3_1(active0, 0x3000001000000000L, active1, 0x1L, active2, 0L); - case 74: - case 106: - return jjMoveStringLiteralDfa3_1(active0, 0L, active1, 0x100L, active2, 0L); - case 76: - case 108: - return jjMoveStringLiteralDfa3_1(active0, 0x8200000000000000L, active1, 0L, active2, 0L); - case 78: - case 110: - return jjMoveStringLiteralDfa3_1(active0, 0x6000010000000L, active1, 0L, active2, 0L); - case 79: - case 111: - return jjMoveStringLiteralDfa3_1(active0, 0x40000000000L, active1, 0x2600L, active2, 0L); - case 80: - case 112: - return jjMoveStringLiteralDfa3_1(active0, 0x800000000000000L, active1, 0L, active2, 0L); - case 81: - case 113: - return jjMoveStringLiteralDfa3_1(active0, 0x28000000000L, active1, 0L, active2, 0L); - case 82: - case 114: - if ((active0 & 0x20000000L) != 0L) - return jjStartNfaWithStates_1(2, 29, 14); - else if ((active0 & 0x40000000000000L) != 0L) - { - jjmatchedKind = 54; - jjmatchedPos = 2; - } - return jjMoveStringLiteralDfa3_1(active0, 0x200000000L, active1, 0xa0L, active2, 0L); - case 83: - case 115: - return jjMoveStringLiteralDfa3_1(active0, 0x1000980000000L, active1, 0L, active2, 0L); - case 84: - case 116: - if ((active1 & 0x4000L) != 0L) - { - jjmatchedKind = 78; - jjmatchedPos = 2; - } - return jjMoveStringLiteralDfa3_1(active0, 0x4a0000000000000L, active1, 0x8000L, active2, 0L); - case 85: - case 117: - return jjMoveStringLiteralDfa3_1(active0, 0x4000000000000000L, active1, 0x1000L, active2, 0L); - case 87: - case 119: - if ((active0 & 0x100000000000000L) != 0L) - return jjStartNfaWithStates_1(2, 56, 14); - break; - default : - break; - } - return jjStartNfa_1(1, active0, active1, active2); -} -private final int jjMoveStringLiteralDfa3_1(long old0, long active0, long old1, long active1, long old2, long active2) -{ - if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) - return jjStartNfa_1(1, old0, old1, old2); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(2, active0, active1, 0L); - return 3; - } - switch(curChar) - { - case 65: - case 97: - return jjMoveStringLiteralDfa4_1(active0, 0x8000600000000L, active1, 0x2000L); - case 66: - case 98: - return jjMoveStringLiteralDfa4_1(active0, 0x40000000000L, active1, 0x1000L); - case 67: - case 99: - return jjMoveStringLiteralDfa4_1(active0, 0x10000000L, active1, 0L); - case 69: - case 101: - if ((active0 & 0x100000000L) != 0L) - { - jjmatchedKind = 32; - jjmatchedPos = 3; - } - else if ((active0 & 0x1000000000000L) != 0L) - return jjStartNfaWithStates_1(3, 48, 14); - else if ((active0 & 0x4000000000000000L) != 0L) - return jjStartNfaWithStates_1(3, 62, 14); - return jjMoveStringLiteralDfa4_1(active0, 0x820000080000000L, active1, 0x8120L); - case 70: - case 102: - return jjMoveStringLiteralDfa4_1(active0, 0L, active1, 0x10L); - case 73: - case 105: - return jjMoveStringLiteralDfa4_1(active0, 0x80000000000L, active1, 0x88L); - case 76: - case 108: - if ((active0 & 0x200000000000000L) != 0L) - return jjStartNfaWithStates_1(3, 57, 14); - else if ((active1 & 0x200L) != 0L) - { - jjmatchedKind = 73; - jjmatchedPos = 3; - } - else if ((active1 & 0x800L) != 0L) - return jjStartNfaWithStates_1(3, 75, 14); - return jjMoveStringLiteralDfa4_1(active0, 0x14000000000L, active1, 0x401L); - case 78: - case 110: - return jjMoveStringLiteralDfa4_1(active0, 0x1000000000L, active1, 0L); - case 79: - case 111: - if ((active0 & 0x2000000000L) != 0L) - return jjStartNfaWithStates_1(3, 37, 14); - else if ((active0 & 0x80000000000000L) != 0L) - return jjStartNfaWithStates_1(3, 55, 14); - break; - case 83: - case 115: - if ((active0 & 0x2000000000000000L) != 0L) - return jjStartNfaWithStates_1(3, 61, 14); - return jjMoveStringLiteralDfa4_1(active0, 0x8002000008000000L, active1, 0x4L); - case 84: - case 116: - if ((active0 & 0x800000000L) != 0L) - return jjStartNfaWithStates_1(3, 35, 14); - return jjMoveStringLiteralDfa4_1(active0, 0x1004100000000000L, active1, 0L); - case 85: - case 117: - return jjMoveStringLiteralDfa4_1(active0, 0x400028000000000L, active1, 0L); - case 87: - case 119: - return jjMoveStringLiteralDfa4_1(active0, 0L, active1, 0x2L); - default : - break; - } - return jjStartNfa_1(2, active0, active1, 0L); -} -private final int jjMoveStringLiteralDfa4_1(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_1(2, old0, old1, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(3, active0, active1, 0L); - return 4; - } - switch(curChar) - { - case 65: - case 97: - return jjMoveStringLiteralDfa5_1(active0, 0x40000000000L, active1, 0x20L); - case 67: - case 99: - return jjMoveStringLiteralDfa5_1(active0, 0x1000000000000000L, active1, 0x100L); - case 69: - case 101: - if ((active0 & 0x8000000000000000L) != 0L) - return jjStartNfaWithStates_1(4, 63, 14); - else if ((active1 & 0x1L) != 0L) - return jjStartNfaWithStates_1(4, 64, 14); - return jjMoveStringLiteralDfa5_1(active0, 0L, active1, 0x400L); - case 70: - case 102: - if ((active1 & 0x8L) != 0L) - return jjStartNfaWithStates_1(4, 67, 14); - break; - case 71: - case 103: - return jjMoveStringLiteralDfa5_1(active0, 0L, active1, 0x8000L); - case 72: - case 104: - return jjMoveStringLiteralDfa5_1(active0, 0L, active1, 0x2L); - case 73: - case 105: - return jjMoveStringLiteralDfa5_1(active0, 0x4128080000000L, active1, 0L); - case 75: - case 107: - if ((active0 & 0x400000000L) != 0L) - return jjStartNfaWithStates_1(4, 34, 14); - break; - case 76: - case 108: - return jjMoveStringLiteralDfa5_1(active0, 0L, active1, 0x1000L); - case 78: - case 110: - return jjMoveStringLiteralDfa5_1(active0, 0x20080000000000L, active1, 0x80L); - case 79: - case 111: - return jjMoveStringLiteralDfa5_1(active0, 0L, active1, 0x10L); - case 82: - case 114: - if ((active0 & 0x800000000000000L) != 0L) - return jjStartNfaWithStates_1(4, 59, 14); - return jjMoveStringLiteralDfa5_1(active0, 0x400000000000000L, active1, 0L); - case 83: - case 115: - if ((active0 & 0x8000000L) != 0L) - return jjStartNfaWithStates_1(4, 27, 14); - break; - case 84: - case 116: - if ((active0 & 0x1000000000L) != 0L) - return jjStartNfaWithStates_1(4, 36, 14); - else if ((active0 & 0x2000000000000L) != 0L) - return jjStartNfaWithStates_1(4, 49, 14); - else if ((active1 & 0x2000L) != 0L) - return jjStartNfaWithStates_1(4, 77, 14); - return jjMoveStringLiteralDfa5_1(active0, 0x10000000L, active1, 0L); - case 85: - case 117: - return jjMoveStringLiteralDfa5_1(active0, 0x8014000000000L, active1, 0L); - case 87: - case 119: - return jjMoveStringLiteralDfa5_1(active0, 0L, active1, 0x4L); - case 89: - case 121: - if ((active0 & 0x200000000L) != 0L) - return jjStartNfaWithStates_1(4, 33, 14); - break; - default : - break; - } - return jjStartNfa_1(3, active0, active1, 0L); -} -private final int jjMoveStringLiteralDfa5_1(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_1(3, old0, old1, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(4, active0, active1, 0L); - return 5; - } - switch(curChar) - { - case 65: - case 97: - return jjMoveStringLiteralDfa6_1(active0, 0L, active1, 0x400L); - case 67: - case 99: - if ((active0 & 0x100000000000L) != 0L) - return jjStartNfaWithStates_1(5, 44, 14); - return jjMoveStringLiteralDfa6_1(active0, 0L, active1, 0x20L); - case 68: - case 100: - return jjMoveStringLiteralDfa6_1(active0, 0x20014000000000L, active1, 0L); - case 69: - case 101: - if ((active0 & 0x80000000000L) != 0L) - return jjStartNfaWithStates_1(5, 43, 14); - else if ((active1 & 0x1000L) != 0L) - return jjStartNfaWithStates_1(5, 76, 14); - return jjMoveStringLiteralDfa6_1(active0, 0L, active1, 0x8000L); - case 70: - case 102: - if ((active0 & 0x80000000L) != 0L) - return jjStartNfaWithStates_1(5, 31, 14); - break; - case 71: - case 103: - if ((active1 & 0x80L) != 0L) - return jjStartNfaWithStates_1(5, 71, 14); - break; - case 72: - case 104: - if ((active0 & 0x1000000000000000L) != 0L) - return jjStartNfaWithStates_1(5, 60, 14); - break; - case 73: - case 105: - return jjMoveStringLiteralDfa6_1(active0, 0x10000000L, active1, 0x6L); - case 76: - case 108: - if ((active0 & 0x40000000000L) != 0L) - return jjStartNfaWithStates_1(5, 42, 14); - return jjMoveStringLiteralDfa6_1(active0, 0x8000000000000L, active1, 0L); - case 78: - case 110: - if ((active0 & 0x400000000000000L) != 0L) - return jjStartNfaWithStates_1(5, 58, 14); - return jjMoveStringLiteralDfa6_1(active0, 0x4000000000000L, active1, 0L); - case 82: - case 114: - if ((active1 & 0x10L) != 0L) - return jjStartNfaWithStates_1(5, 68, 14); - return jjMoveStringLiteralDfa6_1(active0, 0x28000000000L, active1, 0L); - case 84: - case 116: - if ((active1 & 0x100L) != 0L) - return jjStartNfaWithStates_1(5, 72, 14); - break; - default : - break; - } - return jjStartNfa_1(4, active0, active1, 0L); -} -private final int jjMoveStringLiteralDfa6_1(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_1(4, old0, old1, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(5, active0, active1, 0L); - return 6; - } - switch(curChar) - { - case 69: - case 101: - if ((active0 & 0x4000000000L) != 0L) - { - jjmatchedKind = 38; - jjmatchedPos = 6; - } - else if ((active0 & 0x8000000000L) != 0L) - { - jjmatchedKind = 39; - jjmatchedPos = 6; - } - return jjMoveStringLiteralDfa7_1(active0, 0x30000000000L, active1, 0L); - case 72: - case 104: - if ((active1 & 0x20L) != 0L) - return jjStartNfaWithStates_1(6, 69, 14); - break; - case 76: - case 108: - return jjMoveStringLiteralDfa7_1(active0, 0L, active1, 0x2L); - case 78: - case 110: - if ((active1 & 0x400L) != 0L) - return jjStartNfaWithStates_1(6, 74, 14); - break; - case 79: - case 111: - return jjMoveStringLiteralDfa7_1(active0, 0x10000000L, active1, 0L); - case 82: - case 114: - if ((active1 & 0x8000L) != 0L) - return jjStartNfaWithStates_1(6, 79, 14); - break; - case 83: - case 115: - if ((active0 & 0x20000000000000L) != 0L) - return jjStartNfaWithStates_1(6, 53, 14); - break; - case 84: - case 116: - if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_1(6, 51, 14); - return jjMoveStringLiteralDfa7_1(active0, 0L, active1, 0x4L); - case 85: - case 117: - return jjMoveStringLiteralDfa7_1(active0, 0x4000000000000L, active1, 0L); - default : - break; - } - return jjStartNfa_1(5, active0, active1, 0L); -} -private final int jjMoveStringLiteralDfa7_1(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_1(5, old0, old1, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(6, active0, active1, 0L); - return 7; - } - switch(curChar) - { - case 95: - return jjMoveStringLiteralDfa8_1(active0, 0x30000000000L, active1, 0L); - case 67: - case 99: - return jjMoveStringLiteralDfa8_1(active0, 0L, active1, 0x4L); - case 69: - case 101: - if ((active0 & 0x4000000000000L) != 0L) - return jjStartNfaWithStates_1(7, 50, 14); - else if ((active1 & 0x2L) != 0L) - return jjStartNfaWithStates_1(7, 65, 14); - break; - case 78: - case 110: - if ((active0 & 0x10000000L) != 0L) - return jjStartNfaWithStates_1(7, 28, 14); - break; - default : - break; - } - return jjStartNfa_1(6, active0, active1, 0L); -} -private final int jjMoveStringLiteralDfa8_1(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_1(6, old0, old1, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(7, active0, active1, 0L); - return 8; - } - switch(curChar) - { - case 72: - case 104: - if ((active1 & 0x4L) != 0L) - return jjStartNfaWithStates_1(8, 66, 14); - break; - case 79: - case 111: - return jjMoveStringLiteralDfa9_1(active0, 0x30000000000L, active1, 0L); - default : - break; - } - return jjStartNfa_1(7, active0, active1, 0L); -} -private final int jjMoveStringLiteralDfa9_1(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_1(7, old0, old1, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(8, active0, 0L, 0L); - return 9; - } - switch(curChar) - { - case 78: - case 110: - return jjMoveStringLiteralDfa10_1(active0, 0x30000000000L); - default : - break; - } - return jjStartNfa_1(8, active0, 0L, 0L); -} -private final int jjMoveStringLiteralDfa10_1(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjStartNfa_1(8, old0, 0L, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(9, active0, 0L, 0L); - return 10; - } - switch(curChar) - { - case 67: - case 99: - return jjMoveStringLiteralDfa11_1(active0, 0x30000000000L); - default : - break; - } - return jjStartNfa_1(9, active0, 0L, 0L); -} -private final int jjMoveStringLiteralDfa11_1(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjStartNfa_1(9, old0, 0L, 0L); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_1(10, active0, 0L, 0L); - return 11; - } - switch(curChar) - { - case 69: - case 101: - if ((active0 & 0x10000000000L) != 0L) - return jjStartNfaWithStates_1(11, 40, 14); - else if ((active0 & 0x20000000000L) != 0L) - return jjStartNfaWithStates_1(11, 41, 14); - break; - default : - break; - } - return jjStartNfa_1(10, active0, 0L, 0L); -} -private final int jjMoveNfa_1(int startState, int curPos) -{ - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 52; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 3: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(0, 6); - else if (curChar == 39) - jjCheckNAddStates(7, 12); - else if (curChar == 46) - jjCheckNAdd(8); - else if (curChar == 47) - jjstateSet[jjnewStateCnt++] = 2; - if ((0x3fe000000000000L & l) != 0L) - { - if (kind > 102) - kind = 102; - jjCheckNAddTwoStates(5, 6); - } - else if (curChar == 48) - { - if (kind > 102) - kind = 102; - jjCheckNAddStates(13, 15); - } - break; - case 0: - if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 1; - break; - case 1: - if ((0xffff7fffffffffffL & l) != 0L && kind > 18) - kind = 18; - break; - case 2: - if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 0; - break; - case 4: - if ((0x3fe000000000000L & l) == 0L) - break; - if (kind > 102) - kind = 102; - jjCheckNAddTwoStates(5, 6); - break; - case 5: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 102) - kind = 102; - jjCheckNAddTwoStates(5, 6); - break; - case 7: - if (curChar == 46) - jjCheckNAdd(8); - break; - case 8: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 106) - kind = 106; - jjCheckNAddStates(16, 18); - break; - case 10: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(11); - break; - case 11: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 106) - kind = 106; - jjCheckNAddTwoStates(11, 12); - break; - case 14: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 124) - kind = 124; - jjstateSet[jjnewStateCnt++] = 14; - break; - case 15: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(0, 6); - break; - case 16: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(16, 17); - break; - case 17: - if (curChar != 46) - break; - if (kind > 106) - kind = 106; - jjCheckNAddStates(19, 21); - break; - case 18: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 106) - kind = 106; - jjCheckNAddStates(19, 21); - break; - case 20: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(21); - break; - case 21: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 106) - kind = 106; - jjCheckNAddTwoStates(21, 12); - break; - case 22: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(22, 23); - break; - case 24: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(25); - break; - case 25: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 106) - kind = 106; - jjCheckNAddTwoStates(25, 12); - break; - case 26: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(22, 24); - break; - case 28: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(29); - break; - case 29: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(29, 12); - break; - case 30: - if (curChar != 48) - break; - if (kind > 102) - kind = 102; - jjCheckNAddStates(13, 15); - break; - case 32: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 102) - kind = 102; - jjCheckNAddTwoStates(32, 6); - break; - case 33: - if ((0xff000000000000L & l) == 0L) - break; - if (kind > 102) - kind = 102; - jjCheckNAddTwoStates(33, 6); - break; - case 34: - if (curChar == 39) - jjCheckNAddStates(7, 12); - break; - case 35: - if ((0xffffff7fffffffffL & l) != 0L) - jjCheckNAddStates(25, 27); - break; - case 37: - jjCheckNAddStates(25, 27); - break; - case 38: - if (curChar == 39 && kind > 108) - kind = 108; - break; - case 39: - if ((0xffffff7fffffffffL & l) != 0L) - jjCheckNAddStates(28, 30); - break; - case 41: - jjCheckNAddStates(28, 30); - break; - case 42: - if (curChar == 39 && kind > 109) - kind = 109; - break; - case 44: - case 46: - jjCheckNAddStates(31, 33); - break; - case 48: - case 50: - jjCheckNAddStates(34, 36); - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 3: - if ((0x87fffffe87fffffeL & l) != 0L) - { - if (kind > 124) - kind = 124; - jjCheckNAdd(14); - } - else if (curChar == 96) - jjCheckNAddStates(37, 42); - break; - case 1: - if (kind > 18) - kind = 18; - break; - case 6: - if ((0x100000001000L & l) != 0L && kind > 102) - kind = 102; - break; - case 9: - if ((0x2000000020L & l) != 0L) - jjAddStates(43, 44); - break; - case 12: - if ((0x5000000050L & l) != 0L && kind > 106) - kind = 106; - break; - case 13: - case 14: - if ((0x87fffffe87fffffeL & l) == 0L) - break; - if (kind > 124) - kind = 124; - jjCheckNAdd(14); - break; - case 19: - if ((0x2000000020L & l) != 0L) - jjAddStates(45, 46); - break; - case 23: - if ((0x2000000020L & l) != 0L) - jjAddStates(47, 48); - break; - case 27: - if ((0x2000000020L & l) != 0L) - jjAddStates(49, 50); - break; - case 31: - if ((0x100000001000000L & l) != 0L) - jjCheckNAdd(32); - break; - case 32: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 102) - kind = 102; - jjCheckNAddTwoStates(32, 6); - break; - case 35: - if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(25, 27); - break; - case 36: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 37; - break; - case 37: - jjCheckNAddStates(25, 27); - break; - case 39: - if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(28, 30); - break; - case 40: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 41; - break; - case 41: - jjCheckNAddStates(28, 30); - break; - case 43: - if (curChar == 96) - jjCheckNAddStates(37, 42); - break; - case 44: - if ((0xfffffffeefffffffL & l) != 0L) - jjCheckNAddStates(31, 33); - break; - case 45: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 46; - break; - case 46: - jjCheckNAddStates(31, 33); - break; - case 47: - if (curChar == 96 && kind > 108) - kind = 108; - break; - case 48: - if ((0xfffffffeefffffffL & l) != 0L) - jjCheckNAddStates(34, 36); - break; - case 49: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 50; - break; - case 50: - jjCheckNAddStates(34, 36); - break; - case 51: - if (curChar == 96 && kind > 110) - kind = 110; - break; - default : break; - } - } while(i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 3: - case 14: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 124) - kind = 124; - jjCheckNAdd(14); - break; - case 1: - if ((jjbitVec0[i2] & l2) != 0L && kind > 18) - kind = 18; - break; - case 35: - case 37: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(25, 27); - break; - case 39: - case 41: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(28, 30); - break; - case 44: - case 46: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(31, 33); - break; - case 48: - case 50: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(34, 36); - break; - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 52 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private final int jjStopStringLiteralDfa_7(int pos, long active0, long active1) -{ - switch (pos) - { - default : - return -1; - } -} -private final int jjStartNfa_7(int pos, long active0, long active1) -{ - return jjMoveNfa_7(jjStopStringLiteralDfa_7(pos, active0, active1), pos + 1); -} -private final int jjStartNfaWithStates_7(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_7(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_7() -{ - switch(curChar) - { - case 34: - return jjStopAtPos(0, 114); - case 123: - return jjStopAtPos(0, 115); - default : - return jjMoveNfa_7(0, 0); - } -} -private final int jjMoveNfa_7(int startState, int curPos) -{ - int[] nextStates; - int startsAt = 0; - jjnewStateCnt = 4; - int i = 1; - jjstateSet[0] = startState; - int j, kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 1: - if (kind > 111) - kind = 111; - break; - case 3: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 124) - kind = 124; - jjstateSet[jjnewStateCnt++] = 3; - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0x87fffffe87fffffeL & l) != 0L) - { - if (kind > 124) - kind = 124; - jjCheckNAdd(3); - } - else if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 1; - break; - case 1: - if (kind > 111) - kind = 111; - break; - case 2: - case 3: - if ((0x87fffffe87fffffeL & l) == 0L) - break; - if (kind > 124) - kind = 124; - jjCheckNAdd(3); - break; - default : break; - } - } while(i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: do - { - switch(jjstateSet[--i]) - { - case 0: - case 3: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 124) - kind = 124; - jjCheckNAdd(3); - break; - case 1: - if ((jjbitVec0[i2] & l2) != 0L && kind > 111) - kind = 111; - break; - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 4 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -static final int[] jjnextStates = { - 16, 17, 22, 23, 26, 27, 12, 35, 36, 38, 39, 40, 42, 31, 33, 6, - 8, 9, 12, 18, 19, 12, 26, 27, 12, 35, 36, 38, 39, 40, 42, 44, - 45, 47, 48, 49, 51, 44, 45, 47, 48, 49, 51, 10, 11, 20, 21, 24, - 25, 28, 29, -}; -public static final String[] jjstrLiteralImages = { -"", "\74\77", null, "\74\77\75", "\77\76", null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, "\55\76", "\72\72", "\75\76", null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, "\100", "\41", "\176", "\77", "\72", "\174\174", "\46\46", "\53\53", "\55\55", -"\53", "\55", "\52", "\57", "\46", "\174", "\136", "\45", "\74\74", "\76\76", -"\76\76\76", null, null, null, null, null, null, null, null, null, null, null, null, "\42", -"\44", "\42", "\173", null, null, null, "\175", null, null, null, "\44", null, null, -null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", "\73", "\54", "\56", -"\76", "\74", "\75\75", "\74\75", "\76\75", "\41\75", "\74\76", "\41\75\75", -"\75\75\75", "\75", "\53\75", "\55\75", "\52\75", "\57\75", "\46\75", "\174\75", "\136\75", -"\56\75", "\45\75", "\176\75", "\74\74\75", "\76\76\75", }; -public static final String[] lexStateNames = { - "DEFAULT", - "PHPPARSING", - "IN_SINGLE_LINE_COMMENT", - "IN_VARIABLE", - "IN_FORMAL_COMMENT", - "IN_MULTI_LINE_COMMENT", - "IN_STRING", - "DOLLAR_IN_STRING", - "SKIPSTRING", - "DOLLAR_IN_STRING_EXPR", -}; -public static final int[] jjnewLexState = { - -1, 1, 1, 1, 0, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 2, 2, 4, 5, 1, -1, -1, -1, 1, - 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 6, 7, 1, 9, 8, 6, -1, 7, -1, -1, -1, 3, -1, - -1, -1, -1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -}; -static final long[] jjtoToken = { - 0xfffffffff880001fL, 0x198f747fffffffffL, 0xfffffffeL, -}; -static final long[] jjtoSkip = { - 0x37fffe0L, 0x670800000000000L, 0x1L, -}; -static final long[] jjtoSpecial = { - 0x37ff800L, 0x30000000000000L, 0x1L, -}; -static final long[] jjtoMore = { - 0x4000000L, 0x0L, 0x0L, -}; -protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[52]; -private final int[] jjstateSet = new int[104]; -StringBuffer image; -int jjimageLen; -int lengthOfMatch; -protected char curChar; -public PHPParserTokenManager(SimpleCharStream stream) -{ - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; -} -public PHPParserTokenManager(SimpleCharStream stream, int lexState) -{ - this(stream); - SwitchTo(lexState); -} -public void ReInit(SimpleCharStream stream) -{ - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); -} -private final void ReInitRounds() -{ - int i; - jjround = 0x80000001; - for (i = 52; i-- > 0;) - jjrounds[i] = 0x80000000; -} -public void ReInit(SimpleCharStream stream, int lexState) -{ - ReInit(stream); - SwitchTo(lexState); -} -public void SwitchTo(int lexState) -{ - if (lexState >= 10 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; -} - -protected Token jjFillToken() -{ - Token t = Token.newToken(jjmatchedKind); - t.kind = jjmatchedKind; - if (jjmatchedPos < 0) - { - t.image = ""; - t.beginLine = t.endLine = input_stream.getBeginLine(); - t.beginColumn = t.endColumn = input_stream.getBeginColumn(); - } - else - { - String im = jjstrLiteralImages[jjmatchedKind]; - t.image = (im == null) ? input_stream.GetImage() : im; - t.beginLine = input_stream.getBeginLine(); - t.beginColumn = input_stream.getBeginColumn(); - t.endLine = input_stream.getEndLine(); - t.endColumn = input_stream.getEndColumn(); - } - return t; -} - -int curLexState = 0; -int defaultLexState = 0; -int jjnewStateCnt; -int jjround; -int jjmatchedPos; -int jjmatchedKind; - -public Token getNextToken() -{ - int kind; - Token specialToken = null; - Token matchedToken; - int curPos = 0; - - EOFLoop : - for (;;) - { - try - { - curChar = input_stream.BeginToken(); - } - catch(java.io.IOException e) - { - jjmatchedKind = 0; - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - CommonTokenAction(matchedToken); - return matchedToken; - } - image = null; - jjimageLen = 0; - - for (;;) - { - switch(curLexState) - { - case 0: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedPos == 0 && jjmatchedKind > 5) - { - jjmatchedKind = 5; - } - break; - case 1: - try { input_stream.backup(0); - while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e1) { continue EOFLoop; } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_1(); - break; - case 2: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_2(); - if (jjmatchedPos == 0 && jjmatchedKind > 21) - { - jjmatchedKind = 21; - } - break; - case 3: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_3(); - break; - case 4: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_4(); - if (jjmatchedPos == 0 && jjmatchedKind > 26) - { - jjmatchedKind = 26; - } - break; - case 5: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_5(); - if (jjmatchedPos == 0 && jjmatchedKind > 26) - { - jjmatchedKind = 26; - } - break; - case 6: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_6(); - if (jjmatchedPos == 0 && jjmatchedKind > 121) - { - jjmatchedKind = 121; - } - break; - case 7: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_7(); - if (jjmatchedPos == 0 && jjmatchedKind > 128) - { - jjmatchedKind = 128; - } - break; - case 8: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_8(); - if (jjmatchedPos == 0 && jjmatchedKind > 118) - { - jjmatchedKind = 118; - } - break; - case 9: - jjmatchedKind = 120; - jjmatchedPos = -1; - curPos = 0; - curPos = jjMoveStringLiteralDfa0_9(); - if (jjmatchedPos < 0 || (jjmatchedPos == 0 && jjmatchedKind > 122)) - { - jjmatchedKind = 122; - jjmatchedPos = 0; - } - break; - } - if (jjmatchedKind != 0x7fffffff) - { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - TokenLexicalActions(matchedToken); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - CommonTokenAction(matchedToken); - return matchedToken; - } - else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - if (specialToken == null) - specialToken = matchedToken; - else - { - matchedToken.specialToken = specialToken; - specialToken = (specialToken.next = matchedToken); - } - SkipLexicalActions(matchedToken); - } - else - SkipLexicalActions(null); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - continue EOFLoop; - } - jjimageLen += jjmatchedPos + 1; - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - curPos = 0; - jjmatchedKind = 0x7fffffff; - try { - curChar = input_stream.readChar(); - continue; - } - catch (java.io.IOException e1) { } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try { input_stream.readChar(); input_stream.backup(1); } - catch (java.io.IOException e1) { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') { - error_line++; - error_column = 0; - } - else - error_column++; - } - if (!EOFSeen) { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } - } -} - -void SkipLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - case 18 : - if (image == null) - image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)))); - else - image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)))); - input_stream.backup(1); - break; - default : - break; - } -} -void TokenLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - default : - break; - } -} -} diff --git a/net.sourceforge.phpeclipse/src/test/PHPVar.java b/net.sourceforge.phpeclipse/src/test/PHPVar.java deleted file mode 100644 index 497000d..0000000 --- a/net.sourceforge.phpeclipse/src/test/PHPVar.java +++ /dev/null @@ -1,122 +0,0 @@ -package test; - - -/** - * A Variable usage. It could be a first use, an in code use of an already declared var. - * In fact I'm not sure for the moment I will keep this - * @author Matthieu Casanova - */ -public class PHPVar { - - /** The name of the variable. It couldn't be changed. */ - private final String name; - - /** The value. It could change. */ - private String value; - - /** - * Tell if the variable is a reference or not (given in function by &$varname, - * or comming from a 'global' keyword. - */ - private boolean reference; - - /** - * Does the variable have a value or not. - * If we don't know if it was initialized it should be set on true. - * (when we have a global keyword for example) - */ - private boolean initialized; - - /** This variable indicate if it is used or not in the code. */ - private boolean used; - - /** - * We initialize the name and the value of the variable. - * @param name the name of the variable - * @param value the value of the variable - */ - public PHPVar(String name, String value) { - this.name = name; - this.value = value; - initialized = value != null; - } - - /** - * We initialize the name of the variable. The value will be null - * @param name the name of the variable - */ - public PHPVar(String name) { - this.name = name; - } - - /** - * Initialize the variable name and set the initialization status. - * @param name the name of the variable - * @param initialized the initialization status (it should be true or it's unuseful) - */ - public PHPVar(String name, boolean initialized) { - this(name); - this.initialized = initialized; - } - - /** - * Give a reference to the variable. - * @param reference a reference - */ - public void setReference(boolean reference) { - this.reference = reference; - if (reference) {// a reference variable status is unknown so is initialized for me - //example : global - initialized = true; - } - } - - /** - * Tell if the variable is reference. - * @return a boolean - */ - public boolean isReference() { - return reference; - } - - public void setUsed(boolean used) { - this.used = used; - } - - public void setInitialized(boolean initialized) { - this.initialized = initialized; - } - - /** - * Get the name of the variable. - * @return a string containing the name of the variable - */ - public String getName() { - return name; - } - - /** - * Tell if the variable was used. - * @return a boolean telling if the variable is used - */ - public boolean isUsed() { - return used; - } - - /** - * Return a human readable variable (: - * @return a string representation of the object. - */ - public String toString() { - if (value == null) { - if (reference) { - return "&$" + name; - } - return "$" + name; - } - if (reference) { - return "&$" + name + "=" + value; - } - return "$" + name + "=" + value; - } -} diff --git a/net.sourceforge.phpeclipse/src/test/ParseException.java b/net.sourceforge.phpeclipse/src/test/ParseException.java deleted file mode 100644 index d8a2f6a..0000000 --- a/net.sourceforge.phpeclipse/src/test/ParseException.java +++ /dev/null @@ -1,192 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ -package test; - -/** - * This exception is thrown when parse errors are encountered. - * You can explicitly create objects of this exception type by - * calling the method generateParseException in the generated - * parser. - * - * You can modify this class to customize your error reporting - * mechanisms so long as you retain the public fields. - */ -public class ParseException extends Exception { - - /** - * This constructor is used by the method "generateParseException" - * in the generated parser. Calling this constructor generates - * a new object of this type with the fields "currentToken", - * "expectedTokenSequences", and "tokenImage" set. The boolean - * flag "specialConstructor" is also set to true to indicate that - * this constructor was used to create this object. - * This constructor calls its super class with the empty string - * to force the "toString" method of parent class "Throwable" to - * print the error message in the form: - * ParseException: - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, - String[] tokenImageVal - ) - { - super(""); - specialConstructor = true; - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } - - /** - * The following constructors are for use by you for whatever - * purpose you can think of. Constructing the exception in this - * manner makes the exception behave in the normal way - i.e., as - * documented in the class "Throwable". The fields "errorToken", - * "expectedTokenSequences", and "tokenImage" do not contain - * relevant information. The JavaCC generated code does not use - * these constructors. - */ - - public ParseException() { - super(); - specialConstructor = false; - } - - public ParseException(String message) { - super(message); - specialConstructor = false; - } - - /** - * This variable determines which constructor was used to create - * this object and thereby affects the semantics of the - * "getMessage" method (see below). - */ - protected boolean specialConstructor; - - /** - * This is the last token that has been consumed successfully. If - * this object has been created due to a parse error, the token - * followng this token will (therefore) be the first error token. - */ - public Token currentToken; - - /** - * Each entry in this array is an array of integers. Each array - * of integers represents a sequence of tokens (by their ordinal - * values) that is expected at this point of the parse. - */ - public int[][] expectedTokenSequences; - - /** - * This is a reference to the "tokenImage" array of the generated - * parser within which the parse error occurred. This array is - * defined in the generated ...Constants interface. - */ - public String[] tokenImage; - - /** - * This method has the standard behavior when this object has been - * created using the standard constructors. Otherwise, it uses - * "currentToken" and "expectedTokenSequences" to generate a parse - * error message and returns it. If this object has been created - * due to a parse error, and you do not catch it (it gets thrown - * from the parser), then this method is called during the printing - * of the final stack trace, and hence the correct error message - * gets displayed. - */ - public String getMessage() { - if (!specialConstructor) { - return super.getMessage(); - } - String expected = ""; - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected += tokenImage[expectedTokenSequences[i][j]] + " "; - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected += "..."; - } - expected += eol + " "; - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) retval += " "; - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += add_escapes(tok.image); - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; - retval += "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; - } - retval += expected; - return retval; - } - - /** - * The end of line string for this machine. - */ - protected String eol = System.getProperty("line.separator", "\n"); - - /** - * Used to convert raw characters to their escaped version - * when these raw version cannot be used as part of an ASCII - * string literal. - */ - protected String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - -} diff --git a/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java b/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java deleted file mode 100644 index 3ccaf79..0000000 --- a/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java +++ /dev/null @@ -1,442 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */ -package test; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -public class SimpleCharStream -{ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; - public int bufpos = -1; - - protected int beginOffset, endOffset; - - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - protected StringBuffer currentBuffer = new StringBuffer(); - - protected void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, - bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - position += bufpos; - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) { - position += bufpos; - bufpos = maxNextCharInd = 0; - } else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, - available - maxNextCharInd)) == -1) - { - inputStream.close(); - throw new java.io.IOException(); - } - else { - maxNextCharInd += i; - } - currentBuffer.append(buffer); - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - - public char BeginToken() throws java.io.IOException - { - beginOffset = endOffset; - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (8 - (column & 07)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - - public char readChar() throws java.io.IOException - { - endOffset++; - if (inBuf > 0) - { - --inBuf; - - if (++bufpos == bufsize) { - position += bufpos; - bufpos = 0; - } - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return (c); - } - - /** - * @deprecated - * @see #getEndColumn - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @deprecated - * @see #getEndLine - */ - - public int getLine() { - return bufline[bufpos]; - } - - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - public int getEndLine() { - return bufline[bufpos]; - } - - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - public int getBeginLine() { - return bufline[tokenBegin]; - } - - public void backup(int amount) { - - endOffset -= amount; - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - currentBuffer = new StringBuffer(); - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - beginOffset = 0; - endOffset = 0; - } - - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.Reader dstream) - { - this(dstream, 1, 1, 4096); - } - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - currentBuffer = new StringBuffer(); - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - position = 0; - beginOffset = 0; - endOffset = 0; - } - - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - public void ReInit(java.io.Reader dstream) - { - ReInit(dstream, 1, 1, 4096); - } - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream) - { - this(dstream, 1, 1, 4096); - } - - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); - } - - public void ReInit(java.io.InputStream dstream) - { - ReInit(dstream, 1, 1, 4096); - } - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - public String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - public char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token.
- */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && - bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - - public StringBuffer getCurrentBuffer() { - return currentBuffer; - } - - //Added by Matthieu Casanova - public int position = 0; - /** - * @deprecated - * @return - */ - public int getPosition() { - return position + bufpos; - } - - public int getBeginOffset() { - return beginOffset; - } - - public int getEndOffset() { - return endOffset; - } -} diff --git a/net.sourceforge.phpeclipse/src/test/Token.java b/net.sourceforge.phpeclipse/src/test/Token.java deleted file mode 100644 index 2170377..0000000 --- a/net.sourceforge.phpeclipse/src/test/Token.java +++ /dev/null @@ -1,83 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ -package test; - -/** - * Describes the input token stream. - */ - -public class Token { - - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** - * beginLine and beginColumn describe the position of the first character - * of this token; endLine and endColumn describe the position of the - * last character of this token. - */ - public int beginLine, beginColumn, endLine, endColumn; - - //Matthieu Casanova addition - public int sourceStart, sourceEnd; - /** - * The string image of the token. - */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** - * Returns the image. - */ - public String toString() - { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simlpy add something like : - * - * case MyParserConstants.ID : return new IDToken(); - * - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use it in your lexical actions. - */ - public static final Token newToken(int ofKind) - { - switch(ofKind) - { - default : return new Token(); - } - } - -} diff --git a/net.sourceforge.phpeclipse/src/test/TokenMgrError.java b/net.sourceforge.phpeclipse/src/test/TokenMgrError.java deleted file mode 100644 index 64cc02b..0000000 --- a/net.sourceforge.phpeclipse/src/test/TokenMgrError.java +++ /dev/null @@ -1,133 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ -package test; - -public class TokenMgrError extends Error -{ - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** - * Lexical error occured. - */ - static final int LEXICAL_ERROR = 0; - - /** - * An attempt wass made to create a second instance of a static token manager. - */ - static final int STATIC_LEXER_ERROR = 1; - - /** - * Tried to change to an invalid lexical state. - */ - static final int INVALID_LEXICAL_STATE = 2; - - /** - * Detected (and bailed out of) an infinite loop in the token manager. - */ - static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - - /** - * Replaces unprintable characters by their espaced (or unicode escaped) - * equivalents in the given string - */ - protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - - /** - * Returns a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - * Parameters : - * EOFSeen : indicates if EOF caused the lexicl error - * curLexState : lexical state in which this error occured - * errorLine : line number when the error occured - * errorColumn : column number when the error occured - * errorAfter : prefix that was seen before this error occured - * curchar : the offending character - * Note: You can customize the lexical error message by modifying this method. - */ - protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * - * "Internal Error : Please file a bug report .... " - * - * from this method for such cases in the release version of your parser. - */ - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - public TokenMgrError() { - } - - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -}