Esempio n. 1
0
            private static object ReadMethodCall(SimpleParser parser, object prevData, string name)
            {
                using (var la = parser.LookAround())
                {
                    parser.SkipSpaces();
                    if (parser.ReadChar('('))
                    {
                        var prevType = prevData as Type;

                        if (prevType != null)
                        {
                            var isMethodGroup = prevType.GetMethods(BindingFlags.Static | BindingFlags.Public).Any(m => m.Name == name);
                            if (isMethodGroup)
                            {
                                var paramValues = parser.ReadList <ValueBuilder, INode>(ReadListSeparator);
                                if (paramValues.Count == 1 && paramValues[0] == null)
                                {
                                    paramValues.Clear();
                                }

                                parser.SkipSpaces();
                                if (parser.ReadChar(')'))
                                {
                                    la.Success();
                                    return(new Call {
                                        Type = prevType, Element = null, Name = name, Parameters = paramValues
                                    });
                                }
                            }
                        }
                        else
                        {
                            var prevExecutor = (INode)prevData;
                            var type         = prevData == null ? parser.GlobalType : prevExecutor.Compile(parser.GlobalType);

                            var isMethodGroup = type.GetMethods(BindingFlags.Instance | BindingFlags.Public).Any(m => m.Name == name);
                            if (isMethodGroup)
                            {
                                var paramValues = parser.ReadList <ValueBuilder, INode>(ReadListSeparator);
                                if (paramValues.Count == 1 && paramValues[0] == null)
                                {
                                    paramValues.Clear();
                                }

                                parser.SkipSpaces();
                                if (parser.ReadChar(')'))
                                {
                                    la.Success();
                                    return(new Call {
                                        Element = prevExecutor, Name = name, Parameters = paramValues
                                    });
                                }
                            }
                        }
                    }

                    return(null);
                }
            }
Esempio n. 2
0
            private string ReadName(SimpleParser parser)
            {
                using (var la = parser.LookAround())
                {
                    if (!parser.ReadChar('_') &&
                        !parser.ReadChar(UnicodeCategory.LowercaseLetter) &&
                        !parser.ReadChar(UnicodeCategory.UppercaseLetter))
                    {
                        return(null);
                    }

                    parser.ReadWhileCharOrEof(IsIdentifierChar);

                    la.Success();

                    return(la.Text);
                }
            }