Beispiel #1
0
        public SherlockParser()
        {
            //File.WriteAllText(".\\DotGraph",state.StateMachine.ToDotGraph());
            Type thisType = GetType();

            try
            {
                foreach (var method in thisType.GetMethods(BindingFlags.Instance & BindingFlags.NonPublic))
                {
                    foreach (var attribute in method.CustomAttributes)
                    {
                        if (attribute.AttributeType.Name == "SherlockHandlerAttribute")
                        {
                            SherlockTokenType type = (SherlockTokenType)attribute.NamedArguments.Single().TypedValue.Value;
                            Debug.Assert(!mapTokenHandler.ContainsKey(type));

                            mapTokenHandler[(SherlockTokenType)attribute.NamedArguments.Single().TypedValue.Value]
                                = (Func <ASTNode, SherlockToken, ASTNode>)method.CreateDelegate(typeof(Func <ASTNode, SherlockToken, ASTNode>), this);
                        }
                    }
                }
            }
            catch (Exception)
            {
                Debug.Assert(false);
            }
        }
Beispiel #2
0
 public SherlockHandlerAttribute(SherlockTokenType type)
 {
     Type = type;
 }
Beispiel #3
0
 internal SherlockToken(string value, SherlockTokenType tokenType, int column)
 {
     this.value     = value;
     this.tokenType = tokenType;
     this.column    = column;
 }