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
CommitLineData
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
10package org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.event;
11
12import static org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.TsdlUtils.concatenateUnaryStrings;
13import static org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.TsdlUtils.isAnyUnaryString;
14
15import org.antlr.runtime.tree.CommonTree;
16import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ICommonTreeParser;
17import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException;
18
19/**
20 * Parser for event names
21 *
22 * @author Matthew Khouzam
23 *
24 */
4055c3a1 25public final class EventNameParser implements ICommonTreeParser {
b1ea73b5
MK
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.045309 seconds and 5 git commands to generate.