<commit_before>import CheddarPrimitive from './primitive';
import * as CheddarError from '../consts/err';
import {REGEX_DELIMITER, REGEX_ESCAPE, REGEX_FLAGS} from '../consts/chars';

export default class CheddarRegexToken extends CheddarPrimitive {
    exec() {

        this.open();

        if (this.getChar() === REGEX_DELIMITER) {
            let loc = this.Index - 1;
            // in a string

            let chr;

            while ((chr = this.getChar())) {
                if (chr === REGEX_DELIMITER) {
                    break;
                } else if (this.isLast) {
                    this.Index = loc;
                    return this.error(CheddarError.UNMATCHED_DELIMITER);
                } else if (chr === REGEX_ESCAPE) {
                    this.addToken(REGEX_ESCAPE + this.getChar());
                } else {
                    this.addToken(chr);
                }
            }

            // Match flags
            this.newToken(); // Flag to store token
            while (REGEX_FLAGS.indexOf(this.Code[this.Index]) > -1) {
                this.addToken(this.Code[this.Index++]);
            }

            return this.close();

        } else {
            return this.error(CheddarError.EXIT_NOTFOUND);
        }
    }<commit_msg>hotfix [comment]: Fixed ambiguity between comments & regexes<commit_after>import CheddarPrimitive from './primitive';
import * as CheddarError from '../consts/err';
import {REGEX_DELIMITER, REGEX_ESCAPE, REGEX_FLAGS} from '../consts/chars';

export default class CheddarRegexToken extends CheddarPrimitive {
    exec() {

        this.open();

        if (this.getChar() === REGEX_DELIMITER) {
            let loc = this.Index - 1;
            // in a regex
            if ('*/'.includes(this.Code[this.Index])) return CheddarError.EXIT_NOTFOUND;

            let chr;

            while ((chr = this.getChar())) {
                if (chr === REGEX_DELIMITER) {
                    break;
                } else if (this.isLast) {
                    this.Index = loc;
                    return this.error(CheddarError.UNMATCHED_DELIMITER);
                } else if (chr === REGEX_ESCAPE) {
                    this.addToken(REGEX_ESCAPE + this.getChar());
                } else {
                    this.addToken(chr);
                }
            }

            // Match flags
            this.newToken(); // Flag to store token
            while (REGEX_FLAGS.indexOf(this.Code[this.Index]) > -1) {
                this.addToken(this.Code[this.Index++]);
            }

            return this.close();

        } else {
            return this.error(CheddarError.EXIT_NOTFOUND);
        }
    }
{'fraction_non_alphanumeric': 0.11727238666167104, 'fraction_numerical': 0.0014986886474334957, 'mean_word_length': 1.5023430178069352, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4989903', 'n_tokens_mistral': 782, 'n_tokens_neox': 745, 'n_words': 156}