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) {
23 super(s, s + token.length);
28 * Create a new StringLiteral
29 * @param token the token
30 * @param s sourcestart
34 public StringLiteral(char[] token, int s, int e) {
39 public StringLiteral(int s, int e) {
44 * source method comment.
46 public char[] source() {
51 * Return the expression as String.
52 * @return the expression
54 public String toStringExpression() {
55 // handle some special char.....
56 StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$
57 for (int i = 0; i < source.length; i++) {
60 result.append("\\b"); //$NON-NLS-1$
63 result.append("\\t"); //$NON-NLS-1$
66 result.append("\\n"); //$NON-NLS-1$
69 result.append("\\f"); //$NON-NLS-1$
72 result.append("\\r"); //$NON-NLS-1$
75 result.append("\\\""); //$NON-NLS-1$
78 result.append("\\'"); //$NON-NLS-1$
80 case '\\': //take care not to display the escape as a potential real char
81 result.append("\\\\"); //$NON-NLS-1$
84 result.append(source[i]);
87 result.append("\""); //$NON-NLS-1$
88 return result.toString();
92 * @deprecated - use field instead
94 public int sourceEnd() {
99 * @deprecated - use field instead
101 public int sourceStart() {