public static void AddVariableReference(this AstNode node, GeneroAst ast, bool bindNames, object reference) { if (bindNames) { ast.SetAttribute(node, VariableReference, reference); } }
//public string ToCodeString(GeneroAst ast) //{ // return ToCodeString(ast, CodeFormattingOptions.Default); //} //public string ToCodeString(GeneroAst ast, CodeFormattingOptions format) //{ // StringBuilder res = new StringBuilder(); // AppendCodeString(res, ast, format); // return res.ToString(); //} public virtual void PropagateSyntaxTree(GeneroAst ast) { SyntaxTree = ast; foreach (var child in Children) { child.Value.PropagateSyntaxTree(ast); } }
/// <summary> /// The default method calls CheckForErrors on all AstNode children of this node. /// To do specific error checking, override this method and call the base method at the end. /// </summary> /// <param name="ast"></param> /// <param name="errors"></param> public virtual void CheckForErrors(GeneroAst ast, Action <string, int, int> errorFunc, Dictionary <string, List <int> > deferredFunctionSearches, FunctionProviderSearchMode searchInFunctionProvider = FunctionProviderSearchMode.NoSearch, bool isFunctionCallOrDefinition = false) { foreach (var child in Children) { child.Value.CheckForErrors(ast, errorFunc, deferredFunctionSearches, searchInFunctionProvider, isFunctionCallOrDefinition); } }
public static string[] GetNamesWhiteSpace(this AstNode node, GeneroAst ast) { object whitespace; if (ast.TryGetAttribute(node, NodeAttributes.NamesWhiteSpace, out whitespace)) { return((string[])whitespace); } else { return(null); } }
public static string[] GetVerbatimNames(this AstNode node, GeneroAst ast) { object names; if (ast.TryGetAttribute(node, NodeAttributes.VerbatimNames, out names)) { return((string[])names); } else { return(null); } }
public static bool IsIncompleteNode(this AstNode node, GeneroAst ast) { object dummy; if (ast.TryGetAttribute(node, NodeAttributes.ErrorIncompleteNode, out dummy)) { return(true); } else { return(false); } }
public static bool IsMissingCloseGrouping(this AstNode node, GeneroAst ast) { object dummy; if (ast.TryGetAttribute(node, NodeAttributes.ErrorMissingCloseGrouping, out dummy)) { return(true); } else { return(false); } }
public static bool IsAltForm(this AstNode node, GeneroAst ast) { object dummy; if (ast.TryGetAttribute(node, NodeAttributes.IsAltFormValue, out dummy)) { return(true); } else { return(false); } }
private static string GetWhiteSpace(AstNode node, GeneroAst ast, object kind, string defaultValue = " ") { object whitespace; if (ast.TryGetAttribute(node, kind, out whitespace)) { return((string)whitespace); } else { return(defaultValue); } }
public static string GetVerbatimImage(this AstNode node, GeneroAst ast) { object image; if (ast.TryGetAttribute(node, NodeAttributes.VerbatimImage, out image)) { return((string)image); } else { return(null); } }
public override string GetExpressionType(GeneroAst ast) { // need to determine the type from the variables available IGeneroProject dummyProj; IProjectEntry dummyProjEntry; bool dummy; IAnalysisResult res = ast.GetValueByIndex(Name, StartIndex, ast._functionProvider, ast._databaseProvider, ast._programFileProvider, false, out dummy, out dummyProj, out dummyProjEntry); if (res != null) { return(res.Typename); } return(null); }
protected void UpdateNodeAndTree(AstNode node, GeneroAst ast) { node.PropagateSyntaxTree(ast); if (_verbatim) { if (_lookahead.Token != null) { AddExtraVerbatimText(node, _lookaheadWhiteSpace + _lookahead.Token.VerbatimImage); } AddCodeRegions(node); AddNonCodeRegionComments(node); _codeRegions.Clear(); _nonCodeRegionComments.Clear(); } foreach (var keyValue in _attributes) { foreach (var nodeAttr in keyValue.Value) { ast.SetAttribute(keyValue.Key, nodeAttr.Key, nodeAttr.Value); } } }
public static string GetFifthWhiteSpace(this AstNode node, GeneroAst ast) { return(GetWhiteSpace(node, ast, NodeAttributes.FifthPreceedingWhiteSpace)); }
public SourceSpan GetSpan(GeneroAst parent) { return(new SourceSpan(GetStart(parent), GetEnd(parent))); }
public SourceLocation GetEnd(GeneroAst parent) { return(parent.IndexToLocation(EndIndex)); }
public SourceLocation GetStart(GeneroAst parent) { return(parent.IndexToLocation(StartIndex)); }
public static string GetFourthWhiteSpaceDefaultNull(this AstNode node, GeneroAst ast) { return(GetWhiteSpace(node, ast, NodeAttributes.FourthPreceedingWhiteSpace, null)); }
public abstract string GetExpressionType(GeneroAst ast);
public override string GetExpressionType(GeneroAst ast) { // TODO: determine the type from the token we have return(null); }
public static string GetExtraVerbatimText(this AstNode node, GeneroAst ast) { return(GetWhiteSpace(node, ast, NodeAttributes.ExtraVerbatimText, null)); }
public override string GetExpressionType(GeneroAst ast) { return("string"); }