X-Git-Url: http://secure.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java
index 30114bb..8b59f42 100644
--- a/net.sourceforge.phpeclipse/src/test/PHPParser.java
+++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java
@@ -8,7 +8,6 @@ import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.jface.preference.IPreferenceStore;
import java.util.Hashtable;
-import java.util.Enumeration;
import java.util.ArrayList;
import java.io.StringReader;
import java.io.*;
@@ -39,9 +38,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$
static PHPOutlineInfo outlineInfo;
- public static MethodDeclaration currentFunction;
- private static boolean assigning;
-
/** 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 */
@@ -50,6 +46,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
private static int errorStart = -1;
private static int errorEnd = -1;
private static PHPDocument phpDocument;
+
+ private static final char[] SYNTAX_ERROR_CHAR = {'s','y','n','t','a','x',' ','e','r','r','o','r'};
/**
* The point where html starts.
* It will be used by the token manager to create HTMLCode objects
@@ -62,12 +60,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
private static AstNode[] nodes;
/** The cursor in expression stack. */
private static int nodePtr;
- private static VariableDeclaration[] variableDeclarationStack;
- private static int variableDeclarationPtr;
- private static Statement[] statementStack;
- private static int statementPtr;
- private static ElseIf[] elseIfStack;
- private static int elseIfPtr;
public final void setFileToParse(final IFile fileToParse) {
this.fileToParse = fileToParse;
@@ -86,11 +78,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
*/
private static final void init() {
nodes = new AstNode[AstStackIncrement];
- statementStack = new Statement[AstStackIncrement];
- elseIfStack = new ElseIf[AstStackIncrement];
nodePtr = -1;
- statementPtr = -1;
- elseIfPtr = -1;
htmlStart = 0;
}
@@ -111,83 +99,10 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
}
}
- private static final void pushOnVariableDeclarationStack(VariableDeclaration var) {
- try {
- variableDeclarationStack[++variableDeclarationPtr] = var;
- } catch (IndexOutOfBoundsException e) {
- int oldStackLength = variableDeclarationStack.length;
- VariableDeclaration[] oldStack = variableDeclarationStack;
- variableDeclarationStack = new VariableDeclaration[oldStackLength + AstStackIncrement];
- System.arraycopy(oldStack, 0, variableDeclarationStack, 0, oldStackLength);
- variableDeclarationPtr = oldStackLength;
- variableDeclarationStack[variableDeclarationPtr] = var;
- }
- }
-
- private static final void pushOnStatementStack(Statement statement) {
- try {
- statementStack[++statementPtr] = statement;
- } catch (IndexOutOfBoundsException e) {
- int oldStackLength = statementStack.length;
- Statement[] oldStack = statementStack;
- statementStack = new Statement[oldStackLength + AstStackIncrement];
- System.arraycopy(oldStack, 0, statementStack, 0, oldStackLength);
- statementPtr = oldStackLength;
- statementStack[statementPtr] = statement;
- }
- }
-
- private static final void pushOnElseIfStack(ElseIf elseIf) {
- try {
- elseIfStack[++elseIfPtr] = elseIf;
- } catch (IndexOutOfBoundsException e) {
- int oldStackLength = elseIfStack.length;
- ElseIf[] oldStack = elseIfStack;
- elseIfStack = new ElseIf[oldStackLength + AstStackIncrement];
- System.arraycopy(oldStack, 0, elseIfStack, 0, oldStackLength);
- elseIfPtr = oldStackLength;
- elseIfStack[elseIfPtr] = elseIf;
- }
- }
-
- public static final void phpParserTester(final String strEval) throws CoreException, ParseException {
- PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING);
- final StringReader stream = new StringReader(strEval);
- if (jj_input_stream == null) {
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- }
- ReInit(new StringReader(strEval));
- init();
- phpTest();
- }
-
- public static final void htmlParserTester(final File fileName) throws CoreException, ParseException {
- try {
- final Reader stream = new FileReader(fileName);
- if (jj_input_stream == null) {
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- }
- ReInit(stream);
- init();
- phpFile();
- } catch (FileNotFoundException e) {
- e.printStackTrace(); //To change body of catch statement use Options | File Templates.
- }
- }
-
- public static final void htmlParserTester(final String strEval) throws CoreException, ParseException {
- final StringReader stream = new StringReader(strEval);
- if (jj_input_stream == null) {
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- }
- ReInit(stream);
- init();
- phpFile();
- }
-
public final PHPOutlineInfo parseInfo(final Object parent, final String s) {
- currentSegment = new PHPDocument(parent);
- outlineInfo = new PHPOutlineInfo(parent);
+ 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);
@@ -196,9 +111,11 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
init();
try {
parse();
- phpDocument = new PHPDocument(null);
- phpDocument.nodes = nodes;
- PHPeclipsePlugin.log(1,phpDocument.toString());
+ 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);
}
@@ -214,7 +131,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
if (errorMessage == null) {
PHPeclipsePlugin.log(e);
errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it";
- errorStart = jj_input_stream.getPosition();
+ errorStart = SimpleCharStream.getPosition();
errorEnd = errorStart + 1;
}
setMarker(e);
@@ -230,8 +147,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
if (errorStart == -1) {
setMarker(fileToParse,
errorMessage,
- jj_input_stream.tokenBegin,
- jj_input_stream.tokenBegin + e.currentToken.image.length(),
+ SimpleCharStream.tokenBegin,
+ SimpleCharStream.tokenBegin + e.currentToken.image.length(),
errorLevel,
"Line " + e.currentToken.beginLine);
} else {
@@ -249,31 +166,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
}
}
- /**
- * Create markers according to the external parser output
- */
- private static void createMarkers(final String output, final IFile file) throws CoreException {
- // delete all markers
- file.deleteMarkers(IMarker.PROBLEM, 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 static void scanLine(final String output,
final IFile file,
final int indx,
@@ -359,18 +251,31 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
if (currentPosition == htmlStart) {
return;
}
- final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,currentPosition).toCharArray();
+ final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,currentPosition+1).toCharArray();
pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition));
}
- private static final void parse() throws ParseException {
- phpFile();
+ /**
+ * Create a new task.
+ */
+ public static final void createNewTask() {
+ final int currentPosition = SimpleCharStream.getPosition();
+ final String todo = SimpleCharStream.currentBuffer.substring(currentPosition+1,
+ SimpleCharStream.currentBuffer.indexOf("\n",
+ currentPosition)-1);
+ try {
+ setMarker(fileToParse,
+ "todo : " + todo,
+ SimpleCharStream.getBeginLine(),
+ TASK,
+ "Line "+SimpleCharStream.getBeginLine());
+ } catch (CoreException e) {
+ PHPeclipsePlugin.log(e);
+ }
}
- static final public void phpTest() throws ParseException {
- Php();
- jj_consume_token(0);
- PHPParser.createNewHTMLCode();
+ private static final void parse() throws ParseException {
+ phpFile();
}
static final public void phpFile() throws ParseException {
@@ -431,7 +336,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
}
PhpBlock();
}
- jj_consume_token(0);
+ PHPParser.createNewHTMLCode();
} catch (TokenMgrError e) {
PHPeclipsePlugin.log(e);
errorStart = SimpleCharStream.getPosition();
@@ -448,10 +353,12 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
* or somephpcode ?>
*/
static final public void PhpBlock() throws ParseException {
- final int start = jj_input_stream.getPosition();
+ final int start = SimpleCharStream.getPosition();
+ final PHPEchoBlock phpEchoBlock;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case PHPECHOSTART:
- phpEchoBlock();
+ phpEchoBlock = phpEchoBlock();
+ pushOnAstNodes(phpEchoBlock);
break;
case PHPSTARTSHORT:
case PHPSTARTLONG:
@@ -510,7 +417,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
setMarker(fileToParse,
"You should use '' expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
- {if (true) throw e;}
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
+ processParseException(e);
}
break;
default:
@@ -626,43 +533,48 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
final Token className;
Token superclassName = null;
final int pos;
+ char[] classNameImage = SYNTAX_ERROR_CHAR;
+ char[] superclassNameImage = null;
jj_consume_token(CLASS);
+ pos = SimpleCharStream.getPosition();
try {
- pos = jj_input_stream.getPosition();
className = jj_consume_token(IDENTIFIER);
+ classNameImage = className.image.toCharArray();
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
- {if (true) throw e;}
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
+ processParseException(e);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EXTENDS:
jj_consume_token(EXTENDS);
try {
superclassName = jj_consume_token(IDENTIFIER);
+ superclassNameImage = superclassName.image.toCharArray();
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
- {if (true) throw e;}
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
+ processParseException(e);
+ superclassNameImage = SYNTAX_ERROR_CHAR;
}
break;
default:
jj_la1[6] = jj_gen;
;
}
- if (superclassName == null) {
+ if (superclassNameImage == null) {
classDeclaration = new ClassDeclaration(currentSegment,
- className.image.toCharArray(),
+ classNameImage,
pos,
0);
} else {
classDeclaration = new ClassDeclaration(currentSegment,
- className.image.toCharArray(),
- superclassName.image.toCharArray(),
+ classNameImage,
+ superclassNameImage,
pos,
0);
}
@@ -682,8 +594,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image + "', '{' expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
label_3:
@@ -704,8 +616,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', 'var', 'function' or '}' expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
}
@@ -723,7 +635,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
break;
case VAR:
field = FieldDeclaration();
- classDeclaration.addVariable(field);
+ classDeclaration.addField(field);
break;
default:
jj_la1[8] = jj_gen;
@@ -744,7 +656,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
variableDeclaration = VariableDeclarator();
arrayList.add(variableDeclaration);
outlineInfo.addVariable(new String(variableDeclaration.name));
- currentSegment.add(variableDeclaration);
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -759,29 +670,29 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
variableDeclaration = VariableDeclarator();
arrayList.add(variableDeclaration);
outlineInfo.addVariable(new String(variableDeclaration.name));
- currentSegment.add(variableDeclaration);
}
try {
jj_consume_token(SEMICOLON);
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected after variable declaration";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
- {if (true) throw e;}
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
+ processParseException(e);
}
list = new VariableDeclaration[arrayList.size()];
arrayList.toArray(list);
{if (true) return new FieldDeclaration(list,
pos,
- SimpleCharStream.getPosition());}
+ SimpleCharStream.getPosition(),
+ currentSegment);}
throw new Error("Missing return statement in function");
}
static final public VariableDeclaration VariableDeclarator() throws ParseException {
- final String varName, varValue;
+ final String varName;
Expression initializer = null;
- final int pos = jj_input_stream.getPosition();
+ final int pos = SimpleCharStream.getPosition();
varName = VariableDeclaratorId();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ASSIGN:
@@ -791,8 +702,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
} catch (ParseException e) {
errorMessage = "Literal expression expected in variable initializer";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
break;
@@ -804,7 +715,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
{if (true) return new VariableDeclaration(currentSegment,
varName.toCharArray(),
pos,
- jj_input_stream.getPosition());}
+ SimpleCharStream.getPosition());}
}
{if (true) return new VariableDeclaration(currentSegment,
varName.toCharArray(),
@@ -819,13 +730,12 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
*/
static final public String VariableDeclaratorId() throws ParseException {
String expr;
- Expression expression;
+ Expression expression = null;
final StringBuffer buff = new StringBuffer();
final int pos = SimpleCharStream.getPosition();
ConstantIdentifier ex;
try {
expr = Variable();
- buff.append(expr);
label_5:
while (true) {
if (jj_2_1(2)) {
@@ -837,19 +747,25 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
pos,
SimpleCharStream.getPosition());
expression = VariableSuffix(ex);
- buff.append(expression.toStringExpression());
}
- {if (true) return buff.toString();}
+ if (expression == null) {
+ {if (true) return expr;}
+ }
+ {if (true) return expression.toStringExpression();}
} catch (ParseException e) {
errorMessage = "'$' expected for variable identifier";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
throw new Error("Missing return statement in function");
}
+/**
+ * Return a variablename without the $.
+ * @return a variable name
+ */
static final public String Variable() throws ParseException {
final StringBuffer buff;
Expression expression = null;
@@ -868,13 +784,13 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
jj_la1[11] = jj_gen;
;
}
- if (expression == null && !assigning) {
+ if (expression == null) {
{if (true) return token.image.substring(1);}
}
buff = new StringBuffer(token.image);
- buff.append('{');
+ buff.append("{");
buff.append(expression.toStringExpression());
- buff.append('}');
+ buff.append("}");
{if (true) return buff.toString();}
break;
case DOLLAR:
@@ -890,6 +806,10 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
throw new Error("Missing return statement in function");
}
+/**
+ * A Variable name (without the $)
+ * @return a variable name String
+ */
static final public String VariableName() throws ParseException {
final StringBuffer buff;
String expr = null;
@@ -900,9 +820,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
jj_consume_token(LBRACE);
expression = Expression();
jj_consume_token(RBRACE);
- buff = new StringBuffer('{');
+ buff = new StringBuffer("{");
buff.append(expression.toStringExpression());
- buff.append('}');
+ buff.append("}");
{if (true) return buff.toString();}
break;
case IDENTIFIER:
@@ -921,15 +841,15 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
{if (true) return token.image;}
}
buff = new StringBuffer(token.image);
- buff.append('{');
+ buff.append("{");
buff.append(expression.toStringExpression());
- buff.append('}');
+ buff.append("}");
{if (true) return buff.toString();}
break;
case DOLLAR:
jj_consume_token(DOLLAR);
expr = VariableName();
- buff = new StringBuffer('$');
+ buff = new StringBuffer("$");
buff.append(expr);
{if (true) return buff.toString();}
break;
@@ -1098,9 +1018,9 @@ Expression expr,expr2;
*/
static final public MethodDeclaration MethodDeclaration() throws ParseException {
final MethodDeclaration functionDeclaration;
- Token functionToken;
final Block block;
- functionToken = jj_consume_token(FUNCTION);
+ final OutlineableWithChildren seg = currentSegment;
+ jj_consume_token(FUNCTION);
try {
functionDeclaration = MethodDeclarator();
outlineInfo.addVariable(new String(functionDeclaration.name));
@@ -1108,22 +1028,15 @@ Expression expr,expr2;
if (errorMessage != null) {if (true) throw e;}
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
- if (currentSegment != null) {
- currentSegment.add(functionDeclaration);
- currentSegment = functionDeclaration;
- }
- currentFunction = functionDeclaration;
+ currentSegment = functionDeclaration;
block = Block();
- functionDeclaration.statements = block.statements;
- currentFunction = null;
- if (currentSegment != null) {
- currentSegment = (OutlineableWithChildren) currentSegment.getParent();
- }
- {if (true) return functionDeclaration;}
+ functionDeclaration.statements = block.statements;
+ currentSegment = seg;
+ {if (true) return functionDeclaration;}
throw new Error("Missing return statement in function");
}
@@ -1137,6 +1050,7 @@ Expression expr,expr2;
Token reference = null;
final Hashtable formalParameters;
final int pos = SimpleCharStream.getPosition();
+ char[] identifierChar = SYNTAX_ERROR_CHAR;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case BIT_AND:
reference = jj_consume_token(BIT_AND);
@@ -1145,14 +1059,23 @@ Expression expr,expr2;
jj_la1[21] = jj_gen;
;
}
- identifier = jj_consume_token(IDENTIFIER);
+ try {
+ identifier = jj_consume_token(IDENTIFIER);
+ identifierChar = identifier.image.toCharArray();
+ } catch (ParseException e) {
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected";
+ errorLevel = ERROR;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
+ processParseException(e);
+ }
formalParameters = FormalParameters();
{if (true) return new MethodDeclaration(currentSegment,
- identifier.image.toCharArray(),
- formalParameters,
- reference != null,
- pos,
- SimpleCharStream.getPosition());}
+ identifierChar,
+ formalParameters,
+ reference != null,
+ pos,
+ SimpleCharStream.getPosition());}
throw new Error("Missing return statement in function");
}
@@ -1161,8 +1084,6 @@ Expression expr,expr2;
* (FormalParameter())
*/
static final public Hashtable FormalParameters() throws ParseException {
- String expr;
- final StringBuffer buff = new StringBuffer("(");
VariableDeclaration var;
final Hashtable parameters = new Hashtable();
try {
@@ -1170,9 +1091,9 @@ Expression expr,expr2;
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
- {if (true) throw e;}
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
+ processParseException(e);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case DOLLAR:
@@ -1204,9 +1125,9 @@ Expression expr,expr2;
} catch (ParseException e) {
errorMessage = "')' expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
- {if (true) throw e;}
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
+ processParseException(e);
}
{if (true) return parameters;}
throw new Error("Missing return statement in function");
@@ -1241,56 +1162,47 @@ Expression expr,expr2;
case STRING:
jj_consume_token(STRING);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.STRING,
- pos,pos-6);}
+ {if (true) return new ConstantIdentifier(Types.STRING,pos,pos-6);}
break;
case BOOL:
jj_consume_token(BOOL);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.BOOL,
- pos,pos-4);}
+ {if (true) return new ConstantIdentifier(Types.BOOL,pos,pos-4);}
break;
case BOOLEAN:
jj_consume_token(BOOLEAN);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.BOOLEAN,
- pos,pos-7);}
+ {if (true) return new ConstantIdentifier(Types.BOOLEAN,pos,pos-7);}
break;
case REAL:
jj_consume_token(REAL);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.REAL,
- pos,pos-4);}
+ {if (true) return new ConstantIdentifier(Types.REAL,pos,pos-4);}
break;
case DOUBLE:
jj_consume_token(DOUBLE);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.DOUBLE,
- pos,pos-5);}
+ {if (true) return new ConstantIdentifier(Types.DOUBLE,pos,pos-5);}
break;
case FLOAT:
jj_consume_token(FLOAT);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.FLOAT,
- pos,pos-5);}
+ {if (true) return new ConstantIdentifier(Types.FLOAT,pos,pos-5);}
break;
case INT:
jj_consume_token(INT);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.INT,
- pos,pos-3);}
+ {if (true) return new ConstantIdentifier(Types.INT,pos,pos-3);}
break;
case INTEGER:
jj_consume_token(INTEGER);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.INTEGER,
- pos,pos-7);}
+ {if (true) return new ConstantIdentifier(Types.INTEGER,pos,pos-7);}
break;
case OBJECT:
jj_consume_token(OBJECT);
pos = SimpleCharStream.getPosition();
- {if (true) return new ConstantIdentifier(Types.OBJECT,
- pos,pos-6);}
+ {if (true) return new ConstantIdentifier(Types.OBJECT,pos,pos-6);}
break;
default:
jj_la1[25] = jj_gen;
@@ -1356,25 +1268,25 @@ Expression expr,expr2;
*/
static final public VarAssignation varAssignation() throws ParseException {
String varName;
- final Expression expression;
+ final Expression initializer;
final int assignOperator;
final int pos = SimpleCharStream.getPosition();
varName = VariableDeclaratorId();
assignOperator = AssignmentOperator();
try {
- expression = Expression();
+ initializer = Expression();
} catch (ParseException e) {
if (errorMessage != null) {
{if (true) throw e;}
}
errorMessage = "expression expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
{if (true) return new VarAssignation(varName.toCharArray(),
- expression,
+ initializer,
assignOperator,
pos,
SimpleCharStream.getPosition());}
@@ -1674,8 +1586,8 @@ Expression expr,expr2;
}
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
expr = new BinaryExpression(expr,expr2,operator);
@@ -1816,8 +1728,8 @@ Expression expr,expr2;
if (errorMessage != null) {if (true) throw e;}
errorMessage = "unexpected token '"+e.currentToken.next.image+"'";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
label_18:
@@ -2052,8 +1964,8 @@ final int operator;
} catch (ParseException e) {
errorMessage = "')' expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
{if (true) return expr;}
@@ -2137,7 +2049,6 @@ final int pos = SimpleCharStream.getPosition();
static final public Expression PrimaryExpression() throws ParseException {
final Token identifier;
Expression expr;
- final StringBuffer buff = new StringBuffer();
final int pos = SimpleCharStream.getPosition();
if (jj_2_5(2)) {
identifier = jj_consume_token(IDENTIFIER);
@@ -2329,8 +2240,8 @@ final int pos = SimpleCharStream.getPosition();
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
{if (true) return new ClassAccess(prefix,
@@ -2420,8 +2331,8 @@ final int pos = SimpleCharStream.getPosition();
} catch (ParseException e) {
errorMessage = "']' expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
{if (true) return new ArrayDeclarator(prefix,expression,SimpleCharStream.getPosition());}
@@ -2512,8 +2423,8 @@ Expression[] args = null;
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
{if (true) return new FunctionCall(func,args,SimpleCharStream.getPosition());}
@@ -2547,8 +2458,8 @@ final ArrayList list = new ArrayList();
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
}
@@ -2569,11 +2480,11 @@ final ArrayList list = new ArrayList();
try {
jj_consume_token(SEMICOLON);
} catch (ParseException e) {
- if (e.currentToken.next.kind != 4) {
+ if (e.currentToken.next.kind != PHPParserConstants.PHPEND) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
}
@@ -2604,8 +2515,8 @@ final ArrayList list = new ArrayList();
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
errorLevel = ERROR;
- errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = jj_input_stream.getPosition() + 1;
+ errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+ errorEnd = SimpleCharStream.getPosition() + 1;
{if (true) throw e;}
}
{if (true) return statement;}
@@ -2775,16 +2686,17 @@ final ArrayList list = new ArrayList();
throw new ParseException();
}
} catch (ParseException e) {
- errorMessage = "End of file unexpected, '= 0) {
@@ -6915,7 +6837,7 @@ final int startBlock, endBlock;
}
}
}
- for (int i = 0; i < 141; i++) {
+ for (int i = 0; i < 142; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;