<commit_before>package parser

import "github.com/hansrodtang/semver"

type parser struct {
	items  chan item // channel of scanned items.
	result node
	ibuf   []item
	pos    int
}

func (p *parser) run() (node, error) {

	return handleRange(p), nil

}

func (p *parser) next() item {
	if p.pos >= len(p.ibuf) {
		i := <-p.items
		p.ibuf = append(p.ibuf, i)
		p.pos++
		return i
	}
	i := p.ibuf[p.pos]
	p.pos++
	return i
}

func (p *parser) backup() {
	p.pos--
}

func Parse(input string) (node, error) {
	_, ch := lex(input)
	p := &parser{ch, nil, []item{}, 0}
	return p.run()

}

func handleOperator(p *parser) nodeComparison {
	var nc nodeComparison
	for {
		i := p.next()

		switch i.typ {
		case itemEOF:
			p.backup()
			return nc
		case itemSet:
			return nc
		case itemRange:
			return nc
		case itemVersion:
			ver, _ := semver.New(i.val)
			nc = nodeComparison{eq, ver}
			return nc
		default:
			v := p.next()
			ver, _ := semver.New(v.val)
			nc = nodeComparison{comparators[i.val], ver}
			return nc
		}
	}
}<commit_msg>Removed cases that the lexer should prevent.<commit_after>package parser

import "github.com/hansrodtang/semver"

type parser struct {
	items  chan item // channel of scanned items.
	result node
	ibuf   []item
	pos    int
}

func (p *parser) run() (node, error) {

	return handleRange(p), nil

}

func (p *parser) next() item {
	if p.pos >= len(p.ibuf) {
		i := <-p.items
		p.ibuf = append(p.ibuf, i)
		p.pos++
		return i
	}
	i := p.ibuf[p.pos]
	p.pos++
	return i
}

func (p *parser) backup() {
	p.pos--
}

func Parse(input string) (node, error) {
	_, ch := lex(input)
	p := &parser{ch, nil, []item{}, 0}
	return p.run()

}

func handleOperator(p *parser) nodeComparison {
	var nc nodeComparison
	for {
		i := p.next()

		switch i.typ {
		case itemVersion:
			ver, _ := semver.New(i.val)
			nc = nodeComparison{eq, ver}
			return nc
		default:
			v := p.next()
			ver, _ := semver.New(v.val)
			nc = nodeComparison{comparators[i.val], ver}
			return nc
		}
	}
}
{'fraction_non_alphanumeric': 0.15396188565697091, 'fraction_numerical': 0.0010030090270812437, 'mean_word_length': 2.927165354330709, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '459233', 'n_tokens_mistral': 880, 'n_tokens_neox': 808, 'n_words': 219}