1 package edu.uci.eecs.specExtraction;
4 import java.util.regex.Matcher;
5 import java.util.regex.Pattern;
7 import edu.uci.eecs.utilParser.ParseException;
8 import edu.uci.eecs.utilParser.UtilParser;
12 * This class represents a variable declaration in C/C++, in which there exist a
19 public class VariableDeclaration {
20 public final String type;
21 public final String name;
23 public VariableDeclaration(String type, String name) {
24 this.type = SpecUtils.trimSpace(type);
25 this.name = SpecUtils.trimSpace(name);
28 public VariableDeclaration(File file, int lineNum, String line)
29 throws WrongAnnotationException {
30 VariableDeclaration decl = null;
32 decl = UtilParser.parseDeclaration(line);
33 } catch (ParseException e) {
34 WrongAnnotationException.err(file, lineNum, "The declaration: \""
35 + line + "\" has wrong syntax.");
37 type = decl == null ? null : decl.type;
38 name = decl == null ? null : decl.name;
42 public String toString() {
43 return type + ": " + name;