import java.io.*;

public class Cfile {
	File file;
	CfunctionList cfnlist;
	Cfile(File file) throws SyntaxException {
		this.file = file;
		cfnlist = new CfunctionList();
		Lex lex = new Lex(file);
		while(lex.getTokenType() != Lex.EOF) {
			if(lex.getTokenType() == Lex.LEFTBRACE) {
				lex.skipNested();
			}
			Cfunction cfn = new Cfunction(lex);
			if(cfn.isValid()) {
				cfnlist.add(cfn);
			} else {
				lex.gtkn();
			}
		}
	}
	public void dump(PrintWriter out) {
		out.println(simpleName());
		out.println(file.getAbsolutePath());
		cfnlist.dump(out);
	}
	public String simpleName() {
		String name = file.getName();
		return(name.substring(0,name.length()-2));
	}
	public CfunctionList getCfnlist() {
		return(cfnlist);
	}
	public String toString() {
		return(file.toString());
	}
}
