IEnumerable <SourceLine> Preprocess(string fileName, string source) { source = source.Replace("\r", string.Empty); // remove Windows CR source = ProcessComments(fileName, source); var uncommented = LexerParser.Parse(fileName, source); // process older .comment/.endcomments var lineIterator = uncommented.GetIterator(); SourceLine line; while ((line = lineIterator.Skip(l => !l.InstructionName.Equals(".comment"))) != null) { Assembler.Log.LogEntry(line, line.Instruction, "Directive \".comment\" is deprecated. Consider using '/*' for comment blocks instead.", false); line.Reset(); while ((line = lineIterator.GetNext()) != null && !line.InstructionName.Equals(".endcomment")) { line.Reset(); } if (line == null) { throw new Exception("Missing closing \".endcomment\" for \".comment\" directive."); } line.Reset(); } return(ProcessMacros(uncommented)); }
void SetOptionsFromConfig(string configFile) { try { string json = File.ReadAllText(configFile).Replace("\r", string.Empty); var tokens = LexerParser.TokenizeJson(json); if (tokens.Children.Count != 1 || !tokens.Children[0].Name.Equals("{")) { throw new Exception("Invalid configuration file."); } SetChildOptionsFromConfig("/", tokens.Children[0]); } catch (FileNotFoundException) { Console.Error.WriteLine($"Config file \"{configFile}\" not found."); } }