Ejemplo n.º 1
0
 /// <summary>
 /// Create a new method argument.
 /// </summary>
 /// <param name="parent">Method node that defines the method argument.</param>
 /// <param name="token">Identifier token containing the name of the argument.</param>
 protected internal MethodArgumentNode(MethodNode parent, IdentifierToken token)
     : base(token)
 {
     #if DEBUG
     if (parent == null)
         throw new ArgumentNullException("parent");
     #endif
     this.Parent = parent;
 }
Ejemplo n.º 2
0
 protected override MethodDefinition CreateDefinition(InterchangeFormatProcessor processor, ISourceCodeReferenceService sourceCodeService, ISourceCodeReferenceService methodSourceCodeService, MethodNode parseTree)
 {
     return new InstanceMethodDefinition(
         processor.CreateSourceReference(this.ClassName.Value, this.ClassName, sourceCodeService),
         processor.CreateSourceReference(parseTree.Selector, parseTree.SelectorParts[0].StartPosition, parseTree.SelectorParts.Last().StopPosition, sourceCodeService),
         sourceCodeService,
         methodSourceCodeService,
         new AstIntermediateMethodCode(parseTree));
 }
Ejemplo n.º 3
0
 public PrimitiveCallNode(MethodNode parent)
 {
     this.Parent = parent;
     this.ApiParameters = new List<IPrimitiveCallParameterToken>();
 }
Ejemplo n.º 4
0
 public PrimitiveCallNode(MethodNode parent)
 {
     this.Parent        = parent;
     this.ApiParameters = new List <IPrimitiveCallParameterToken>();
 }
Ejemplo n.º 5
0
 protected abstract MethodDefinition CreateDefinition(InterchangeFormatProcessor processor, ISourceCodeReferenceService sourceCodeService, ISourceCodeReferenceService methodSourceCodeService, MethodNode parseTree);
Ejemplo n.º 6
0
        protected virtual PrimitiveCallNode ParseApiCall(MethodNode parent, BinarySelectorToken token)
        {
            PrimitiveCallNode result = new PrimitiveCallNode(parent);
            List<IPrimitiveCallParameterToken> parameters = new List<IPrimitiveCallParameterToken>();

            Token apiConvention = this.GetNextTokenxx(Preference.Default);
            if (!(apiConvention is KeywordToken))
                this.ReportParserError(result, SemanticErrors.MissingApiConvention, apiConvention);

            while(true)
            {
                Token tkn = this.GetNextTokenxx(Preference.Default);
                if (tkn is IPrimitiveCallParameterToken)
                {
                    parameters.Add((IPrimitiveCallParameterToken)tkn);
                }
                else if (Parser.IsApiClosingDelimiter(tkn))
                {

                    result.SetContents(token, tkn as BinarySelectorToken, apiConvention as KeywordToken, parameters);
                    return result;
                }
                else
                {
                    this.ReportParserError(result, SemanticErrors.UnexpectedApiParameterToken, tkn);
                    this.ResidueToken = tkn;

                    result.SetContents(token, tkn as BinarySelectorToken, apiConvention as KeywordToken, parameters);
                    return result;
                }
            }
        }
Ejemplo n.º 7
0
 protected virtual MethodArgumentNode ParseMethodArgument(MethodNode parent, Token token)
 {
     // PARSE: identifier      ... NB: X3J20 bug - definition missing ... but this one is easy.
     if (!(token is IdentifierToken))
     {
         this.ReportParserError(parent, SemanticErrors.MissingMethodArgument, token);
         this.ResidueToken = token;
         // NB: MethodArgumentNode must be able to handle null for arg. name token.
         return new MethodArgumentNode(parent, null);
     }
     return new MethodArgumentNode(parent, (IdentifierToken)token);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Parse the method message pattern.
        /// </summary>
        protected virtual MethodNode ParseMessagePattern()
        {
            // PARSE: <message pattern> ::= <unary pattern> | <binary pattern> | <keyword pattern>
            //      <unary pattern> ::= unarySelector
            //      <binary pattern> ::= binarySelector <method argument>
            //      <keyword pattern> ::= (keyword <method argument>)+
            MethodNode result = new MethodNode();
            List<IMethodSelectorToken> selectorParts = new List<IMethodSelectorToken>();
            List<MethodArgumentNode> arguments = new List<MethodArgumentNode>();

            Token token = this.GetNextTokenxx(Preference.Default);

            // PARSE: <message pattern> ::= <unary pattern> | <binary pattern> | <keyword pattern>
            if (token is KeywordToken)
            {
                // <keyword pattern> ::= (keyword <method argument>)+
                selectorParts.Add((IMethodSelectorToken)token);
                token = this.GetNextTokenxx(Preference.Default);
                arguments.Add(this.ParseMethodArgument(result, token));
                while (true)
                {
                    token = this.GetNextTokenxx(Preference.VerticalBar | Preference.NegativeSign);
                    if (token is KeywordToken)
                    {
                        selectorParts.Add((IMethodSelectorToken)token);
                        token = this.GetNextTokenxx(Preference.Default);
                        arguments.Add(this.ParseMethodArgument(result, token));
                    }
                    else
                    {
                        result.SetContents(selectorParts, arguments);
                        this.ResidueToken = token; // temp vars or statement
                        return result;
                    }
                }
            }
            else if (token is BinarySelectorToken)
            {
                //  <binary pattern> ::= binarySelector <method argument>
                selectorParts.Add((IMethodSelectorToken)token);
                token = this.GetNextTokenxx(Preference.Default);
                arguments.Add(this.ParseMethodArgument(result, token));
                result.SetContents(selectorParts, arguments);
                return result;
            }
            else if (token is IdentifierToken)
            {
                //  <unary pattern> ::= unarySelector
                selectorParts.Add((IMethodSelectorToken)token);
                result.SetContents(selectorParts, arguments);
                return result;
            }
            else
            {
                this.ReportParserError(result, SemanticErrors.MissingMethodMessagePattern, token);
                this.ResidueToken = token;
                return result;
            }
        }