Example #1
0
        private List <AstItem> ReadFuncParameters(TokenIterator tokens)
        {
            var result  = new List <AstItem>();
            var current = tokens.Pop();

            while (current.Kind != TokenKind.RoundBracketClose)
            {
                var name = current;
                if (name.Kind != TokenKind.Word)
                {
                    throw new Exception("Expected parameter name, found " + name);
                }

                tokens.PopExpected(TokenKind.TypeOperator);

                var dataType = ReadDataType(tokens);

                result.Add(AstItem.Parameter(name.Value, dataType));

                current = tokens.Pop();
                if (current.Kind == TokenKind.Comma)
                {
                    current = tokens.Pop();
                }
            }
            return(result);
        }