Beispiel #1
0
 public static void AddVariableReference(this AstNode node, GeneroAst ast, bool bindNames, object reference)
 {
     if (bindNames)
     {
         ast.SetAttribute(node, VariableReference, reference);
     }
 }
Beispiel #2
0
        //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);
            }
        }
Beispiel #3
0
 /// <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);
     }
 }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
        public static bool IsIncompleteNode(this AstNode node, GeneroAst ast)
        {
            object dummy;

            if (ast.TryGetAttribute(node, NodeAttributes.ErrorIncompleteNode, out dummy))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #7
0
        public static bool IsMissingCloseGrouping(this AstNode node, GeneroAst ast)
        {
            object dummy;

            if (ast.TryGetAttribute(node, NodeAttributes.ErrorMissingCloseGrouping, out dummy))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
        public static bool IsAltForm(this AstNode node, GeneroAst ast)
        {
            object dummy;

            if (ast.TryGetAttribute(node, NodeAttributes.IsAltFormValue, out dummy))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
 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);
         }
     }
 }
Beispiel #13
0
 public static string GetFifthWhiteSpace(this AstNode node, GeneroAst ast)
 {
     return(GetWhiteSpace(node, ast, NodeAttributes.FifthPreceedingWhiteSpace));
 }
Beispiel #14
0
 public SourceSpan GetSpan(GeneroAst parent)
 {
     return(new SourceSpan(GetStart(parent), GetEnd(parent)));
 }
Beispiel #15
0
 public SourceLocation GetEnd(GeneroAst parent)
 {
     return(parent.IndexToLocation(EndIndex));
 }
Beispiel #16
0
 public SourceLocation GetStart(GeneroAst parent)
 {
     return(parent.IndexToLocation(StartIndex));
 }
Beispiel #17
0
 public static string GetFourthWhiteSpaceDefaultNull(this AstNode node, GeneroAst ast)
 {
     return(GetWhiteSpace(node, ast, NodeAttributes.FourthPreceedingWhiteSpace, null));
 }
Beispiel #18
0
 public abstract string GetExpressionType(GeneroAst ast);
Beispiel #19
0
 public override string GetExpressionType(GeneroAst ast)
 {
     // TODO: determine the type from the token we have
     return(null);
 }
Beispiel #20
0
 public static string GetExtraVerbatimText(this AstNode node, GeneroAst ast)
 {
     return(GetWhiteSpace(node, ast, NodeAttributes.ExtraVerbatimText, null));
 }
Beispiel #21
0
 public override string GetExpressionType(GeneroAst ast)
 {
     return("string");
 }