static int Main(string[] args) { if (args.Length == 0) { throw new RaulException("Você precisa passar um arquivo"); } //Console.WriteLine(Directory.GetCurrentDirectory()); string code = File.ReadAllText(args[0]); if (string.IsNullOrWhiteSpace(code)) { throw new RaulException("Não pode ter nada vazio...Espaços contam como vazio, se você não entendeu."); } code = Preproc.Run(code); Node root = Parser.Run(code); SymbolTable st = new SymbolTable(); string alo = root.Evaluate(st); Console.WriteLine(alo); return(0); }
public Node Parse(string text, bool enableTracing = false) { Log = new List <Message>(); Statistics = new Statistics(); EnableTracing = enableTracing; var parsingStarted = DateTime.Now; Node root = null; /// Если парсеру передан препроцессор if (Preproc != null) { /// Предобрабатываем текст text = Preproc.Preprocess(text, out bool success); /// Если препроцессор сработал успешно, можно парсить if (success) { root = ParsingAlgorithm(text); Preproc.Postprocess(root, Log); } else { Log.AddRange(Preproc.Log); } } else { root = ParsingAlgorithm(text); } Statistics.GeneralTimeSpent = DateTime.Now - parsingStarted; Statistics.TokensCount = LexingStream.Count; Statistics.CharsCount = text.Length; return(root); }