The compiler almost work.
[artemus.git] / art5
blob022cdf857c854049d7a49bb235e2fbf4e93d0d63
1 #!/usr/bin/perl
3 use Artemus5;
5 my $a = Artemus5->new();
7 #my $src = join('', <>);
9 #print $a->process($src);
11 # <a href = http://host?t=<{$0}>;offset=0><{or $1 "Main index"}></a>
13 my $url = [ '?',
14 [ '"', '<a href = http://host/?t=' ],
15 [ '$', 0 ],
16 [ '"', ';offset='],
17 [ 'or',
18 [ '$', 2 ],
19 [ '"', 0 ],
21 [ '"', '>'],
22 [ 'or',
23 [ '$', 1 ],
24 [ '"', 'Main index' ],
26 [ '"', '</a>' ]
29 $a->{op}->{url} = $url;
31 # navigator
32 # <span class = 'prev'><{
33 # if $2
34 # {?
35 # "<a href = "
36 # {url "INDEX" "topic" $0 "offset" {sub $2 $1}}
37 # ">&lt;&lt;</a>"
38 # }
39 #}></span>
41 # <html>\n<{url 'LOGIN' 'Login page'}>\n<{url 'INDEX'}></html>
43 my $p = [ '?',
44 [ '"', "<html>\n" ],
45 [ 'url', [ '"', 'LOGIN'], ['"', 'Login page'], ['"', 10 ]],
46 [ '"', "\n" ],
47 [ 'url', [ '"', 'INDEX'] ],
48 [ '"', "\n</html>" ]
51 print $a->exec($p), "\n";
53 use Data::Dumper;
55 my $c;
56 $c = $a->compile("Leading <{%arch}> Trailing");
57 print $a->exec($c), "\n";
58 $c = $a->compile("Leading <{? 'Arch: ' %arch}> Trailing");
59 print $a->exec($c), "\n";
60 $c = $a->compile("Leading <{mul {add 10 20} 1000}> Trailing");
61 print $a->exec($c), "\n";
62 $c = $a->compile("Leading <{? {= 'TEST' 'here'} { TEST }}> Trailing");
63 print $a->exec($c), "\n";
64 $c = $a->compile("Leading <{if {eq 1 2} 'Equal' 'Different'}> Trailing");
65 print $a->exec($c), "\n";
66 $c = $a->compile("Leading <{if {eq 1 1} 'Equal' 'Different'}> Trailing");
67 print $a->exec($c), "\n";
68 $c = $a->compile("Leading <{if {eq 1 2} {'Equal'} {'Different'}}> Trailing");
69 print $a->exec($c), "\n";
70 $c = $a->compile("Leading <{if {eq 1 1} {'Equal'} {'Different'}}> Trailing");
71 print $a->exec($c), "\n";
73 exit 0;