Commit | Line | Data |
---|---|---|
b1ea73b5 MK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | *******************************************************************************/ | |
9 | package org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl; | |
10 | ||
11 | import java.util.List; | |
12 | ||
13 | import org.antlr.runtime.tree.CommonTree; | |
14 | import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ICommonTreeParser; | |
15 | ||
16 | /** | |
17 | * A parser of pointer lists... like x.y.z | |
18 | * | |
19 | * @author Matthew Khouzam - Initial API and implementation | |
20 | */ | |
4055c3a1 | 21 | public final class PointerListStringParser implements ICommonTreeParser { |
b1ea73b5 MK |
22 | |
23 | /** | |
24 | * Instance | |
25 | */ | |
26 | public static final PointerListStringParser INSTANCE = new PointerListStringParser(); | |
27 | ||
28 | private PointerListStringParser() { | |
29 | } | |
30 | ||
31 | /** | |
32 | * Creates the string representation of a type specifier. | |
33 | * | |
34 | * @param pointers | |
35 | * A TYPE_SPECIFIER node. | |
36 | * @param param | |
37 | * unused | |
38 | * | |
39 | * @return A StringBuilder to which will be appended the string. | |
40 | */ | |
41 | @Override | |
42 | public StringBuilder parse(CommonTree pointers, ICommonTreeParserParameter param) { | |
43 | StringBuilder sb = new StringBuilder(); | |
44 | List<CommonTree> pointerList = pointers.getChildren(); | |
45 | if (pointers.getChildCount() == 0) { | |
46 | return sb; | |
47 | } | |
48 | ||
49 | for (CommonTree pointer : pointerList) { | |
50 | ||
51 | sb.append(" *"); //$NON-NLS-1$ | |
52 | if (pointer.getChildCount() > 0) { | |
53 | sb.append(" const"); //$NON-NLS-1$ | |
54 | } | |
55 | } | |
56 | return sb; | |
57 | } | |
58 | } |