<commit_before>use nom::{alpha,alphanumeric,space};
use std;

pub enum Command {
    Exit,
    Help,
    Load( String ),
    Query( Vec<String>, Vec<Filter> ),
}

pub struct Filter {
    pub field_name: String,
    pub filter_type: String,
    pub value: String,
}

named!(
    pub cmd<Command>,
    alt!(
        exit
      | help
      | load
      | query
    )
);

named!(
    pub exit<Command>,
    chain!(
        tag!("EXIT"),
        || { Command::Exit }
    )
);

named!(
    pub help<Command>,
    chain!(
        tag!("HELP"),
        || { Command::Help }
    )
);

named!(
    pub field_names<Vec<String> >,
    alt!(
        tag!("*") => { |_| Vec::new() }
        | chain! (
            field_name: alpha ~
            field_names: many0!(
                chain!(
                    opt!(space) ~
                    tag!(",") ~
                    opt!(space) ~
                    field_name: alpha,
                    || field_name
                )
            ),
            || {
                let mut rtn_field_names = vec!(std::str::from_utf8(field_name).unwrap().to_string());
                for field_name in field_names {
                    rtn_field_names.push(std::str::from_utf8(field_name).unwrap().to_string());
                }

                rtn_field_names
            }
        )
    )
);<commit_msg>Can return fields with non-alpha characters from SELECT statement - bug fix.<commit_after>use nom::{alphanumeric,space};
use std;

pub enum Command {
    Exit,
    Help,
    Load( String ),
    Query( Vec<String>, Vec<Filter> ),
}

pub struct Filter {
    pub field_name: String,
    pub filter_type: String,
    pub value: String,
}

named!(
    pub cmd<Command>,
    alt!(
        exit
      | help
      | load
      | query
    )
);

named!(
    pub exit<Command>,
    chain!(
        tag!("EXIT"),
        || { Command::Exit }
    )
);

named!(
    pub help<Command>,
    chain!(
        tag!("HELP"),
        || { Command::Help }
    )
);

named!(
    pub field_names<Vec<String> >,
    alt!(
        tag!("*") => { |_| Vec::new() }
        | chain! (
            field_name: id ~
            field_names: many0!(
                chain!(
                    opt!(space) ~
                    tag!(",") ~
                    opt!(space) ~
                    field_name: id,
                    || field_name
                )
            ),
            || {
                let mut rtn_field_names = vec!(field_name);
                for field_name in field_names {
                    rtn_field_names.push(field_name);
                }

                rtn_field_names
            }
        )
    )
);
{'fraction_non_alphanumeric': 0.13579781214635986, 'fraction_numerical': 0.0015088645794039985, 'mean_word_length': 1.3324538258575198, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '2522394', 'n_tokens_mistral': 809, 'n_tokens_neox': 795, 'n_words': 158}