<commit_before>use std::ascii::AsciiExt;
use std::char::from_u32;
use std::num::from_str_radix;

use self::xmlstr::XmlStr;

mod xmlstr;

// TODO: Error handling: should we preserve a hierarchy of what we
// were trying to do?

pub struct Parser;

struct Element<'a> {
    name: &'a str,
    attributes: Vec<Attribute<'a>>,
    children: Vec<Child<'a>>,
}

enum AttributeValue<'a> {
    ReferenceAttributeValue(Reference<'a>),
    LiteralAttributeValue(&'a str),
}

struct Attribute<'a> {
    name: &'a str,
    values: Vec<AttributeValue<'a>>,
}

struct Text<'a> {
    text: &'a str,
}

enum Reference<'a> {
    EntityReference(&'a str),
    DecimalCharReference(&'a str),
    HexCharReference(&'a str),
}

struct Comment<'a> {
    text: &'a str,
}

struct ProcessingInstruction<'a> {
    target: &'a str,
    value: Option<&'a str>,
}

enum RootChild<'a> {
    CommentRootChild(Comment<'a>),
    PIRootChild(ProcessingInstruction<'a>),
    IgnoredRootChild,
}

enum Child<'a> {
    ElementChild(Element<'a>),
    TextChild(Text<'a>),
    ReferenceChild(Reference<'a>),
    CommentChild(Comment<'a>),
    PIChild(ProcessingInstruction<'a>),
}

macro_rules! try_parse(
    ($e:expr) => ({
        match $e {
            Err(e) => return Err(e),
            Ok(x) => x,
        }
    })<commit_msg>Add Show to the intermediate parsing structs<commit_after>use std::ascii::AsciiExt;
use std::char::from_u32;
use std::num::from_str_radix;

use self::xmlstr::XmlStr;

mod xmlstr;

// TODO: Error handling: should we preserve a hierarchy of what we
// were trying to do?

pub struct Parser;

#[deriving(Show)]
struct Element<'a> {
    name: &'a str,
    attributes: Vec<Attribute<'a>>,
    children: Vec<Child<'a>>,
}

#[deriving(Show)]
enum AttributeValue<'a> {
    ReferenceAttributeValue(Reference<'a>),
    LiteralAttributeValue(&'a str),
}

#[deriving(Show)]
struct Attribute<'a> {
    name: &'a str,
    values: Vec<AttributeValue<'a>>,
}

#[deriving(Show)]
struct Text<'a> {
    text: &'a str,
}

#[deriving(Show)]
enum Reference<'a> {
    EntityReference(&'a str),
    DecimalCharReference(&'a str),
    HexCharReference(&'a str),
}

#[deriving(Show)]
struct Comment<'a> {
    text: &'a str,
}

#[deriving(Show)]
struct ProcessingInstruction<'a> {
    target: &'a str,
    value: Option<&'a str>,
}

#[deriving(Show)]
enum RootChild<'a> {
    CommentRootChild(Comment<'a>),
    PIRootChild(ProcessingInstruction<'a>),
    IgnoredRootChild,
}

#[deriving(Show)]
enum Child<'a> {
    ElementChild(Element<'a>),
    TextChild(Text<'a>),
    ReferenceChild(Reference<'a>),
    CommentChild(Comment<'a>),
    PIChild(ProcessingInstruction<'a>),
}

macro_rules! try_parse(
    ($e:expr) => ({
        match $e {
            Err(e) => return Err(e),
            Ok(x) => x,
        }
    })
{'fraction_non_alphanumeric': 0.1741472172351885, 'fraction_numerical': 0.001436265709156194, 'mean_word_length': 3.887719298245614, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2235913', 'n_tokens_mistral': 998, 'n_tokens_neox': 1035, 'n_words': 209}