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 d97225b..2dc2240 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -29,6 +29,7 @@ import net.sourceforge.phpdt.internal.compiler.parser.PHPReqIncDeclaration; */ public final class PHPParser extends PHPParserSuperclass implements PHPParserConstants { + /** The file that is parsed. */ private static IFile fileToParse; /** The current segment */ @@ -37,9 +38,15 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$ private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ 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; + public PHPParser() { } @@ -107,12 +114,23 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon */ private static void setMarker(final ParseException e) { try { - setMarker(fileToParse, - errorMessage, - jj_input_stream.tokenBegin, - jj_input_stream.tokenBegin + e.currentToken.image.length(), - errorLevel, - "Line " + e.currentToken.beginLine); + if (errorStart == -1) { + setMarker(fileToParse, + errorMessage, + jj_input_stream.tokenBegin, + jj_input_stream.tokenBegin + e.currentToken.image.length(), + errorLevel, + "Line " + e.currentToken.beginLine); + } else { + setMarker(fileToParse, + errorMessage, + errorStart, + errorEnd, + errorLevel, + "Line " + e.currentToken.beginLine); + errorStart = -1; + errorEnd = -1; + } } catch (CoreException e2) { PHPeclipsePlugin.log(e2); } @@ -458,13 +476,26 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon static final public void ClassDeclaration() throws ParseException { final PHPClassDeclaration classDeclaration; final Token className; - final int pos = jj_input_stream.bufpos; + final int pos; jj_consume_token(CLASS); - className = jj_consume_token(IDENTIFIER); + try { + pos = jj_input_stream.bufpos; + className = jj_consume_token(IDENTIFIER); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; + errorLevel = ERROR; + {if (true) throw e;} + } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EXTENDS: jj_consume_token(EXTENDS); - jj_consume_token(IDENTIFIER); + try { + jj_consume_token(IDENTIFIER); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; + errorLevel = ERROR; + {if (true) throw e;} + } break; default: jj_la1[6] = jj_gen; @@ -3894,146 +3925,6 @@ final int pos = jj_input_stream.bufpos; return retval; } - static final private boolean jj_3R_196() { - if (jj_3R_41()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_197()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } - return false; - } - - static final private boolean jj_3R_99() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_41()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_71() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_109()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_70() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_41()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_62() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_70()) { - jj_scanpos = xsp; - if (jj_3R_71()) { - jj_scanpos = xsp; - if (jj_3R_72()) { - jj_scanpos = xsp; - if (jj_3R_73()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_114() { - if (jj_scan_token(BIT_AND)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_113()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_194() { - if (jj_3R_196()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_111() { - if (jj_3R_113()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_114()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } - return false; - } - - static final private boolean jj_3R_94() { - if (jj_scan_token(DOLLAR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_62()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_192() { - if (jj_scan_token(LPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_194()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_93() { - if (jj_scan_token(DOLLAR_ID)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_99()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_77() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_93()) { - jj_scanpos = xsp; - if (jj_3R_94()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_112() { - if (jj_scan_token(XOR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_111()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_175() { - if (jj_scan_token(NULL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_107() { if (jj_3R_111()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5407,6 +5298,146 @@ final int pos = jj_input_stream.bufpos; return false; } + static final private boolean jj_3R_196() { + if (jj_3R_41()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_197()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + + static final private boolean jj_3R_99() { + if (jj_scan_token(LBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_41()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_71() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_109()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_70() { + if (jj_scan_token(LBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_41()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_62() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_70()) { + jj_scanpos = xsp; + if (jj_3R_71()) { + jj_scanpos = xsp; + if (jj_3R_72()) { + jj_scanpos = xsp; + if (jj_3R_73()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_114() { + if (jj_scan_token(BIT_AND)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_113()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_194() { + if (jj_3R_196()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_111() { + if (jj_3R_113()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_114()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + + static final private boolean jj_3R_94() { + if (jj_scan_token(DOLLAR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_62()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_192() { + if (jj_scan_token(LPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_194()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_93() { + if (jj_scan_token(DOLLAR_ID)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_99()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_77() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_93()) { + jj_scanpos = xsp; + if (jj_3R_94()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_112() { + if (jj_scan_token(XOR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_111()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_175() { + if (jj_scan_token(NULL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static private boolean jj_initialized_once = false; static public PHPParserTokenManager token_source; static SimpleCharStream jj_input_stream;