add log for c language

?: //not capture during parsing
import java.io.File;

import org.apache.commons.io.FileUtils;

public class AddlogForC {

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		File f = new File(
				"test.c");
		String content = FileUtils.readFileToString(f);
		String regex = "((?:static\\s+)?[\\w*]+\\s+([\\w+]+)\\s*\\([^)]*\\)\\s*\\s\\{)"; // [^)]*\\)\\s*\\{
		System.out
				.println(content.replaceAll(regex, "$1\n    printf(\"$2\");"));
		FileUtils.write(f, content);
	}

}

你可能感兴趣的:(language)