Skip to content

Commit

Permalink
Currently testing under nom.
Browse files Browse the repository at this point in the history
  • Loading branch information
supernovus committed Sep 28, 2011
1 parent a24c11a commit 06da21b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/Exemel.pm
Expand Up @@ -132,11 +132,16 @@ class Exemel::Element does Exemel {
}

method parse-node ($node, $mother?) {
my $name = ~$node<name>;
$*ERR.say: "node: $node";
my $name = $node<name>.Str;
$*ERR.say: "name: $name";
my %attribs;
my @nodes;

$*ERR.say: "attr elems: "~$node<attribute>.elems;

if ($node<attribute>) {
$*ERR.say: "attribute found";
for @($node<attribute>) -> $a {
my $an = ~$a<name>;
%attribs{$an} = ~$a<value>;
Expand All @@ -149,7 +154,12 @@ class Exemel::Element does Exemel {
$parent.parent = $mother;
}

$*ERR.say: $node.caps;#.fmt('%s = %s',"\n");

$*ERR.say: "child elems: "~$node<child>.elems;

if ($node<child>) {
$*ERR.say: "child found";
for @($node<child>) -> $c {
my $child;
if ($c<cdata>) {
Expand Down
3 changes: 1 addition & 2 deletions lib/Exemel/Grammar.pm
Expand Up @@ -39,9 +39,8 @@ rule element {
]
}

## The \s+ below should not be necessary. Remove it once this is fixed in nom.
rule attribute {
\s+ <name> '=' '"' <value>? '"'
<name> '=' '"' <value>? '"'
}

rule child {
Expand Down
1 change: 1 addition & 0 deletions t/02-parser.t
Expand Up @@ -13,6 +13,7 @@ my $xml = Exemel::Document.parse($text);
my $head = '<?xml version="1.0"?>';

is $xml.root.name, 'test', 'root name parsed';
$*ERR.say: "XML: $xml";
is $xml.root.nodes[0].nodes[0], 'The title', 'text node parsed';
is $xml.root.nodes[1].nodes[0].attribs<name>, 'first', 'attribute 1 parsed';
is $xml.root.nodes[1].nodes[1].attribs<name>, 'second', 'attribute 2 parsed';
Expand Down

0 comments on commit 06da21b

Please sign in to comment.