Example #1
0
        /// <summary>
        /// fun_arg                                     = identifier ":" [ "ref" ] type
        /// </summary>
        private FunctionArgument parseFunSingleArg(bool required = false)
        {
            if (!peek(LexemType.Identifier))
                return null;

            var node = new FunctionArgument();
            node.Name = getValue();

            if (!check(LexemType.Colon))
            {
                if (required)
                    error(ParserMessages.SymbolExpected, ":");
                else
                    return null;
            }

            node.IsRefArgument = check(LexemType.Ref);
            node.TypeSignature = ensure(parseType, ParserMessages.ArgTypeExpected);

            return node;
        }
Example #2
0
        /// <summary>
        /// fun_arg                                     = identifier [ ":" [ "ref" ] type [ "... " ] ]
        /// </summary>
        private FunctionArgument parseFunSingleArg(bool required = false)
        {
            if (!peek(LexemType.Identifier))
                return null;

            var node = new FunctionArgument();
            node.Name = getValue();

            if (!check(LexemType.Colon))
            {
                if (required)
                    error(ParserMessages.SymbolExpected, ":");

                node.Type = typeof (UnspecifiedType);
                return node;
            }

            node.IsRefArgument = check(LexemType.Ref);
            node.TypeSignature = ensure(parseType, ParserMessages.ArgTypeExpected);

            if (check(LexemType.Ellipsis))
            {
                if(node.IsRefArgument)
                    error(ParserMessages.VariadicByRef);

                node.IsVariadic = true;
            }

            return node;
        }
Example #3
0
 protected bool Equals(FunctionArgument other)
 {
     return(string.Equals(Name, other.Name) && string.Equals(TypeSignature, other.TypeSignature));
 }
Example #4
0
 protected bool Equals(FunctionArgument other)
 {
     return string.Equals(Name, other.Name) && string.Equals(TypeSignature, other.TypeSignature);
 }