ctf: make all parser implementations final classes
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.ctf.core / src / org / eclipse / tracecompass / internal / ctf / core / event / metadata / tsdl / event / EventNameParser.java
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
10 package org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.event;
11
12 import static org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.TsdlUtils.concatenateUnaryStrings;
13 import static org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.TsdlUtils.isAnyUnaryString;
14
15 import org.antlr.runtime.tree.CommonTree;
16 import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ICommonTreeParser;
17 import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException;
18
19 /**
20 * Parser for event names
21 *
22 * @author Matthew Khouzam
23 *
24 */
25 public final class EventNameParser implements ICommonTreeParser {
26 /**
27 * Instance
28 */
29 public static final EventNameParser INSTANCE = new EventNameParser();
30
31 private EventNameParser() {
32 }
33
34 @Override
35 public String parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {
36 CommonTree firstChild = (CommonTree) tree.getChild(0);
37
38 if (isAnyUnaryString(firstChild)) {
39 return concatenateUnaryStrings(tree.getChildren());
40 }
41 throw new ParseException("invalid value for event name"); //$NON-NLS-1$
42 }
43
44 }
This page took 0.049084 seconds and 5 git commands to generate.