AjTalk.Model.ModelParser.ParseMethod C# (CSharp) Méthode

ParseMethod() public méthode

public ParseMethod ( ) : MethodModel
Résultat MethodModel
        public MethodModel ParseMethod()
        {
            string name = this.ParseNameOrOperator();
            string selector;
            IList<string> parameterNames = new List<string>();
            IList<string> localVariables = new List<string>();

            if (IsUnarySelector(name))
                selector = name;
            else if (IsBinarySelector(name))
            {
                selector = name;
                parameterNames.Add(this.ParseSimpleName());
            }
            else
            {
                selector = name;

                parameterNames.Add(this.ParseSimpleName());

                name = this.TryParseMultipleKeywordSelector();

                while (name != null)
                {
                    selector += name;
                    parameterNames.Add(this.ParseSimpleName());
                    name = this.TryParseMultipleKeywordSelector();
                }
            }

            if (this.TryParseBar())
            {
                string varname;

                while ((varname = this.TryParseSimpleName()) != null)
                {
                    localVariables.Add(varname);
                }

                this.ParseBar();
            }

            IEnumerable<IExpression> body = this.ParseExpressions();

            MethodModel model = new MethodModel(selector, parameterNames, localVariables, body, this.@class, this.isClassMethod);

            Token token = this.NextToken();

            if (token != null)
                throw new ParserException(string.Format("Unexpected '{0}'", token.Value));

            return model;
        }

Same methods

ModelParser::ParseMethod ( ClassModel @class, bool isClassMethod ) : MethodModel

Usage Example

Exemple #1
0
 public Method CompileInstanceMethod(string text, IBehavior cls)
 {
     ModelParser parser = new ModelParser(text);
     var methodmodel = parser.ParseMethod();
     Method method = new Method(cls, methodmodel.Selector, text);
     BytecodeCompiler compiler = new BytecodeCompiler(method);
     compiler.CompileMethod(methodmodel);
     return method;
 }
All Usage Examples Of AjTalk.Model.ModelParser::ParseMethod