using System.IO; namespace codelanguage; public class CraftCodeFile : CraftFile { public List CodeLines { get; set; } = new(); public List Tokens { get; set; } = new(); public CraftCodeFile(string path) : base(path) { } public override bool Load() { try { CodeLines = File.ReadAllLines(Path).ToList(); LastModified = File.GetLastWriteTime(Path); return true; } catch { return false; } } public override bool Save() { try { File.WriteAllLines(Path, CodeLines); return true; } catch { return false; } } public bool Tokenize() { try { var lexer = new Lexer(string.Join("\n", CodeLines)); Tokens = lexer.Tokenize(); return true; } catch { return false; } } public string GetCode() => string.Join("\n", CodeLines); public void SetCode(string code) => CodeLines = code.Split('\n').ToList(); }