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 java.util.List;
14 import java.util.ArrayList;
16 //import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
17 //import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
18 //import net.sourceforge.phpdt.internal.compiler.impl.Constant;
19 //import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
20 //import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
22 public class StringLiteral extends Literal {
25 public StringLiteral(final char[] token, final int s) {
26 super(s, s + token.length);
31 * Create a new StringLiteral
32 * @param token the token
33 * @param s sourcestart
37 public StringLiteral(final char[] token, final int s, final int e) {
42 public StringLiteral(final int s, final int e) {
47 * source method comment.
49 public char[] source() {
54 * Return the expression as String.
55 * @return the expression
57 /* public String toStringExpression() {
58 // handle some special char.....
59 StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$
60 for (int i = 0; i < source.length; i++) {
63 result.append("\\b"); //$NON-NLS-1$
66 result.append("\\t"); //$NON-NLS-1$
69 result.append("\\n"); //$NON-NLS-1$
72 result.append("\\f"); //$NON-NLS-1$
75 result.append("\\r"); //$NON-NLS-1$
78 result.append("\\\""); //$NON-NLS-1$
81 result.append("\\'"); //$NON-NLS-1$
83 case '\\': //take care not to display the escape as a potential real char
84 result.append("\\\\"); //$NON-NLS-1$
87 result.append(source[i]);
90 result.append("\""); //$NON-NLS-1$
91 return result.toString();
95 * Return the expression as String.
96 * @return the expression
98 public String toStringExpression() {
99 return new String(source);
103 * @deprecated - use field instead
105 public int sourceEnd() {
106 return getSourceEnd();
110 * @deprecated - use field instead
112 public int sourceStart() {
113 return getSourceStart();