From: kpouer Date: Wed, 26 Nov 2003 20:19:56 +0000 (+0000) Subject: the parser is no longer static X-Git-Url: http://git.phpeclipse.com the parser is no longer static --- diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 301d62c..15fd16e 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -78,24 +78,26 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon PHPParser.fileToParse = fileToParse; } - public static final void phpParserTester(final String strEval) throws ParseException { + 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); - PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING); + token_source.SwitchTo(PHPParserTokenManager.PHPPARSING); phpTest(); } - public static final void htmlParserTester(final File fileName) throws FileNotFoundException, ParseException { + 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(); @@ -105,10 +107,11 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon phpFile(); } - public static final void htmlParserTester(final String strEval) throws ParseException { + 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(); @@ -151,6 +154,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon 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(); @@ -270,6 +274,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon 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(); @@ -305,51 +310,51 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon /** * Put a new html block in the stack. */ - public static final void createNewHTMLCode() { + public final void createNewHTMLCode() { final int currentPosition = token.sourceStart; if (currentPosition == htmlStart || currentPosition < htmlStart || - currentPosition > SimpleCharStream.currentBuffer.length()) { + currentPosition > jj_input_stream.getCurrentBuffer().length()) { return; } - final String html = SimpleCharStream.currentBuffer.substring(htmlStart, currentPosition); + final String html = jj_input_stream.getCurrentBuffer().substring(htmlStart, currentPosition); pushOnAstNodes(new HTMLCode(html, htmlStart,currentPosition)); } /** Create a new task. */ - public static final void createNewTask(final int todoStart) { - final String todo = SimpleCharStream.currentBuffer.substring(todoStart, - SimpleCharStream.currentBuffer.indexOf("\n", + 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, - SimpleCharStream.getBeginLine(), + jj_input_stream.getBeginLine(), TASK, - "Line "+SimpleCharStream.getBeginLine()); + "Line "+jj_input_stream.getBeginLine()); } catch (CoreException e) { PHPeclipsePlugin.log(e); } } } - private static final void parse() throws ParseException { + private final void parse() throws ParseException { phpFile(); } - static final public void todo() throws ParseException { + final public void todo() throws ParseException { Token todoToken; todoToken = jj_consume_token(23); createNewTask(todoToken.sourceStart); } - static final public void phpTest() throws ParseException { + final public void phpTest() throws ParseException { Php(); jj_consume_token(0); } - static final public void phpFile() throws ParseException { + final public void phpFile() throws ParseException { try { label_1: while (true) { @@ -409,11 +414,11 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } PhpBlock(); } - PHPParser.createNewHTMLCode(); + createNewHTMLCode(); } catch (TokenMgrError e) { PHPeclipsePlugin.log(e); - errorStart = SimpleCharStream.beginOffset; - errorEnd = SimpleCharStream.endOffset; + errorStart = jj_input_stream.getBeginOffset(); + errorEnd = jj_input_stream.getEndOffset(); errorMessage = e.getMessage(); errorLevel = ERROR; {if (true) throw generateParseException();} @@ -425,7 +430,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon * or * or */ - static final public void PhpBlock() throws ParseException { + final public void PhpBlock() throws ParseException { final PHPEchoBlock phpEchoBlock; final Token token,phpEnd; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -509,7 +514,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_la1[2] = jj_gen; ; } - PHPParser.createNewHTMLCode(); + createNewHTMLCode(); Php(); try { phpEnd = jj_consume_token(PHPEND); @@ -529,12 +534,12 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } } - static final public PHPEchoBlock phpEchoBlock() throws ParseException { + final public PHPEchoBlock phpEchoBlock() throws ParseException { final Expression expr; final PHPEchoBlock echoBlock; final Token token, token2; token = jj_consume_token(PHPECHOSTART); - PHPParser.createNewHTMLCode(); + createNewHTMLCode(); expr = Expression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: @@ -553,7 +558,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon throw new Error("Missing return statement in function"); } - static final public void Php() throws ParseException { + final public void Php() throws ParseException { label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -610,7 +615,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } } - static final public ClassDeclaration ClassDeclaration() throws ParseException { + final public ClassDeclaration ClassDeclaration() throws ParseException { final ClassDeclaration classDeclaration; Token className = null; final Token superclassName, token, extendsToken; @@ -678,7 +683,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon throw new Error("Missing return statement in function"); } - static final public int ClassBody(final ClassDeclaration classDeclaration) throws ParseException { + final public int ClassBody(final ClassDeclaration classDeclaration) throws ParseException { Token token; try { jj_consume_token(LBRACE); @@ -711,7 +716,7 @@ Token token; errorStart = e.currentToken.sourceStart; errorEnd = e.currentToken.sourceEnd; processParseExceptionDebug(e); - {if (true) return PHPParser.token.sourceEnd;} + {if (true) return this.token.sourceEnd;} } throw new Error("Missing return statement in function"); } @@ -719,7 +724,7 @@ Token token; /** * A class can contain only methods and fields. */ - static final public void ClassBodyDeclaration(final ClassDeclaration classDeclaration) throws ParseException { + final public void ClassBodyDeclaration(final ClassDeclaration classDeclaration) throws ParseException { final MethodDeclaration method; final FieldDeclaration field; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -743,7 +748,7 @@ Token token; * A class field declaration : it's var VariableDeclarator() (, VariableDeclarator())*;. * it is only used by ClassBodyDeclaration() */ - static final public FieldDeclaration FieldDeclaration() throws ParseException { + final public FieldDeclaration FieldDeclaration() throws ParseException { VariableDeclaration variableDeclaration; final VariableDeclaration[] list; final ArrayList arrayList = new ArrayList(); @@ -798,7 +803,7 @@ Token token; * a strict variable declarator : there cannot be a suffix here. * It will be used by fields and formal parameters */ - static final public VariableDeclaration VariableDeclaratorNoSuffix() throws ParseException { + final public VariableDeclaration VariableDeclaratorNoSuffix() throws ParseException { final Token token, lbrace,rbrace; Expression expr, initializer = null; Token assignToken; @@ -854,7 +859,7 @@ Token token; /** * this will be used by static statement */ - static final public VariableDeclaration VariableDeclarator() throws ParseException { + final public VariableDeclaration VariableDeclarator() throws ParseException { final AbstractVariable variable; Expression initializer = null; final Token token; @@ -894,7 +899,7 @@ Token token; * A Variable name. * @return the variable name (with suffix) */ - static final public AbstractVariable VariableDeclaratorId() throws ParseException { + final public AbstractVariable VariableDeclaratorId() throws ParseException { final Variable var; AbstractVariable expression = null; try { @@ -922,7 +927,7 @@ Token token; throw new Error("Missing return statement in function"); } - static final public Variable Variable() throws ParseException { + final public Variable Variable() throws ParseException { Variable variable = null; final Token token; token = jj_consume_token(DOLLAR); @@ -931,7 +936,7 @@ Token token; throw new Error("Missing return statement in function"); } - static final public Variable Var() throws ParseException { + final public Variable Var() throws ParseException { Variable variable = null; final Token token,token2; ConstantIdentifier constant; @@ -963,7 +968,7 @@ Token token; throw new Error("Missing return statement in function"); } - static final public Expression VariableInitializer() throws ParseException { + final public Expression VariableInitializer() throws ParseException { final Expression expr; final Token token, token2; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1029,7 +1034,7 @@ Token token; throw new Error("Missing return statement in function"); } - static final public ArrayVariableDeclaration ArrayVariable() throws ParseException { + final public ArrayVariableDeclaration ArrayVariable() throws ParseException { final Expression expr,expr2; expr = Expression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1042,11 +1047,11 @@ final Expression expr,expr2; jj_la1[17] = jj_gen; ; } - {if (true) return new ArrayVariableDeclaration(expr,SimpleCharStream.getPosition());} + {if (true) return new ArrayVariableDeclaration(expr,jj_input_stream.getPosition());} throw new Error("Missing return statement in function"); } - static final public ArrayVariableDeclaration[] ArrayInitializer() throws ParseException { + final public ArrayVariableDeclaration[] ArrayInitializer() throws ParseException { ArrayVariableDeclaration expr; final ArrayList list = new ArrayList(); jj_consume_token(LPAREN); @@ -1111,7 +1116,7 @@ final Expression expr,expr2; * A Method Declaration. * function MetodDeclarator() Block() */ - static final public MethodDeclaration MethodDeclaration() throws ParseException { + final public MethodDeclaration MethodDeclaration() throws ParseException { final MethodDeclaration functionDeclaration; final Block block; final OutlineableWithChildren seg = currentSegment; @@ -1141,7 +1146,7 @@ final Expression expr,expr2; * [&] IDENTIFIER(parameters ...). * @return a function description for the outline */ - static final public MethodDeclaration MethodDeclarator(final int start) throws ParseException { + final public MethodDeclaration MethodDeclarator(final int start) throws ParseException { Token identifier = null; Token reference = null; final ArrayList formalParameters = new ArrayList(); @@ -1196,10 +1201,10 @@ final Expression expr,expr2; * FormalParameters follows method identifier. * (FormalParameter()) */ - static final public int FormalParameters(final ArrayList parameters) throws ParseException { + final public int FormalParameters(final ArrayList parameters) throws ParseException { VariableDeclaration var; final Token token; - Token tok = PHPParser.token; + Token tok = this.token; int end = tok.sourceEnd; try { tok = jj_consume_token(LPAREN); @@ -1253,7 +1258,7 @@ final Expression expr,expr2; * A formal parameter. * $varname[=value] (,$varname[=value]) */ - static final public VariableDeclaration FormalParameter() throws ParseException { + final public VariableDeclaration FormalParameter() throws ParseException { final VariableDeclaration variableDeclaration; Token token = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1273,7 +1278,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public ConstantIdentifier Type() throws ParseException { + final public ConstantIdentifier Type() throws ParseException { final Token token; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: @@ -1320,7 +1325,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression Expression() throws ParseException { + final public Expression Expression() throws ParseException { final Expression expr; Expression initializer = null; int assignOperator = -1; @@ -1369,7 +1374,7 @@ final Expression expr,expr2; } errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; errorLevel = ERROR; - errorEnd = SimpleCharStream.getPosition(); + errorEnd = jj_input_stream.getPosition(); {if (true) throw e;} } break; @@ -1408,7 +1413,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ExpressionWBang() throws ParseException { + final public Expression ExpressionWBang() throws ParseException { final Expression expr; final Token token; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1430,7 +1435,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ExpressionNoBang() throws ParseException { + final public Expression ExpressionNoBang() throws ParseException { Expression expr; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LIST: @@ -1453,7 +1458,7 @@ final Expression expr,expr2; * Any assignement operator. * @return the assignement operator id */ - static final public int AssignmentOperator() throws ParseException { + final public int AssignmentOperator() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: jj_consume_token(ASSIGN); @@ -1515,7 +1520,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ConditionalExpression() throws ParseException { + final public Expression ConditionalExpression() throws ParseException { final Expression expr; Expression expr2 = null; Expression expr3 = null; @@ -1538,7 +1543,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ConditionalOrExpression() throws ParseException { + final public Expression ConditionalOrExpression() throws ParseException { Expression expr,expr2; int operator; expr = ConditionalAndExpression(); @@ -1574,7 +1579,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ConditionalAndExpression() throws ParseException { + final public Expression ConditionalAndExpression() throws ParseException { Expression expr,expr2; int operator; expr = ConcatExpression(); @@ -1610,7 +1615,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ConcatExpression() throws ParseException { + final public Expression ConcatExpression() throws ParseException { Expression expr,expr2; expr = InclusiveOrExpression(); label_10: @@ -1631,7 +1636,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression InclusiveOrExpression() throws ParseException { + final public Expression InclusiveOrExpression() throws ParseException { Expression expr,expr2; expr = ExclusiveOrExpression(); label_11: @@ -1652,7 +1657,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ExclusiveOrExpression() throws ParseException { + final public Expression ExclusiveOrExpression() throws ParseException { Expression expr,expr2; expr = AndExpression(); label_12: @@ -1673,7 +1678,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression AndExpression() throws ParseException { + final public Expression AndExpression() throws ParseException { Expression expr,expr2; expr = EqualityExpression(); label_13: @@ -1694,7 +1699,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression EqualityExpression() throws ParseException { + final public Expression EqualityExpression() throws ParseException { Expression expr,expr2; int operator; Token token; @@ -1758,7 +1763,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression RelationalExpression() throws ParseException { + final public Expression RelationalExpression() throws ParseException { Expression expr,expr2; int operator; expr = ShiftExpression(); @@ -1804,7 +1809,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression ShiftExpression() throws ParseException { + final public Expression ShiftExpression() throws ParseException { Expression expr,expr2; int operator; expr = AdditiveExpression(); @@ -1845,7 +1850,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression AdditiveExpression() throws ParseException { + final public Expression AdditiveExpression() throws ParseException { Expression expr,expr2; int operator; expr = MultiplicativeExpression(); @@ -1881,7 +1886,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression MultiplicativeExpression() throws ParseException { + final public Expression MultiplicativeExpression() throws ParseException { Expression expr,expr2; int operator; try { @@ -1890,8 +1895,8 @@ final Expression expr,expr2; if (errorMessage != null) {if (true) throw e;} errorMessage = "unexpected token '"+e.currentToken.next.image+'\''; errorLevel = ERROR; - errorStart = PHPParser.token.sourceStart; - errorEnd = PHPParser.token.sourceEnd; + errorStart = this.token.sourceStart; + errorEnd = this.token.sourceEnd; {if (true) throw e;} } label_18: @@ -1934,7 +1939,7 @@ final Expression expr,expr2; /** * An unary expression starting with @, & or nothing */ - static final public Expression UnaryExpression() throws ParseException { + final public Expression UnaryExpression() throws ParseException { final Expression expr; /* expr = UnaryExpressionNoPrefix() //why did I had that ? {return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);} @@ -1944,7 +1949,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression AtNotTildeUnaryExpression() throws ParseException { + final public Expression AtNotTildeUnaryExpression() throws ParseException { final Expression expr; final Token token; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1995,7 +2000,7 @@ final Expression expr,expr2; * An expression prefixed (or not) by one or more @ and !. * @return the expression */ - static final public Expression AtNotUnaryExpression() throws ParseException { + final public Expression AtNotUnaryExpression() throws ParseException { final Expression expr; final Token token; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -2037,7 +2042,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression UnaryExpressionNoPrefix() throws ParseException { + final public Expression UnaryExpressionNoPrefix() throws ParseException { final Expression expr; final Token token; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -2084,7 +2089,7 @@ final Expression expr,expr2; throw new Error("Missing return statement in function"); } - static final public Expression PreIncDecExpression() throws ParseException { + final public Expression PreIncDecExpression() throws ParseException { final Expression expr; final int operator; final Token token; @@ -2107,7 +2112,7 @@ final Token token; throw new Error("Missing return statement in function"); } - static final public Expression UnaryExpressionNotPlusMinus() throws ParseException { + final public Expression UnaryExpressionNotPlusMinus() throws ParseException { final Expression expr; if (jj_2_3(2147483647)) { expr = CastExpression(); @@ -2155,7 +2160,7 @@ final Token token; throw new Error("Missing return statement in function"); } - static final public CastExpression CastExpression() throws ParseException { + final public CastExpression CastExpression() throws ParseException { final ConstantIdentifier type; final Expression expr; final Token token,token1; @@ -2187,7 +2192,7 @@ final Token token,token1; throw new Error("Missing return statement in function"); } - static final public Expression PostfixExpression() throws ParseException { + final public Expression PostfixExpression() throws ParseException { final Expression expr; int operator = -1; Token token = null; @@ -2221,7 +2226,7 @@ final Token token,token1; throw new Error("Missing return statement in function"); } - static final public Expression PrimaryExpression() throws ParseException { + final public Expression PrimaryExpression() throws ParseException { Expression expr; Token token = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -2252,7 +2257,7 @@ final Token token,token1; throw new Error("Missing return statement in function"); } - static final public Expression refPrimaryExpression(final Token reference) throws ParseException { + final public Expression refPrimaryExpression(final Token reference) throws ParseException { Expression expr; Expression expr2 = null; final Token identifier; @@ -2344,18 +2349,18 @@ final Token token,token1; * array(vars) * @return an array */ - static final public ArrayInitializer ArrayDeclarator() throws ParseException { + 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, - PHPParser.token.sourceEnd);} + this.token.sourceEnd);} throw new Error("Missing return statement in function"); } - static final public Expression ClassIdentifier() throws ParseException { + final public Expression ClassIdentifier() throws ParseException { final Expression expr; final Token token; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -2390,7 +2395,7 @@ final Token token,token1; /** * Used by Variabledeclaratorid and primarysuffix */ - static final public AbstractVariable VariableSuffix(final AbstractVariable prefix) throws ParseException { + final public AbstractVariable VariableSuffix(final AbstractVariable prefix) throws ParseException { Expression expression = null; final Token classAccessToken,lbrace,rbrace; Token token; @@ -2629,7 +2634,7 @@ final Token token,token1; throw new Error("Missing return statement in function"); } - static final public Literal Literal() throws ParseException { + final public Literal Literal() throws ParseException { final Token token; StringLiteral literal; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -2669,7 +2674,7 @@ final Token token,token1; throw new Error("Missing return statement in function"); } - static final public StringLiteral evaluableString() throws ParseException { + final public StringLiteral evaluableString() throws ParseException { ArrayList list = new ArrayList(); Token start,end; Token token,lbrace,rbrace; @@ -2711,14 +2716,14 @@ final Token token,token1; end = jj_consume_token(DOUBLEQUOTE2); AbstractVariable[] vars = new AbstractVariable[list.size()]; list.toArray(vars); - {if (true) return new StringLiteral(SimpleCharStream.currentBuffer.substring(start.sourceEnd,end.sourceStart), + {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"); } - static final public FunctionCall Arguments(final Expression func) throws ParseException { + final public FunctionCall Arguments(final Expression func) throws ParseException { Expression[] args = null; final Token token,lparen; lparen = jj_consume_token(LPAREN); @@ -2776,7 +2781,7 @@ final Token token,lparen; * argumentDeclaration() (, argumentDeclaration)* * @return an array of arguments */ - static final public Expression[] ArgumentList() throws ParseException { + final public Expression[] ArgumentList() throws ParseException { Expression arg; final ArrayList list = new ArrayList(); int pos; @@ -2817,7 +2822,7 @@ Token token; * A Statement without break. * @return a statement */ - static final public Statement StatementNoBreak() throws ParseException { + final public Statement StatementNoBreak() throws ParseException { final Statement statement; Token token = null; if (jj_2_4(2)) { @@ -2919,7 +2924,7 @@ Token token; * expression ; * @return an expression */ - static final public Statement expressionStatement() throws ParseException { + final public Statement expressionStatement() throws ParseException { final Statement statement; final Token token; statement = Expression(); @@ -2939,7 +2944,7 @@ Token token; throw new Error("Missing return statement in function"); } - static final public Define defineStatement() throws ParseException { + final public Define defineStatement() throws ParseException { Expression defineName,defineValue; final Token defineToken; Token token; @@ -3009,7 +3014,7 @@ Token token; /** * A Normal statement. */ - static final public Statement Statement() throws ParseException { + final public Statement Statement() throws ParseException { final Statement statement; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IF: @@ -3070,7 +3075,7 @@ Token token; /** * An html block inside a php syntax. */ - static final public HTMLBlock htmlBlock() throws ParseException { + final public HTMLBlock htmlBlock() throws ParseException { final int startIndex = nodePtr; final AstNode[] blockNodes; final int nbNodes; @@ -3102,7 +3107,7 @@ Token token; jj_consume_token(-1); throw new ParseException(); } - PHPParser.createNewHTMLCode(); + createNewHTMLCode(); } catch (ParseException e) { errorMessage = "unexpected end of file , '= 100) return; if (pos == jj_endpos + 1) { jj_lasttokens[jj_endpos++] = kind; @@ -7483,7 +7466,7 @@ final ArrayList list = new ArrayList(); } } - static public ParseException generateParseException() { + public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[160]; for (int i = 0; i < 160; i++) { @@ -7531,13 +7514,13 @@ final ArrayList list = new ArrayList(); return new ParseException(token, exptokseq, tokenImage); } - static final public void enable_tracing() { + final public void enable_tracing() { } - static final public void disable_tracing() { + final public void disable_tracing() { } - static final private void jj_rescan_token() { + final private void jj_rescan_token() { jj_rescan = true; for (int i = 0; i < 5; i++) { JJCalls p = jj_2_rtns[i]; @@ -7558,7 +7541,7 @@ final ArrayList list = new ArrayList(); jj_rescan = false; } - static final private void jj_save(int index, int xla) { + 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; } diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index 9d2846a..c1d2e52 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -3,7 +3,7 @@ options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; - STATIC = true; + STATIC = false; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; DEBUG_TOKEN_MANAGER = false; @@ -101,24 +101,26 @@ public final class PHPParser extends PHPParserSuperclass { PHPParser.fileToParse = fileToParse; } - public static final void phpParserTester(final String strEval) throws ParseException { + 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); - PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING); + token_source.SwitchTo(PHPParserTokenManager.PHPPARSING); phpTest(); } - public static final void htmlParserTester(final File fileName) throws FileNotFoundException, ParseException { + 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(); @@ -128,10 +130,11 @@ public final class PHPParser extends PHPParserSuperclass { phpFile(); } - public static final void htmlParserTester(final String strEval) throws ParseException { + 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(); @@ -174,6 +177,7 @@ public final class PHPParser extends PHPParserSuperclass { 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(); @@ -293,6 +297,7 @@ public final class PHPParser extends PHPParserSuperclass { 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(); @@ -328,36 +333,36 @@ public final class PHPParser extends PHPParserSuperclass { /** * Put a new html block in the stack. */ - public static final void createNewHTMLCode() { + public final void createNewHTMLCode() { final int currentPosition = token.sourceStart; if (currentPosition == htmlStart || currentPosition < htmlStart || - currentPosition > SimpleCharStream.currentBuffer.length()) { + currentPosition > jj_input_stream.getCurrentBuffer().length()) { return; } - final String html = SimpleCharStream.currentBuffer.substring(htmlStart, currentPosition); + final String html = jj_input_stream.getCurrentBuffer().substring(htmlStart, currentPosition); pushOnAstNodes(new HTMLCode(html, htmlStart,currentPosition)); } /** Create a new task. */ - public static final void createNewTask(final int todoStart) { - final String todo = SimpleCharStream.currentBuffer.substring(todoStart, - SimpleCharStream.currentBuffer.indexOf("\n", + 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, - SimpleCharStream.getBeginLine(), + jj_input_stream.getBeginLine(), TASK, - "Line "+SimpleCharStream.getBeginLine()); + "Line "+jj_input_stream.getBeginLine()); } catch (CoreException e) { PHPeclipsePlugin.log(e); } } } - private static final void parse() throws ParseException { + private final void parse() throws ParseException { phpFile(); } } @@ -370,9 +375,9 @@ TOKEN_MGR_DECLS: // 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 - static void CommonTokenAction(Token t) { - t.sourceStart = input_stream.beginOffset; - t.sourceEnd = input_stream.endOffset; + void CommonTokenAction(Token t) { + t.sourceStart = input_stream.getBeginOffset(); + t.sourceEnd = input_stream.getBeginOffset(); } // CommonTokenAction } // TOKEN_MGR_DECLS @@ -741,11 +746,11 @@ void phpFile() : { try { (PhpBlock())* - {PHPParser.createNewHTMLCode();} + {createNewHTMLCode();} } catch (TokenMgrError e) { PHPeclipsePlugin.log(e); - errorStart = SimpleCharStream.beginOffset; - errorEnd = SimpleCharStream.endOffset; + errorStart = jj_input_stream.getBeginOffset(); + errorEnd = jj_input_stream.getEndOffset(); errorMessage = e.getMessage(); errorLevel = ERROR; throw generateParseException(); @@ -779,7 +784,7 @@ void PhpBlock() : PHPeclipsePlugin.log(e); }} ] - {PHPParser.createNewHTMLCode();} + {createNewHTMLCode();} Php() try { phpEnd = @@ -800,7 +805,7 @@ PHPEchoBlock phpEchoBlock() : final Token token, token2; } { - token = {PHPParser.createNewHTMLCode();} + token = {createNewHTMLCode();} expr = Expression() [ ] token2 = { htmlStart = token2.sourceEnd; @@ -907,7 +912,7 @@ Token token; errorStart = e.currentToken.sourceStart; errorEnd = e.currentToken.sourceEnd; processParseExceptionDebug(e); - return PHPParser.token.sourceEnd; + return this.token.sourceEnd; } } @@ -1165,7 +1170,7 @@ final Expression expr,expr2; expr2 = Expression() {return new ArrayVariableDeclaration(expr,expr2);} ] - {return new ArrayVariableDeclaration(expr,SimpleCharStream.getPosition());} + {return new ArrayVariableDeclaration(expr,jj_input_stream.getPosition());} } ArrayVariableDeclaration[] ArrayInitializer() : @@ -1285,7 +1290,7 @@ int FormalParameters(final ArrayList parameters) : { VariableDeclaration var; final Token token; - Token tok = PHPParser.token; + Token tok = this.token; int end = tok.sourceEnd; } { @@ -1372,7 +1377,7 @@ Expression Expression() : } errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; errorLevel = ERROR; - errorEnd = SimpleCharStream.getPosition(); + errorEnd = jj_input_stream.getPosition(); throw e; } ] @@ -1644,8 +1649,8 @@ Expression MultiplicativeExpression() : if (errorMessage != null) throw e; errorMessage = "unexpected token '"+e.currentToken.next.image+'\''; errorLevel = ERROR; - errorStart = PHPParser.token.sourceStart; - errorEnd = PHPParser.token.sourceEnd; + errorStart = this.token.sourceStart; + errorEnd = this.token.sourceEnd; throw e; } ( @@ -1895,7 +1900,7 @@ ArrayInitializer ArrayDeclarator() : token = vars = ArrayInitializer() {return new ArrayInitializer(vars, token.sourceStart, - PHPParser.token.sourceEnd);} + this.token.sourceEnd);} } Expression ClassIdentifier(): @@ -2021,7 +2026,7 @@ StringLiteral evaluableString() : { AbstractVariable[] vars = new AbstractVariable[list.size()]; list.toArray(vars); - return new StringLiteral(SimpleCharStream.currentBuffer.substring(start.sourceEnd,end.sourceStart), + return new StringLiteral(jj_input_stream.getCurrentBuffer().substring(start.sourceEnd,end.sourceStart), start.sourceStart, end.sourceEnd, vars); @@ -2248,7 +2253,7 @@ HTMLBlock htmlBlock() : (phpEchoBlock())* try { ( | ) - {PHPParser.createNewHTMLCode();} + {createNewHTMLCode();} } catch (ParseException e) { errorMessage = "unexpected end of file , ' try { - {pos = SimpleCharStream.getPosition();} + {pos = jj_input_stream.getPosition();} statement = Statement() - {elseStatement = new Else(statement,pos,SimpleCharStream.getPosition());} + {elseStatement = new Else(statement,pos,jj_input_stream.getPosition());} } catch (ParseException e) { if (errorMessage != null) { throw e; @@ -3034,7 +3039,7 @@ IfStatement IfStatement0(final Expression condition, final int start,final int e elseIfs, elseStatement, pos, - SimpleCharStream.getPosition());} + jj_input_stream.getPosition());} } ElseIf ElseIfStatementColon() : @@ -3103,7 +3108,7 @@ Statement WhileStatement0(final int start, final int end) : { Statement statement; final ArrayList stmts = new ArrayList(); - final int pos = SimpleCharStream.getPosition(); + final int pos = jj_input_stream.getPosition(); } { (statement = Statement() {stmts.add(statement);})* @@ -3131,7 +3136,7 @@ Statement WhileStatement0(final int start, final int end) : { final Statement[] stmtsArray = new Statement[stmts.size()]; stmts.toArray(stmtsArray); - return new Block(stmtsArray,pos,SimpleCharStream.getPosition());} + return new Block(stmtsArray,pos,jj_input_stream.getPosition());} } catch (ParseException e) { errorMessage = "';' expected after 'endwhile' keyword"; errorLevel = ERROR; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserManager.java b/net.sourceforge.phpeclipse/src/test/PHPParserManager.java index a0c1802..4f42264 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserManager.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserManager.java @@ -6,7 +6,6 @@ import org.eclipse.core.resources.IFile; public class PHPParserManager { - private static PHPParserSuperclass parser; public static PHPParserSuperclass getParser(IFile fileToParse) { try { @@ -14,10 +13,7 @@ public class PHPParserManager { if (PHPeclipsePlugin.PHPPARSER == PHPeclipsePlugin.PHPPARSER_ORIGINAL) { actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); } else { - if (parser == null) { - parser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); - } - actualParser = parser; + actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); } actualParser.setFileToParse(fileToParse); return actualParser; @@ -37,10 +33,7 @@ public class PHPParserManager { if (PHPeclipsePlugin.PHPPARSER == PHPeclipsePlugin.PHPPARSER_ORIGINAL) { actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); } else { - if (parser == null) { - parser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); - } - actualParser = parser; + actualParser = (PHPParserSuperclass) Class.forName(PHPeclipsePlugin.PHPPARSER).newInstance(); } return actualParser; } catch (InstantiationException e) { diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java b/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java index 9a4efb3..d651379 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java @@ -24,19 +24,19 @@ public class PHPParserTokenManager implements PHPParserConstants // 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 - static void CommonTokenAction(Token t) { - t.sourceStart = input_stream.beginOffset; - t.sourceEnd = input_stream.endOffset; + void CommonTokenAction(Token t) { + t.sourceStart = input_stream.getBeginOffset(); + t.sourceEnd = input_stream.getBeginOffset(); } - public static java.io.PrintStream debugStream = System.out; - public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -static private final int jjStopAtPos(int pos, int kind) + 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; } -static private final int jjMoveStringLiteralDfa0_5() +private final int jjMoveStringLiteralDfa0_5() { switch(curChar) { @@ -49,7 +49,7 @@ static private final int jjMoveStringLiteralDfa0_5() return 1; } } -static private final int jjMoveStringLiteralDfa1_5(long active0) +private final int jjMoveStringLiteralDfa1_5(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -69,7 +69,7 @@ static private final int jjMoveStringLiteralDfa1_5(long active0) } return 2; } -static private final int jjMoveStringLiteralDfa2_5(long old0, long active0) +private final int jjMoveStringLiteralDfa2_5(long old0, long active0) { if (((active0 &= old0)) == 0L) return 2; @@ -86,7 +86,7 @@ static private final int jjMoveStringLiteralDfa2_5(long old0, long active0) return 3; } } -static private final int jjMoveStringLiteralDfa3_5(long old0, long active0) +private final int jjMoveStringLiteralDfa3_5(long old0, long active0) { if (((active0 &= old0)) == 0L) return 3; @@ -106,7 +106,7 @@ static private final int jjMoveStringLiteralDfa3_5(long old0, long active0) } return 4; } -static private final int jjMoveStringLiteralDfa0_8() +private final int jjMoveStringLiteralDfa0_8() { switch(curChar) { @@ -116,7 +116,7 @@ static private final int jjMoveStringLiteralDfa0_8() return 1; } } -private static final int jjStopStringLiteralDfa_9(int pos, long active0, long active1) +private final int jjStopStringLiteralDfa_9(int pos, long active0, long active1) { switch (pos) { @@ -124,11 +124,11 @@ private static final int jjStopStringLiteralDfa_9(int pos, long active0, long ac return -1; } } -private static final int jjStartNfa_9(int pos, long active0, long active1) +private final int jjStartNfa_9(int pos, long active0, long active1) { return jjMoveNfa_9(jjStopStringLiteralDfa_9(pos, active0, active1), pos + 1); } -static private final int jjStartNfaWithStates_9(int pos, int kind, int state) +private final int jjStartNfaWithStates_9(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; @@ -136,7 +136,7 @@ static private final int jjStartNfaWithStates_9(int pos, int kind, int state) catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_9(state, pos + 1); } -static private final int jjMoveStringLiteralDfa0_9() +private final int jjMoveStringLiteralDfa0_9() { switch(curChar) { @@ -146,7 +146,7 @@ static private final int jjMoveStringLiteralDfa0_9() return jjMoveNfa_9(0, 0); } } -static private final void jjCheckNAdd(int state) +private final void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) { @@ -154,24 +154,24 @@ static private final void jjCheckNAdd(int state) jjrounds[state] = jjround; } } -static private final void jjAddStates(int start, int end) +private final void jjAddStates(int start, int end) { do { jjstateSet[jjnewStateCnt++] = jjnextStates[start]; } while (start++ != end); } -static private final void jjCheckNAddTwoStates(int state1, int state2) +private final void jjCheckNAddTwoStates(int state1, int state2) { jjCheckNAdd(state1); jjCheckNAdd(state2); } -static private final void jjCheckNAddStates(int start, int end) +private final void jjCheckNAddStates(int start, int end) { do { jjCheckNAdd(jjnextStates[start]); } while (start++ != end); } -static private final void jjCheckNAddStates(int start) +private final void jjCheckNAddStates(int start) { jjCheckNAdd(jjnextStates[start]); jjCheckNAdd(jjnextStates[start + 1]); @@ -179,7 +179,7 @@ static private final void jjCheckNAddStates(int start) static final long[] jjbitVec0 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; -static private final int jjMoveNfa_9(int startState, int curPos) +private final int jjMoveNfa_9(int startState, int curPos) { int[] nextStates; int startsAt = 0; @@ -255,7 +255,7 @@ static private final int jjMoveNfa_9(int startState, int curPos) catch(java.io.IOException e) { return curPos; } } } -static private final int jjMoveStringLiteralDfa0_0() +private final int jjMoveStringLiteralDfa0_0() { switch(curChar) { @@ -268,7 +268,7 @@ static private final int jjMoveStringLiteralDfa0_0() return 1; } } -static private final int jjMoveStringLiteralDfa1_0(long active0) +private final int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -290,7 +290,7 @@ static private final int jjMoveStringLiteralDfa1_0(long active0) return 2; } } -static private final int jjMoveStringLiteralDfa2_0(long old0, long active0) +private final int jjMoveStringLiteralDfa2_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return 2; @@ -315,7 +315,7 @@ static private final int jjMoveStringLiteralDfa2_0(long old0, long active0) } return 3; } -static private final int jjMoveStringLiteralDfa3_0(long old0, long active0) +private final int jjMoveStringLiteralDfa3_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return 3; @@ -338,7 +338,7 @@ static private final int jjMoveStringLiteralDfa3_0(long old0, long active0) } return 4; } -static private final int jjMoveStringLiteralDfa4_0(long old0, long active0) +private final int jjMoveStringLiteralDfa4_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return 4; @@ -358,7 +358,7 @@ static private final int jjMoveStringLiteralDfa4_0(long old0, long active0) } return 5; } -static private final int jjMoveStringLiteralDfa0_4() +private final int jjMoveStringLiteralDfa0_4() { switch(curChar) { @@ -371,7 +371,7 @@ static private final int jjMoveStringLiteralDfa0_4() return 1; } } -static private final int jjMoveStringLiteralDfa1_4(long active0) +private final int jjMoveStringLiteralDfa1_4(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -391,7 +391,7 @@ static private final int jjMoveStringLiteralDfa1_4(long active0) } return 2; } -static private final int jjMoveStringLiteralDfa2_4(long old0, long active0) +private final int jjMoveStringLiteralDfa2_4(long old0, long active0) { if (((active0 &= old0)) == 0L) return 2; @@ -408,7 +408,7 @@ static private final int jjMoveStringLiteralDfa2_4(long old0, long active0) return 3; } } -static private final int jjMoveStringLiteralDfa3_4(long old0, long active0) +private final int jjMoveStringLiteralDfa3_4(long old0, long active0) { if (((active0 &= old0)) == 0L) return 3; @@ -428,7 +428,7 @@ static private final int jjMoveStringLiteralDfa3_4(long old0, long active0) } return 4; } -private static final int jjStopStringLiteralDfa_3(int pos, long active0, long active1, long active2) +private final int jjStopStringLiteralDfa_3(int pos, long active0, long active1, long active2) { switch (pos) { @@ -456,11 +456,11 @@ private static final int jjStopStringLiteralDfa_3(int pos, long active0, long ac return -1; } } -private static final int jjStartNfa_3(int pos, long active0, long active1, long active2) +private final int jjStartNfa_3(int pos, long active0, long active1, long active2) { return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0, active1, active2), pos + 1); } -static private final int jjStartNfaWithStates_3(int pos, int kind, int state) +private final int jjStartNfaWithStates_3(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; @@ -468,7 +468,7 @@ static private final int jjStartNfaWithStates_3(int pos, int kind, int state) catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_3(state, pos + 1); } -static private final int jjMoveStringLiteralDfa0_3() +private final int jjMoveStringLiteralDfa0_3() { switch(curChar) { @@ -560,7 +560,7 @@ static private final int jjMoveStringLiteralDfa0_3() return jjMoveNfa_3(0, 0); } } -static private final int jjMoveStringLiteralDfa1_3(long active0, long active1, long active2) +private final int jjMoveStringLiteralDfa1_3(long active0, long active1, long active2) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -660,7 +660,7 @@ static private final int jjMoveStringLiteralDfa1_3(long active0, long active1, l } return jjStartNfa_3(0, active0, active1, active2); } -static private final int jjMoveStringLiteralDfa2_3(long old0, long active0, long old1, long active1, long old2, long 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); @@ -695,7 +695,7 @@ static private final int jjMoveStringLiteralDfa2_3(long old0, long active0, long } return jjStartNfa_3(1, 0L, active1, active2); } -static private final int jjMoveNfa_3(int startState, int curPos) +private final int jjMoveNfa_3(int startState, int curPos) { int[] nextStates; int startsAt = 0; @@ -776,7 +776,7 @@ static private final int jjMoveNfa_3(int startState, int curPos) catch(java.io.IOException e) { return curPos; } } } -private static final int jjStopStringLiteralDfa_6(int pos, long active0, long active1) +private final int jjStopStringLiteralDfa_6(int pos, long active0, long active1) { switch (pos) { @@ -784,11 +784,11 @@ private static final int jjStopStringLiteralDfa_6(int pos, long active0, long ac return -1; } } -private static final int jjStartNfa_6(int pos, long active0, long active1) +private final int jjStartNfa_6(int pos, long active0, long active1) { return jjMoveNfa_6(jjStopStringLiteralDfa_6(pos, active0, active1), pos + 1); } -static private final int jjStartNfaWithStates_6(int pos, int kind, int state) +private final int jjStartNfaWithStates_6(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; @@ -796,7 +796,7 @@ static private final int jjStartNfaWithStates_6(int pos, int kind, int state) catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_6(state, pos + 1); } -static private final int jjMoveStringLiteralDfa0_6() +private final int jjMoveStringLiteralDfa0_6() { switch(curChar) { @@ -810,7 +810,7 @@ static private final int jjMoveStringLiteralDfa0_6() return jjMoveNfa_6(0, 0); } } -static private final int jjMoveNfa_6(int startState, int curPos) +private final int jjMoveNfa_6(int startState, int curPos) { int[] nextStates; int startsAt = 0; @@ -884,7 +884,7 @@ static private final int jjMoveNfa_6(int startState, int curPos) catch(java.io.IOException e) { return curPos; } } } -private static final int jjStopStringLiteralDfa_2(int pos, long active0) +private final int jjStopStringLiteralDfa_2(int pos, long active0) { switch (pos) { @@ -892,11 +892,11 @@ private static final int jjStopStringLiteralDfa_2(int pos, long active0) return -1; } } -private static final int jjStartNfa_2(int pos, long active0) +private final int jjStartNfa_2(int pos, long active0) { return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); } -static private final int jjStartNfaWithStates_2(int pos, int kind, int state) +private final int jjStartNfaWithStates_2(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; @@ -904,7 +904,7 @@ static private final int jjStartNfaWithStates_2(int pos, int kind, int state) catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_2(state, pos + 1); } -static private final int jjMoveStringLiteralDfa0_2() +private final int jjMoveStringLiteralDfa0_2() { switch(curChar) { @@ -917,7 +917,7 @@ static private final int jjMoveStringLiteralDfa0_2() return jjMoveNfa_2(0, 0); } } -static private final int jjMoveStringLiteralDfa1_2(long active0) +private final int jjMoveStringLiteralDfa1_2(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -938,7 +938,7 @@ static private final int jjMoveStringLiteralDfa1_2(long active0) } return jjStartNfa_2(0, active0); } -static private final int jjMoveStringLiteralDfa2_2(long old0, long active0) +private final int jjMoveStringLiteralDfa2_2(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_2(0, old0); @@ -957,7 +957,7 @@ static private final int jjMoveStringLiteralDfa2_2(long old0, long active0) } return jjStartNfa_2(1, active0); } -static private final int jjMoveStringLiteralDfa3_2(long old0, long active0) +private final int jjMoveStringLiteralDfa3_2(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_2(1, old0); @@ -978,7 +978,7 @@ static private final int jjMoveStringLiteralDfa3_2(long old0, long active0) } return jjStartNfa_2(2, active0); } -static private final int jjMoveNfa_2(int startState, int curPos) +private final int jjMoveNfa_2(int startState, int curPos) { int[] nextStates; int startsAt = 0; @@ -1054,7 +1054,7 @@ static private final int jjMoveNfa_2(int startState, int curPos) catch(java.io.IOException e) { return curPos; } } } -private static final int jjStopStringLiteralDfa_1(int pos, long active0, long active1, long active2) +private final int jjStopStringLiteralDfa_1(int pos, long active0, long active1, long active2) { switch (pos) { @@ -1183,11 +1183,11 @@ private static final int jjStopStringLiteralDfa_1(int pos, long active0, long ac return -1; } } -private static final int jjStartNfa_1(int pos, long active0, long active1, long active2) +private final int jjStartNfa_1(int pos, long active0, long active1, long active2) { return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0, active1, active2), pos + 1); } -static private final int jjStartNfaWithStates_1(int pos, int kind, int state) +private final int jjStartNfaWithStates_1(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; @@ -1195,7 +1195,7 @@ static private final int jjStartNfaWithStates_1(int pos, int kind, int state) catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_1(state, pos + 1); } -static private final int jjMoveStringLiteralDfa0_1() +private final int jjMoveStringLiteralDfa0_1() { switch(curChar) { @@ -1326,7 +1326,7 @@ static private final int jjMoveStringLiteralDfa0_1() return jjMoveNfa_1(3, 0); } } -static private final int jjMoveStringLiteralDfa1_1(long active0, long active1, long active2) +private final int jjMoveStringLiteralDfa1_1(long active0, long active1, long active2) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -1485,7 +1485,7 @@ static private final int jjMoveStringLiteralDfa1_1(long active0, long active1, l } return jjStartNfa_1(0, active0, active1, active2); } -static private final int jjMoveStringLiteralDfa2_1(long old0, long active0, long old1, long active1, long old2, long 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); @@ -1585,7 +1585,7 @@ static private final int jjMoveStringLiteralDfa2_1(long old0, long active0, long } return jjStartNfa_1(1, active0, active1, active2); } -static private final int jjMoveStringLiteralDfa3_1(long old0, long active0, long old1, long active1, long old2, long 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); @@ -1666,7 +1666,7 @@ static private final int jjMoveStringLiteralDfa3_1(long old0, long active0, long } return jjStartNfa_1(2, active0, active1, 0L); } -static private final int jjMoveStringLiteralDfa4_1(long old0, long active0, long old1, long active1) +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); @@ -1753,7 +1753,7 @@ static private final int jjMoveStringLiteralDfa4_1(long old0, long active0, long } return jjStartNfa_1(3, active0, active1, 0L); } -static private final int jjMoveStringLiteralDfa5_1(long old0, long active0, long old1, long active1) +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); @@ -1825,7 +1825,7 @@ static private final int jjMoveStringLiteralDfa5_1(long old0, long active0, long } return jjStartNfa_1(4, active0, active1, 0L); } -static private final int jjMoveStringLiteralDfa6_1(long old0, long active0, long old1, long active1) +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); @@ -1888,7 +1888,7 @@ static private final int jjMoveStringLiteralDfa6_1(long old0, long active0, long } return jjStartNfa_1(5, active0, active1, 0L); } -static private final int jjMoveStringLiteralDfa7_1(long old0, long active0, long old1, long active1) +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); @@ -1921,7 +1921,7 @@ static private final int jjMoveStringLiteralDfa7_1(long old0, long active0, long } return jjStartNfa_1(6, active0, active1, 0L); } -static private final int jjMoveStringLiteralDfa8_1(long old0, long active0, long old1, long active1) +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); @@ -1945,7 +1945,7 @@ static private final int jjMoveStringLiteralDfa8_1(long old0, long active0, long } return jjStartNfa_1(7, active0, active1, 0L); } -static private final int jjMoveStringLiteralDfa9_1(long old0, long active0, long old1, long active1) +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); @@ -1964,7 +1964,7 @@ static private final int jjMoveStringLiteralDfa9_1(long old0, long active0, long } return jjStartNfa_1(8, active0, 0L, 0L); } -static private final int jjMoveStringLiteralDfa10_1(long old0, long active0) +private final int jjMoveStringLiteralDfa10_1(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_1(8, old0, 0L, 0L); @@ -1983,7 +1983,7 @@ static private final int jjMoveStringLiteralDfa10_1(long old0, long active0) } return jjStartNfa_1(9, active0, 0L, 0L); } -static private final int jjMoveStringLiteralDfa11_1(long old0, long active0) +private final int jjMoveStringLiteralDfa11_1(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_1(9, old0, 0L, 0L); @@ -2006,7 +2006,7 @@ static private final int jjMoveStringLiteralDfa11_1(long old0, long active0) } return jjStartNfa_1(10, active0, 0L, 0L); } -static private final int jjMoveNfa_1(int startState, int curPos) +private final int jjMoveNfa_1(int startState, int curPos) { int[] nextStates; int startsAt = 0; @@ -2402,7 +2402,7 @@ static private final int jjMoveNfa_1(int startState, int curPos) catch(java.io.IOException e) { return curPos; } } } -private static final int jjStopStringLiteralDfa_7(int pos, long active0, long active1) +private final int jjStopStringLiteralDfa_7(int pos, long active0, long active1) { switch (pos) { @@ -2410,11 +2410,11 @@ private static final int jjStopStringLiteralDfa_7(int pos, long active0, long ac return -1; } } -private static final int jjStartNfa_7(int pos, long active0, long active1) +private final int jjStartNfa_7(int pos, long active0, long active1) { return jjMoveNfa_7(jjStopStringLiteralDfa_7(pos, active0, active1), pos + 1); } -static private final int jjStartNfaWithStates_7(int pos, int kind, int state) +private final int jjStartNfaWithStates_7(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; @@ -2422,7 +2422,7 @@ static private final int jjStartNfaWithStates_7(int pos, int kind, int state) catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_7(state, pos + 1); } -static private final int jjMoveStringLiteralDfa0_7() +private final int jjMoveStringLiteralDfa0_7() { switch(curChar) { @@ -2434,7 +2434,7 @@ static private final int jjMoveStringLiteralDfa0_7() return jjMoveNfa_7(0, 0); } } -static private final int jjMoveNfa_7(int startState, int curPos) +private final int jjMoveNfa_7(int startState, int curPos) { int[] nextStates; int startsAt = 0; @@ -2592,17 +2592,17 @@ static final long[] jjtoSpecial = { static final long[] jjtoMore = { 0x4000000L, 0x0L, 0x0L, }; -static protected SimpleCharStream input_stream; -static private final int[] jjrounds = new int[52]; -static private final int[] jjstateSet = new int[104]; -static StringBuffer image; -static int jjimageLen; -static int lengthOfMatch; -static protected char curChar; +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 (input_stream != null) - throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR); + 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) @@ -2610,26 +2610,26 @@ public PHPParserTokenManager(SimpleCharStream stream, int lexState) this(stream); SwitchTo(lexState); } -static public void ReInit(SimpleCharStream stream) +public void ReInit(SimpleCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; curLexState = defaultLexState; input_stream = stream; ReInitRounds(); } -static private final void ReInitRounds() +private final void ReInitRounds() { int i; jjround = 0x80000001; for (i = 52; i-- > 0;) jjrounds[i] = 0x80000000; } -static public void ReInit(SimpleCharStream stream, int lexState) +public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } -static public void SwitchTo(int 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); @@ -2637,7 +2637,7 @@ static public void SwitchTo(int lexState) curLexState = lexState; } -static protected Token jjFillToken() +protected Token jjFillToken() { Token t = Token.newToken(jjmatchedKind); t.kind = jjmatchedKind; @@ -2659,14 +2659,14 @@ static protected Token jjFillToken() return t; } -static int curLexState = 0; -static int defaultLexState = 0; -static int jjnewStateCnt; -static int jjround; -static int jjmatchedPos; -static int jjmatchedKind; +int curLexState = 0; +int defaultLexState = 0; +int jjnewStateCnt; +int jjround; +int jjmatchedPos; +int jjmatchedKind; -public static Token getNextToken() +public Token getNextToken() { int kind; Token specialToken = null; @@ -2854,7 +2854,7 @@ public static Token getNextToken() } } -static void SkipLexicalActions(Token matchedToken) +void SkipLexicalActions(Token matchedToken) { switch(jjmatchedKind) { @@ -2869,7 +2869,7 @@ static void SkipLexicalActions(Token matchedToken) break; } } -static void TokenLexicalActions(Token matchedToken) +void TokenLexicalActions(Token matchedToken) { switch(jjmatchedKind) { diff --git a/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java b/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java index e6aa7e0..3ccaf79 100644 --- a/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java +++ b/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java @@ -8,34 +8,31 @@ package test; public class SimpleCharStream { - public static final boolean staticFlag = true; - static int bufsize; - static int available; - static int tokenBegin; - static public int bufpos = -1; + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; - //Added by Matthieu Casanova - public static int position = 0; + protected int beginOffset, endOffset; - public static int beginOffset, endOffset; + protected int bufline[]; + protected int bufcolumn[]; - static protected int bufline[]; - static protected int bufcolumn[]; + protected int column = 0; + protected int line = 1; - static protected int column = 0; - static protected int line = 1; + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; - static protected boolean prevCharIsCR = false; - static protected boolean prevCharIsLF = false; + protected java.io.Reader inputStream; - static protected java.io.Reader inputStream; - static protected StringBuffer currentBuffer = new StringBuffer(); + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + protected StringBuffer currentBuffer = new StringBuffer(); - static protected char[] buffer; - static protected int maxNextCharInd = 0; - static protected int inBuf = 0; - - static protected void ExpandBuff(boolean wrapAround) + protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; @@ -85,7 +82,7 @@ public class SimpleCharStream tokenBegin = 0; } - static protected void FillBuff() throws java.io.IOException + protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { @@ -134,7 +131,7 @@ public class SimpleCharStream } } - static public char BeginToken() throws java.io.IOException + public char BeginToken() throws java.io.IOException { beginOffset = endOffset; tokenBegin = -1; @@ -144,7 +141,7 @@ public class SimpleCharStream return c; } - static protected void UpdateLineColumn(char c) + protected void UpdateLineColumn(char c) { column++; @@ -182,10 +179,9 @@ public class SimpleCharStream bufline[bufpos] = line; bufcolumn[bufpos] = column; - } - static public char readChar() throws java.io.IOException + public char readChar() throws java.io.IOException { endOffset++; if (inBuf > 0) @@ -200,9 +196,8 @@ public class SimpleCharStream return buffer[bufpos]; } - if (++bufpos >= maxNextCharInd) { - FillBuff(); - } + if (++bufpos >= maxNextCharInd) + FillBuff(); char c = buffer[bufpos]; @@ -211,40 +206,41 @@ public class SimpleCharStream } /** - * @deprecated + * @deprecated * @see #getEndColumn */ - static public int getColumn() { + public int getColumn() { return bufcolumn[bufpos]; } /** - * @deprecated + * @deprecated * @see #getEndLine */ - static public int getLine() { + public int getLine() { return bufline[bufpos]; } - static public int getEndColumn() { + public int getEndColumn() { return bufcolumn[bufpos]; } - static public int getEndLine() { + public int getEndLine() { return bufline[bufpos]; } - static public int getBeginColumn() { + public int getBeginColumn() { return bufcolumn[tokenBegin]; } - static public int getBeginLine() { + public int getBeginLine() { return bufline[tokenBegin]; } - static public void backup(int amount) { + public void backup(int amount) { + endOffset -= amount; inBuf += amount; if ((bufpos -= amount) < 0) @@ -254,12 +250,8 @@ public class SimpleCharStream public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { - if (inputStream != null) - throw new Error("\n ERROR: Second call to the constructor of a static SimpleCharStream. You must\n" + - " either use ReInit() or set the JavaCC option STATIC to false\n" + - " during the generation of this class."); inputStream = dstream; - currentBuffer = new StringBuffer(); + currentBuffer = new StringBuffer(); line = startline; column = startcolumn - 1; @@ -269,7 +261,6 @@ public class SimpleCharStream bufcolumn = new int[buffersize]; beginOffset = 0; endOffset = 0; - } public SimpleCharStream(java.io.Reader dstream, int startline, @@ -347,7 +338,7 @@ public class SimpleCharStream { ReInit(dstream, startline, startcolumn, 4096); } - static public String GetImage() + public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); @@ -356,7 +347,7 @@ public class SimpleCharStream new String(buffer, 0, bufpos + 1); } - static public char[] GetSuffix(int len) + public char[] GetSuffix(int len) { char[] ret = new char[len]; @@ -372,18 +363,17 @@ public class SimpleCharStream return ret; } - static public void Done() + public void Done() { buffer = null; bufline = null; bufcolumn = null; - } /** * Method to adjust line and column numbers for the start of a token.
*/ - static public void adjustBeginLineColumn(int newLine, int newCol) + public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; @@ -408,7 +398,7 @@ public class SimpleCharStream bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; - } + } if (i < len) { @@ -417,11 +407,10 @@ public class SimpleCharStream while (i++ < len) { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; - } else { + else bufline[j] = newLine; - } } } @@ -429,11 +418,25 @@ public class SimpleCharStream column = bufcolumn[j]; } + public StringBuffer getCurrentBuffer() { + return currentBuffer; + } + + //Added by Matthieu Casanova + public int position = 0; /** * @deprecated * @return */ - public static int getPosition() { + public int getPosition() { return position + bufpos; } + + public int getBeginOffset() { + return beginOffset; + } + + public int getEndOffset() { + return endOffset; + } } diff --git a/net.sourceforge.phpeclipse/src/test/TokenMgrError.java b/net.sourceforge.phpeclipse/src/test/TokenMgrError.java index a52959c..64cc02b 100644 --- a/net.sourceforge.phpeclipse/src/test/TokenMgrError.java +++ b/net.sourceforge.phpeclipse/src/test/TokenMgrError.java @@ -90,7 +90,7 @@ public class TokenMgrError extends Error * curLexState : lexical state in which this error occured * errorLine : line number when the error occured * errorColumn : column number when the error occured - * errorAfter : functionName that was seen before this 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. */