function get_type() { // reserved[(token ...)>] [SIGNED|UNSIGNED] [ZEROFILL] [BINARY|ASCII|UNICODE] [{CHARACTER SET|CHARSET} ident] [COLLATE ident] $type = Modyllic_Type::create($this->get_reserved()); if ($this->peek_next()->value() == '(') { $this->get_symbol(); if ($type instanceof Modyllic_Type_Numeric) { $args = $this->get_array(); $type->length = $args[0]; if (count($args) > 1) { $type->scale = $args[1]; } } else { if ($type instanceof Modyllic_Type_Float) { $args = $this->get_array(); $type->length = $args[0]; if (count($args) > 1) { $type->decimals = $args[1]; } } else { if ($type instanceof Modyllic_Type_Compound) { $type->values = $this->get_array(); } else { $type->length = $this->get_list(); if ($type instanceof Modyllic_Type_VarChar and $type->length > 65535) { $type = new Modyllic_Type_Text($type->name, $type->length); } else { if ($type instanceof Modyllic_Type_VarBinary and $type->length > 65535) { $type = new Modyllic_Type_Blob($type->name, $type->length); } } } } } } $binary = false; while ($this->peek_next() instanceof Modyllic_Token_Reserved) { if (in_array($this->peek_next()->token(), array('SIGNED', 'UNSIGNED', 'ZEROFILL', 'ASCII', 'UNICODE', 'BINARY'))) { switch ($this->get_reserved()) { case 'SIGNED': $type->unsigned = false; break; case 'UNSIGNED': $type->unsigned = true; break; case 'ZEROFILL': $type->zerofill = true; $type->unsigned = true; break; case 'ASCII': $type->charset('latin1'); $type->collate('latin1_general_ci'); break; case 'UNICODE': $type->charset('ucs2'); $type->collate('ucs2_general_ci'); break; case 'BINARY': $binary = true; break; } } else { if (in_array($this->peek_next()->token(), array('CHARACTER SET', 'CHARSET'))) { $this->get_reserved(); $new = $this->get_ident(); if (isset($type->charset) and isset($type->collate)) { $type->collate = $this->updated_collate($type->charset, $new, $type->collate); } $type->charset($new); } else { if ($this->peek_next()->token() == 'COLLATE') { $this->get_reserved(); $type->collate($this->get_ident()); } else { break; } } } } if (($type instanceof Modyllic_Type_VarChar or $type instanceof Modyllic_Type_Text) and strtolower($type->charset()) == 'binary') { $type = $type->binary(); } else { if ($binary) { $type->collate($type->charset() . "_bin"); } } if (!$type->is_valid()) { # throw $this->error( "Syntax error in type declaration of ".$type->to_sql() ); } return $type; }