/** * Parse a file. * * - Extract DocBlocks. * - Tokkenize DocBlocks. * * @protected * @method parseFile * @param \LADoc\Builder\Files\File $file */ protected function parseFile(File $file) { // Reset parser properties. $this->inDocBlock = false; $this->line = null; $this->docBlock = null; $this->docBlocks = []; // For each line. foreach ($file->getLines() as $num => $contents) { // Create/Set current line instance. $this->line = new Line($num, $contents, $this->inDocBlock); // If the line start a DocBlock. if ($this->line->isType('docBlockStart')) { // Set we are in a DocBlock. $this->inDocBlock = true; // Create new DocBlock instance. $this->docBlock = new DocBlock($file); // Set the line start number. $this->docBlock->setLineNumber('from', $num); // Go to next line. continue; } // If the line end a DocBlock. if ($this->line->isType('docBlockEnd')) { // Validate the DocBlock. // Set the line end number. $this->docBlock->setLineNumber('to', $num); // Register the DocBlock. $this->docBlocks[] = $this->docBlock; // Set we are not in a DocBlock. $this->inDocBlock = false; // Go to next line. continue; } // If the line is in a DocBlock. if ($this->line->isType('docBlockData')) { // Parse DocBlock line. // Go to next line. continue; } // If the line is a single line comment. if ($this->line->isType('singleLineComment')) { // Parse comment line. // Add the comment line to last DocBlock. // Go to next line. continue; } } }