public override void BuildAst(LanguageData language, ParseTree parseTree) { var opHandler = new OperatorHandler(language.Grammar.CaseSensitive); Util.Check(!parseTree.HasErrors(), "ParseTree has errors, cannot build AST."); var astContext = new InterpreterAstContext(language, opHandler); var astBuilder = new AstBuilder(astContext); astBuilder.BuildAst(parseTree); }
public void Validate(ParseTree parseTree) { if (parseTree.HasErrors() && parseTree.ParserMessages.Count > 0) { var message = parseTree.ParserMessages[0]; var error = message.Message + " at " + message.Location.ToUiString(); throw new Exception(error); } }
public void TryParse(string source) { //ClearParserOutput(); if (_parser == null || !_parser.Language.CanParse()) return; _parseTree = null; GC.Collect(); //to avoid disruption of perf times with occasional collections //_parser.Context.TracingEnabled = chkParserTrace.Checked; try { _parseTree = _parser.Parse(source); if (_parseTree.HasErrors() == false) { UpdateOutlineWindow(); statusBarControl.State = new LPSolverState("Done.", EnumEditorStates.Normal); } //else //{ // throw new Exception("Could not Parse the Model. Please Check Error List"); //} } catch (Exception exp) { statusBarControl.State = new LPSolverState("Parser Error - " + exp.Message, EnumEditorStates.Error); } finally { _parseTree = _parser.Context.CurrentParseTree; ShowCompilerErrors(); } }
public static void CheckParseErrors(ParseTree parseTree) { if (parseTree.HasErrors()) throw new Exception("Unexpected parse error(s): " + string.Join("\n", parseTree.ParserMessages)); }
/// <summary> /// スクリプトを解析し、処理ができるようにします。 /// 通常、この関数はスクリプトを読み込んだ時点で自動的に実行されます。 /// </summary> public void Parse() { RawTree = Parser.Parse(RawString); if (RawTree.HasErrors()) { var exm = "Kastepsスクリプトにエラーがありました。" + Environment.NewLine; foreach (var m in RawTree.ParserMessages) { exm += String.Format("{0} @[{1},{2}]: {3}", m.Level, m.Location.Line, m.Location.Column, m.Message); } throw new InvalidDataException(exm); } }
public bool HasErrors() { return(parseTree.HasErrors()); }