protected bool GetMemberNameAndAssociatedType()
 {
     memberToken = Current.Token;
     if (SkipStructuredDelimiters(memberToken.GetAsDelimiter()))
     {
         memberToken.Invalidate(); return(true);
     }
     memberId = null;
     Context.Entry e = memberToken.GetAsContextEntry();
     if (e != null)
     {
         if (dictionaryAdd == null)
         {
             if (e.IsText())
             {
                 memberId = e.GetText();
             }
             else
             {
                 AddError("unable to parse member (" + e.context.name + ") as member name for " + resultType);
             }
         }
         else
         {
             memberId = e.Resolve(tok, scope);                    // "dictionary member value will be resolved later";
         }
         if (e.tokens == Current.tokens)
         {
             Current.tokenIndex += e.tokenCount - 1;
         }
     }
     else
     {
         memberId = memberToken.GetAsBasicToken();
     }
     if (memberId == null)
     {
         memberToken.index = -1; memberValue = state;
         return(true);
     }
     memberValue = null;
     return(CalculateMemberTypeBasedOnName());
 }
 public override string ToString()
 {
     Context.Entry pce = meta as Context.Entry;
     if (pce != null)
     {
         Delim d = pce.sourceMeta as Delim;
         if (d != null)
         {
             return(d.ToString());
         }
         if (IsValid)
         {
             return(ToString(pce.TextRaw));
         }
         string output = pce.context.name;
         if (pce.IsText())
         {
             output += "(" + pce.GetText() + ")";
         }
         return(output);
     }
     return(Resolve(null, null).ToString());
 }
        protected bool TryGetValue()
        {
            memberValue = null;
            Token  token = Current.Token;
            object meta  = token.meta;

            if (SkipStructuredDelimiters(meta as Delim))
            {
                return(true);
            }
            Context.Entry context = meta as Context.Entry;
            if (context != null)
            {
                bool subContextUsingSameList = context.tokens == Current.tokens;
                if (context.IsText())
                {
                    memberValue = context.GetText();
                }
                else
                {
                    int          index     = Current.tokenIndex;
                    List <Token> parseNext = subContextUsingSameList
                                                        ? Current.tokens.GetRange(index, context.tokenCount)
                                                        : context.tokens;
                    if (memberType == typeof(Expression))
                    {
                        memberValue = new Expression(new List <Token>()
                        {
                            token
                        });
                    }
                    else
                    {
                        if (CodeConvert.IsConvertable(memberType))
                        {
                            //Show.Log(memberId + " :: " + memberValue);
                            memberValue = context.Resolve(tok, scope);
                        }
                        else
                        {
                            //Show.Log(memberId+" : "+memberValue);
                            if (!CodeConvert.TryParseTokens(memberType, parseNext, ref memberValue, scope, tok))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (subContextUsingSameList)
                {
                    Current.tokenIndex += context.tokenCount - 1;                     // -1 because increment happens after this method
                }
                return(true);
            }
            string s = meta as string;

            if (s != null)
            {
                memberValue = token.ToString(s);
                if (!CodeConvert.TryConvert(ref memberValue, memberType))
                {
                    AddError("unable to convert (" + memberValue + ") to type '" + memberType + "'");
                    return(false);
                }
                return(true);
            }
            TokenSubstitution sub = meta as TokenSubstitution;

            if (sub != null)
            {
                memberValue = sub.value;
                if (!memberType.IsAssignableFrom(memberValue.GetType()) && !CodeConvert.TryConvert(ref memberValue, memberType))
                {
                    AddError("unable to convert substitution (" + memberValue + ") to type '" + memberType + "'");
                    return(false);
                }
                return(true);
            }
            AddError("unable to parse token with meta data " + meta);
            return(false);
        }