Exakat\Tasks\Load::checkTokens PHP Метод

checkTokens() приватный Метод

private checkTokens ( $filename )
    private function checkTokens($filename)
    {
        if (count($this->expressions) > 0) {
            print "Warning : expression is not empty in {$filename}\n";
            print_r($this->expressions);
            foreach ($this->expressions as $atomId) {
                print_r($this->atoms[$atomId]);
            }
        }
        if ($this->contexts[self::CONTEXT_NOSEQUENCE] > 0) {
            print "Warning : context for sequence is not back to 0 in {$filename} : it is " . $this->contexts[self::CONTEXT_NOSEQUENCE] . "\n";
        }
        // All node has one incoming or one outgoing link (outgoing or incoming).
        $O = $D = array();
        foreach ($this->links as $label => $origins) {
            foreach ($origins as $origin => $destinations) {
                foreach ($destinations as $destination => $links) {
                    foreach ($links as $link) {
                        $O[] = $link['origin'];
                        $D[] = $link['destination'];
                    }
                }
            }
        }
        $O = array_count_values($O);
        $D = array_count_values($D);
        $total = 0;
        foreach ($this->atoms as $id => $atom) {
            if ($id === 1) {
                continue;
            }
            if (!isset($D[$id])) {
                print "Warning : forgotten atom {$id} in {$this->filename} : \n";
                print_r($atom);
                print "\n";
                ++$total;
            } elseif ($D[$id] > 1) {
                print "Warning : too linked atom {$id} : \n";
                print_r($atom);
                print "\n";
                ++$total;
            }
            if (!isset($atom['line'])) {
                print "Warning : missing line atom {$id} : \n";
                print_r($atom);
                print "\n";
                ++$total;
            }
            if (!isset($atom['code'])) {
                print "Warning : code atom {$id} : \n";
                print_r($atom);
                print "\n";
                ++$total;
            }
            if (!isset($atom['token'])) {
                print "Warning : token atom {$id} : \n";
                print_r($atom);
                print "\n";
                ++$total;
            }
        }
        if ($total > 0) {
            print $total . " errors found\n";
        }
    }
Load