1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
13 //import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 //import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
15 //import net.sourceforge.phpdt.internal.compiler.impl.Constant;
16 //import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17 //import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
19 public class StringLiteral extends Literal {
22 public StringLiteral(char[] token, int s, int e) {
27 public StringLiteral(int s, int e) {
32 * source method comment.
34 public char[] source() {
39 * Return the expression as String.
40 * @return the expression
42 public String toStringExpression() {
43 // handle some special char.....
44 StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$
45 for (int i = 0; i < source.length; i++) {
48 result.append("\\b"); //$NON-NLS-1$
51 result.append("\\t"); //$NON-NLS-1$
54 result.append("\\n"); //$NON-NLS-1$
57 result.append("\\f"); //$NON-NLS-1$
60 result.append("\\r"); //$NON-NLS-1$
63 result.append("\\\""); //$NON-NLS-1$
66 result.append("\\'"); //$NON-NLS-1$
68 case '\\' : //take care not to display the escape as a potential real char
69 result.append("\\\\"); //$NON-NLS-1$
72 result.append(source[i]);
75 result.append("\""); //$NON-NLS-1$
76 return result.toString();
80 * @deprecated - use field instead
82 public int sourceEnd() {
87 * @deprecated - use field instead
89 public int sourceStart() {