Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 72 lines (56 sloc) 1.744 kb
6fa8ed1 @masak [Hitomi::Markup] working on passing 06-markup
authored
1 use Hitomi::XMLParser;
2
3 class Hitomi::Template {
4 has $!source;
5 has $!filepath;
6 has $!filename;
7 has $!loader;
8 has $!encoding;
9 has $!lookup;
10 has $!allow_exec;
11 has $!stream;
12
13 submethod BUILD(:$source, :$filepath, :$filename, :$loader,
14 :$encoding, :$lookup, :$allow_exec) {
15
16 $!source = $source;
17 $!filepath = $filepath;
18 $!filename = $filename;
19 $!loader = $loader;
20 $!encoding = $encoding;
21 $!loader = $loader;
22 $!allow_exec = $allow_exec;
23
24 $!filepath //= $!filename;
25
26 $!stream = self._parse($!source, $!encoding);
27 }
28
29 method new($source, $filepath?, $filename?, $loader?,
30 $encoding?, $lookup = 'strict', $allow_exec = True) {
31 self.bless(*,
32 :$source, :$filepath, :$filename, :$loader,
33 :$encoding, :$lookup, :$allow_exec);
34 }
35
36 method _parse($source, $encoding) {
37 ...
38 }
39
b4e82ea @masak [t/hitomi] new test file 06-markup.t
authored
40 method generate(*%nameds, *@pairs) {
6fa8ed1 @masak [Hitomi::Markup] working on passing 06-markup
authored
41 return $!stream;
42 }
43 }
44
45 class Hitomi::MarkupTemplate is Hitomi::Template {
46 submethod BUILD(:$!source, :$!filepath, :$!filename, :$!loader,
47 :$!encoding, :$!lookup, :$!allow_exec) {
48 }
49
50 method _parse($source is copy, $encoding) {
51 if $source !~~ Hitomi::Stream {
52 $source = Hitomi::XMLParser.new($source, $!filename, $encoding);
53 }
54
55 my @stream;
56
57 for $source.llist -> @event {
58 my ($kind, $data, $pos) = @event;
59
60 @stream.push( [$kind, $data, $pos] );
61 }
62
63 return Hitomi::Stream.new(@stream);
b4e82ea @masak [t/hitomi] new test file 06-markup.t
authored
64 }
65 }
66
67 class Hitomi::Markup {
68 method new($text) {
69 return self.bless(*, :$text);
70 }
71 }
Something went wrong with that request. Please try again.