public static ParserState Parse(string source, IAbstractSyntaxTreePrinter printer = null, Rule rule = null) { if (rule == null) rule = _grammar.file; var state = new ParserState(source); try { if (rule.Match(state)) { if (state.AtEndOfInput()) { if (printer != null) printer.Print(state.GetRoot()); return state; } throw new ParsingException(state, rule, message: "Failed to read end of input"); } throw new ParsingException(state, rule, message: "Failed to parse source"); } catch (ParsingException e) { return state.Exception(e); } }
public static ParserState Parse(string source, IAbstractSyntaxTreePrinter printer = null, Rule rule = null) { if (rule == null) { rule = _grammar.file; } var state = new ParserState(source); try { if (rule.Match(state)) { if (state.AtEndOfInput()) { if (printer != null) { printer.Print(state.GetRoot()); } return(state); } throw new ParsingException(state, rule, message: "Failed to read end of input"); } throw new ParsingException(state, rule, message: "Failed to parse source"); } catch (ParsingException e) { return(state.Exception(e)); } }
public static IEnumerable<ParserState> Parse(IAbstractSyntaxTreePrinter printer, string sDir) { foreach ( var state in Directory.GetFiles("*.c;*.cpp;*.h;*.hpp;").Select(fi => CppFileParser.Parse(fi, printer)) ) { if (state.ParseException != null) throw state.ParseException; yield return state; } }
public static IEnumerable <ParserState> Parse(IAbstractSyntaxTreePrinter printer, string sDir) { foreach (var state in Directory.GetFiles("*.c;*.cpp;*.h;*.hpp;").Select(fi => CppFileParser.Parse(fi, printer))) { if (state.ParseException != null) { throw state.ParseException; } yield return(state); } }
public static ParserState Parse(string file, IAbstractSyntaxTreePrinter printer = null) { string text = File.ReadAllText(file); return CppSourceParser.Parse(text, printer); }
public static ParserState Parse(string file, IAbstractSyntaxTreePrinter printer = null) { string text = File.ReadAllText(file); return(CppSourceParser.Parse(text, printer)); }