1 package edu.uci.eecs.specExtraction;
4 import java.util.regex.Matcher;
5 import java.util.regex.Pattern;
9 * This class represents a variable declaration in C/C++, in which there exist a
16 public class VariableDeclaration {
17 public final String type;
18 public final String name;
20 public VariableDeclaration(String type, String name) {
21 this.type = SpecUtils.trimSpace(type);
22 this.name = SpecUtils.trimSpace(name);
25 public VariableDeclaration(File file, int lineNum, String line)
26 throws WrongAnnotationException {
27 // "([<>\*\w\s]+)\s?(\w+)\s;"
28 Pattern regexp = Pattern.compile("([<>&\\*\\w\\s]+)\\s?(\\w+)\\s?;");
29 Matcher matcher = regexp.matcher(line);
31 type = matcher.group(1);
32 name = matcher.group(2);
36 WrongAnnotationException.err(file, lineNum, "The declaration: \""
37 + line + "\" has wrong syntax.");
41 public String toString() {
42 return type + ": " + name;