<commit_before>
use pair::Pair;
use error::{NcclError, ErrorKind};
use token::{Token, TokenKind};

pub struct Parser {
    current: usize,
    path: Vec<String>,
    tokens: Vec<Token>,
    pair: Pair,
    line: u64,
}

// nccl = pair+
// pair = value schema? newline key+
// schema = ": " value
// key = indent (pair | value) newline
// value = [^:]+
// newline = "\n" | "\r\n"
// indent = " "+ | "\t"

impl Parser {
    pub fn new(tokens: Vec<Token>) -> Self {
        Parser {
            current: 0,
            path: vec![],
            tokens: tokens,
            pair: Pair::new("__top_level__"),
            line: 1,
        }
    }

    pub fn parse(&mut self) -> Result<Pair, NcclError> {
        while !self.is_at_end() {
            self.value()?;
            if self.peek().kind == TokenKind::Value {
                self.colon()?;
                self.value()?;
            }
            self.newline()?;
            self.indent()?;
            self.value()?;
            self.newline()?;
        }<commit_msg>update ebnf<commit_after>
use pair::Pair;
use error::{NcclError, ErrorKind};
use token::{Token, TokenKind};

pub struct Parser {
    current: usize,
    path: Vec<String>,
    tokens: Vec<Token>,
    pair: Pair,
    line: u64,
}

// nccl = (value newline)+
// value = name schema? newline (key newline)*
// key = indent value
// name = [^:]+
// schema = ": " name
// newline = ("\n" | "\r\n")+
// indent = " "+ | "\t"

impl Parser {
    pub fn new(tokens: Vec<Token>) -> Self {
        Parser {
            current: 0,
            path: vec![],
            tokens: tokens,
            pair: Pair::new("__top_level__"),
            line: 1,
        }
    }

    pub fn parse(&mut self) -> Result<Pair, NcclError> {
        while !self.is_at_end() {
            self.value()?;
            if self.peek().kind == TokenKind::Value {
                self.colon()?;
                self.value()?;
            }
            self.newline()?;
            self.indent()?;
            self.value()?;
            self.newline()?;
        }
{'fraction_non_alphanumeric': 0.17259873232569478, 'fraction_numerical': 0.0039005363237445147, 'mean_word_length': 1.640926640926641, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 15, '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': '4066158', 'n_tokens_mistral': 674, 'n_tokens_neox': 672, 'n_words': 157}