X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index 9ad3eff..10ba3a9 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -87,7 +87,7 @@ public final class PHPParser extends PHPParserSuperclass { /** The cursor in expression stack. */ private static int nodePtr; - public static final boolean PARSER_DEBUG = true; + public static final boolean PARSER_DEBUG = false; public final void setFileToParse(final IFile fileToParse) { PHPParser.fileToParse = fileToParse; @@ -589,19 +589,79 @@ MORE : | <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | - | | )> -| + | )> +//| | | } + SKIP : +{ + : IN_STRING +} + + TOKEN : +{ + : IN_STRING +} + + + TOKEN : +{ + : DOLLAR_IN_STRING +} + + TOKEN : +{ + : PHPPARSING +} + + TOKEN : +{ + : DOLLAR_IN_STRING_EXPR +} + + SPECIAL_TOKEN : +{ + <"{"> : SKIPSTRING +} + + SPECIAL_TOKEN : +{ + <"}"> : IN_STRING +} + + SKIP : +{ + <~[]> +} + + TOKEN : +{ + : DOLLAR_IN_STRING +} + + TOKEN : +{ + +} + + SKIP : +{ + <~[]> +} + + SKIP : +{ + <~[]> +} /* IDENTIFIERS */ TOKEN : { : IN_VARIABLE} - TOKEN : + TOKEN : { |) (||)* > | @@ -618,6 +678,10 @@ MORE : > } + SPECIAL_TOKEN : +{ + < ~[] > : IN_STRING +} /* SEPARATORS */ TOKEN : @@ -920,19 +984,19 @@ FieldDeclaration FieldDeclaration() : */ VariableDeclaration VariableDeclaratorNoSuffix() : { - final Token dollar, token, lbrace,rbrace; + final Token token, lbrace,rbrace; Expression expr, initializer = null; Token assignToken; Variable variable; } { - dollar = + ( token = - {variable = new Variable(token.image,dollar.sourceStart,token.sourceEnd);} + {variable = new Variable(token.image,token.sourceStart,token.sourceEnd);} | lbrace = expr = Expression() rbrace = - {variable = new Variable(expr,dollar.sourceStart,rbrace.sourceEnd);} + {variable = new Variable(expr,lbrace.sourceStart,rbrace.sourceEnd);} ) [ assignToken = @@ -1036,13 +1100,13 @@ Variable Variable() : final Token token; } { - token = variable = Var(token) + token = variable = Var() { - return new Variable(variable,token.sourceStart,variable.sourceEnd); + return variable; } } -Variable Var(final Token dollar) : +Variable Var() : { Variable variable = null; final Token token,token2; @@ -1050,18 +1114,18 @@ Variable Var(final Token dollar) : Expression expression; } { - token = variable = Var(token) - {return new Variable(variable,dollar.sourceStart,variable.sourceEnd);} + token = variable = Var() + {return new Variable(variable,variable.sourceStart,variable.sourceEnd);} | token = expression = Expression() token2 = { return new Variable(expression, - dollar.sourceStart, + token.sourceStart, token2.sourceEnd); } | token = - {return new Variable(token.image,dollar.sourceStart,token.sourceEnd);} + {return new Variable(token.image,token.sourceStart,token.sourceEnd);} } Expression VariableInitializer() : @@ -1865,7 +1929,7 @@ AbstractVariable VariableSuffix(final AbstractVariable prefix) : } | token = - {expression = new Variable(token.image,token.sourceStart,token.sourceEnd);} + {expression = new ConstantIdentifier(token.image,token.sourceStart,token.sourceEnd);} | expression = Variable() ) @@ -1914,6 +1978,7 @@ AbstractVariable VariableSuffix(final AbstractVariable prefix) : Literal Literal() : { final Token token; + StringLiteral literal; } { token = {return new NumberLiteral(token);} @@ -1922,26 +1987,70 @@ Literal Literal() : | token = {return new TrueLiteral(token);} | token = {return new FalseLiteral(token);} | token = {return new NullLiteral(token);} +| literal = evaluableString() {return literal;} +} + +StringLiteral evaluableString() : +{ + ArrayList list = new ArrayList(); + Token start,end; + Token token,lbrace,rbrace; + AbstractVariable var; + Expression expr; +} +{ + start = + ( + + ( + token = {list.add(new Variable(token.image, + token.sourceStart, + token.sourceEnd));} + | + lbrace = + token = + {list.add(new Variable(token.image, + token.sourceStart, + token.sourceEnd));} + rbrace = + ) + )* + end = + { + AbstractVariable[] vars = new AbstractVariable[list.size()]; + list.toArray(vars); + return new StringLiteral(SimpleCharStream.currentBuffer.substring(start.sourceEnd,end.sourceStart), + start.sourceStart, + end.sourceEnd, + vars); + } } FunctionCall Arguments(final Expression func) : { Expression[] args = null; -final Token token; +final Token token,lparen; } { - [ args = ArgumentList() ] + lparen = [ args = ArgumentList() ] try { token = {return new FunctionCall(func,args,token.sourceEnd);} } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list"; errorLevel = ERROR; - errorStart = args[args.length-1].sourceEnd+1; - errorEnd = args[args.length-1].sourceEnd+1; + if (args == null) { + errorStart = lparen.sourceEnd+1; + errorEnd = lparen.sourceEnd+2; + } else { + errorStart = args[args.length-1].sourceEnd+1; + errorEnd = args[args.length-1].sourceEnd+2; + } processParseExceptionDebug(e); } - {return new FunctionCall(func,args,args[args.length-1].sourceEnd);} + { + int sourceEnd = (args == null && args.length != 0) ? lparen.sourceEnd+1 : args[args.length-1].sourceEnd; + return new FunctionCall(func,args,sourceEnd);} } /** @@ -2749,7 +2858,6 @@ Expression SwitchLabel() : token = <_DEFAULT> try { - {return null;} } catch (ParseException e) { errorMessage = "':' expected after 'default' keyword"; errorLevel = ERROR; @@ -2757,6 +2865,7 @@ Expression SwitchLabel() : errorEnd = token.sourceEnd+1; processParseExceptionDebug(e); } + {return null;} } Break BreakStatement() :