public SyntaxTree ParseFileContents(string fileContents, FortranStyle style = FortranStyle.Fortran90) { var oldCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var sourceAST = new SyntaxTree(); try { streamReader = new FortranStreamReader(fileContents, style); IMember parentMember = null; while (streamReader.HasMoreToRead()) { if (streamReader.SkipToNextPotentialCodeElement()) { if (TryReadMember <Program>("program", sourceAST, ref parentMember)) { continue; } if (TryReadMember <Module>("module", sourceAST, ref parentMember)) { continue; } if (TryReadMember <Interface>("interface", sourceAST, ref parentMember)) { continue; } if (TryReadMember <Subroutine>("subroutine", sourceAST, ref parentMember)) { continue; } if (TryReadMember <Function>("function", sourceAST, ref parentMember)) { continue; } if (TryReadType("type", sourceAST, ref parentMember)) { continue; } if (TryReadModuleProcedure(ref parentMember)) { continue; } } } } finally { Thread.CurrentThread.CurrentCulture = oldCulture; } return(sourceAST); }
public FortranStreamReader(string text, FortranStyle style) { Style = style; Text = text ?? string.Empty; LineNumber = 1; }