<commit_before><?php

namespace Behat\Gherkin;

use Behat\Gherkin\Exception\Exception,
    Behat\Gherkin\Node;

class Parser
{
    private $file;
    private $lexer;

    /**
     * Initialize Parser.
     * 
     * @param   Lexer   $lexer  lexer instance
     */
    public function __construct(Lexer $lexer)
    {
        $this->lexer = $lexer;
    }

    /**
     * Parse input & return features array.
     * 
     * @param   string          $input  Gherkin filename or string document
     *
     * @return  array           array of feature nodes
     */
    public function parse($input)
    {
        $features = array();

        if (is_file($input)) {
            $this->file = $input;
            $input      = file_get_contents($this->file);
        } else {
            $this->file = null;
        }

        $this->lexer->setInput($input);
        $this->lexer->setLanguage($language = 'en');
        $languageSpecifiedOnLine = null;

        while ('EOS' !== $this->predictTokenType()) {
            if ('Newline' === $this->predictTokenType()
             || 'Comment' === $this->predictTokenType()) {
                $this->lexer->getAdvancedToken();
            } elseif ('Language' === $this->predictTokenType()) {
                $language = $this->expectTokenType('Language')->value;

                if (null === $languageSpecifiedOnLine) {
                    // Reparse input with new language
                    $languageSpecifiedOnLine = $this->lexer->getCurrentLine();
                    $this->lexer->setInput($input);
                    $this->lexer->setLanguage($language);
                } elseif ($languageSpecifiedOnLine !== $this->lexer->getCurrentLine()) {
                    // Language already specified
                    throw new Exception(sprintf('Ambigious language specifiers on lines: %d and %d%s',
                        $languageSpecifiedOnLine, $this->lexer->getCurrentLine(),<commit_msg>refactored varname<commit_after><?php

namespace Behat\Gherkin;

use Behat\Gherkin\Exception\Exception,
    Behat\Gherkin\Node;

class Parser
{
    private $file;
    private $lexer;

    /**
     * Initialize Parser.
     * 
     * @param   Lexer   $lexer  lexer instance
     */
    public function __construct(Lexer $lexer)
    {
        $this->lexer = $lexer;
    }

    /**
     * Parse input & return features array.
     * 
     * @param   string          $input  Gherkin filename or string document
     *
     * @return  array           array of feature nodes
     */
    public function parse($input)
    {
        $features = array();

        if (is_file($input)) {
            $this->file = $input;
            $input      = file_get_contents($this->file);
        } else {
            $this->file = null;
        }

        $this->lexer->setInput($input);
        $this->lexer->setLanguage($language = 'en');
        $languageSpecifierLine = null;

        while ('EOS' !== $this->predictTokenType()) {
            if ('Newline' === $this->predictTokenType()
             || 'Comment' === $this->predictTokenType()) {
                $this->lexer->getAdvancedToken();
            } elseif ('Language' === $this->predictTokenType()) {
                $language = $this->expectTokenType('Language')->value;

                if (null === $languageSpecifierLine) {
                    // Reparse input with new language
                    $languageSpecifierLine = $this->lexer->getCurrentLine();
                    $this->lexer->setInput($input);
                    $this->lexer->setLanguage($language);
                } elseif ($languageSpecifierLine !== $this->lexer->getCurrentLine()) {
                    // Language already specified
                    throw new Exception(sprintf('Ambigious language specifiers on lines: %d and %d%s',
                        $languageSpecifierLine, $this->lexer->getCurrentLine(),
{'fraction_non_alphanumeric': 0.13515604849110135, 'fraction_numerical': 0.0, 'mean_word_length': 1.843108504398827, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5654282', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1047, 'n_words': 214}