fn type_(&mut self) -> WeldResult<Type> {
        let mut annotations = Annotations::new();
        self.parse_annotations(&mut annotations)?;

        if !self.peek().signals_type() {
            let name = self.symbol()?.to_string();
            // NOTE: The type field is not used right now, but may be later if we decide
            // to keep type alias information past macro substitution.
            return Ok(Alias(name, Box::new(Unknown)));
        }

        match *self.next() {
            TI8 => Ok(Scalar(ScalarKind::I8)),
            TI16 => Ok(Scalar(ScalarKind::I16)),
            TI32 => Ok(Scalar(ScalarKind::I32)),
            TI64 => Ok(Scalar(ScalarKind::I64)),
            TU8 => Ok(Scalar(ScalarKind::U8)),
            TU16 => Ok(Scalar(ScalarKind::U16)),
            TU32 => Ok(Scalar(ScalarKind::U32)),
            TU64 => Ok(Scalar(ScalarKind::U64)),
            TF32 => Ok(Scalar(ScalarKind::F32)),
            TF64 => Ok(Scalar(ScalarKind::F64)),
            TBool => Ok(Scalar(ScalarKind::Bool)),

            TVec => {
                self.consume(TOpenBracket)?;
                let elem_type = self.type_()?;
                self.consume(TCloseBracket)?;
                Ok(Vector(Box::new(elem_type)))
            }

            TSimd => {
                self.consume(TOpenBracket)?;
                let elem_type = self.type_()?;
                self.consume(TCloseBracket)?;
                if let Scalar(ref kind) = elem_type {
                    Ok(Simd(*kind))
                } else {
                    compile_err!("Expected Scalar type in simd")
                }
            }

            TAppender => {
                self.consume(TOpenBracket)?;
                let elem_type = self.type_()?;
                self.consume(TCloseBracket)?;

                Ok(Builder(Appender(Box::new(elem_type)), annotations))
            }

            TMerger => {
                let elem_type: Type;
                self.consume(TOpenBracket)?;
                elem_type = self.type_()?;
                self.consume(TComma)?;
                let binop = self.commutative_binop_()?;
                self.consume(TCloseBracket)?;

                Ok(Builder(Merger(Box::new(elem_type), binop), annotations))
            }

            TDict => {
                let key_type: Type;
                let value_type: Type;
                self.consume(TOpenBracket)?;
                key_type = self.type_()?;
                self.consume(TComma)?;
                value_type = self.type_()?;
                self.consume(TCloseBracket)?;
                Ok(Dict(Box::new(key_type), Box::new(value_type)))
            }

            TDictMerger => {
                let key_type: Type;
                let value_type: Type;
                self.consume(TOpenBracket)?;
                key_type = self.type_()?;
                self.consume(TComma)?;
                value_type = self.type_()?;
                self.consume(TComma)?;
                let binop = self.commutative_binop_()?;
                self.consume(TCloseBracket)?;
                Ok(Builder(
                    DictMerger(Box::new(key_type), Box::new(value_type), binop),
                    annotations,
                ))
            }

            TGroupMerger => {
                self.consume(TOpenBracket)?;
                let key_type = self.type_()?;
                self.consume(TComma)?;
                let value_type = self.type_()?;
                self.consume(TCloseBracket)?;
                let group_merger = GroupMerger(Box::new(key_type), Box::new(value_type));
                Ok(Builder(group_merger, annotations))
            }

            TVecMerger => {
                let elem_type: Type;
                self.consume(TOpenBracket)?;
                elem_type = self.type_()?;
                self.consume(TComma)?;
                let binop = self.commutative_binop_()?;
                self.consume(TCloseBracket)?;

                Ok(Builder(VecMerger(Box::new(elem_type), binop), annotations))
            }

            TOpenBrace => {
                let mut types: Vec<Type> = Vec::new();
                while *self.peek() != TCloseBrace {
                    let ty = self.type_()?;
                    types.push(ty);
                    if *self.peek() == TComma {
                        self.next();
                    } else if *self.peek() != TCloseBrace {
                        return compile_err!("Expected ',' or '}}'");
                    }
                }
                self.consume(TCloseBrace)?;
                Ok(Struct(types))
            }

            TQuestion => Ok(Unknown),

            ref other => compile_err!("Expected type but got '{}'", other),
        }
    }
Parse a Type starting at the current input position.
weld/src/syntax/parser.rs