/// <summary> /// Pre-compiles DS code in code block node, /// checks for syntax, converts non-assignments to assignments, /// stores list of AST nodes, errors and warnings /// Evaluates and stores list of unbound identifiers /// </summary> /// <param name="priorNames"></param> /// <param name="parseParams"> container for compilation related parameters </param> /// <param name="elementResolver"> classname resolver </param> /// <returns> true if code compilation succeeds, false otherwise </returns> public static bool PreCompileCodeBlock(Core core, ref ParseParam parseParams, IDictionary <string, string> priorNames = null) { string postfixGuid = parseParams.PostfixGuid.ToString().Replace("-", "_"); // Parse code to generate AST and add temporaries to non-assignment nodes List <AssociativeNode> astNodes; List <AssociativeNode> comments; ParseUserCode(core, parseParams.OriginalCode, postfixGuid, out astNodes, out comments); parseParams.AppendErrors(core.BuildStatus.Errors); if (parseParams.Errors.Count() > 0) { return(false); } // Catch the syntax errors and errors for unsupported // language constructs thrown by compile expression parseParams.AppendWarnings(core.BuildStatus.Warnings); var warnings = Check(astNodes); parseParams.AppendWarnings(warnings); parseParams.AppendParsedNodes(astNodes.Where(n => !n.skipMe)); parseParams.AppendComments(comments); // Compile the code to get the resultant unboundidentifiers // and any errors or warnings that were caught by the compiler and cache them in parseParams return(CompileCodeBlockAST(core, parseParams, priorNames)); }
/// <summary> /// Pre-compiles DS code in code block node, /// checks for syntax, converts non-assignments to assignments, /// stores list of AST nodes, errors and warnings /// Evaluates and stores list of unbound identifiers /// </summary> /// <param name="parseParams"></param> /// <returns></returns> public static bool PreCompileCodeBlock(Core core, ref ParseParam parseParams) { string postfixGuid = parseParams.PostfixGuid.ToString().Replace("-", "_"); // Parse code to generate AST and add temporaries to non-assignment nodes IEnumerable <ProtoCore.AST.Node> astNodes = ParseUserCode(core, parseParams.OriginalCode, postfixGuid); // Catch the syntax errors and errors for unsupported // language constructs thrown by compile expression if (core.BuildStatus.ErrorCount > 0) { parseParams.AppendErrors(core.BuildStatus.Errors); parseParams.AppendWarnings(core.BuildStatus.Warnings); return(false); } parseParams.AppendParsedNodes(astNodes); // Compile the code to get the resultant unboundidentifiers // and any errors or warnings that were caught by the compiler and cache them in parseParams return(CompileCodeBlockAST(core, parseParams)); }
/// <summary> /// Pre-compiles DS code in code block node, /// checks for syntax, converts non-assignments to assignments, /// stores list of AST nodes, errors and warnings /// Evaluates and stores list of unbound identifiers /// </summary> /// <param name="parseParams"> container for compilation related parameters </param> /// <param name="elementResolver"> classname resolver </param> /// <returns> true if code compilation succeeds, false otherwise </returns> public static bool PreCompileCodeBlock(Core core, ref ParseParam parseParams) { string postfixGuid = parseParams.PostfixGuid.ToString().Replace("-", "_"); // Parse code to generate AST and add temporaries to non-assignment nodes List<AssociativeNode> astNodes; List<AssociativeNode> comments; ParseUserCode(core, parseParams.OriginalCode, postfixGuid, out astNodes, out comments); // Catch the syntax errors and errors for unsupported // language constructs thrown by compile expression if (core.BuildStatus.ErrorCount > 0) { parseParams.AppendErrors(core.BuildStatus.Errors); parseParams.AppendWarnings(core.BuildStatus.Warnings); return false; } parseParams.AppendParsedNodes(astNodes); parseParams.AppendComments(comments); // Compile the code to get the resultant unboundidentifiers // and any errors or warnings that were caught by the compiler and cache them in parseParams return CompileCodeBlockAST(core, parseParams); }