Ejemplo n.º 1
0
 /**
  * Creates constraint object from tokens.
  * <p>
  * If parameter $constraintName is not passed then current position should point to the name of the constraint.
  *
  * @param Tokenizer $tokenizer Tokens collection.
  * @param string $constraintName Optional name of the constraint.
  *
  * @return Constraint
  */
 public static function create(Tokenizer $tokenizer, $constraintName = '')
 {
     if ($constraintName === false) {
         $constraintName = '';
     } elseif (!$constraintName) {
         $constraintName = $tokenizer->getCurrentToken()->text;
         $tokenizer->nextToken();
         $tokenizer->skipWhiteSpace();
     }
     $constraint = new self($constraintName);
     $token = $tokenizer->getCurrentToken();
     $level = $token->level;
     $constraintDefinition = '';
     do {
         if ($token->level == $level && $token->text == ',') {
             break;
         }
         if ($token->level < $level && $token->text == ')') {
             break;
         }
         $constraintDefinition .= $token->text;
         $token = $tokenizer->nextToken();
     } while (!$tokenizer->endOfInput());
     $constraint->setBody($constraintDefinition);
     return $constraint;
 }
Ejemplo n.º 2
0
 /**
  * Creates sequence object from tokens.
  * <p>
  * Current position should point to the name of the sequence.
  *
  * @param Tokenizer $tokenizer Tokens collection.
  *
  * @return Sequence
  */
 public static function create(Tokenizer $tokenizer)
 {
     $name = $tokenizer->getCurrentToken()->text;
     $sequence = new self($name);
     $tokenizer->resetState();
     $definition = '';
     while (!$tokenizer->endOfInput()) {
         $definition .= $tokenizer->getCurrentToken()->text;
         $tokenizer->nextToken();
     }
     $sequence->setBody($definition);
     return $sequence;
 }
Ejemplo n.º 3
0
 /**
  * Creates stored procedure object from tokens.
  * <p>
  * Current position should point to the type of the stored procedure (PROCEDURE, FUNCTION or TYPE).
  * <p>
  * Name may consist of two parts divided by '.'.
  *
  * @param Tokenizer $tokenizer Tokens collection.
  *
  * @return Procedure
  */
 public static function create(Tokenizer $tokenizer)
 {
     $type = $tokenizer->getCurrentToken()->text;
     $tokenizer->nextToken();
     $tokenizer->skipWhiteSpace();
     $name = $tokenizer->getCurrentToken()->text;
     $token = $tokenizer->nextToken();
     if ($token->text === '.') {
         $token = $tokenizer->nextToken();
         $name .= '.' . $token->text;
     }
     $procedure = new self($name, $type);
     $tokenizer->resetState();
     $definition = '';
     while (!$tokenizer->endOfInput()) {
         $definition .= $tokenizer->getCurrentToken()->text;
         $tokenizer->nextToken();
     }
     $procedure->setBody($definition);
     return $procedure;
 }