Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 100 lines (63 sloc) 1.802 kB
5bb360e @tewk Cardinal restart
tewk authored
1 =head1 TITLE
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
2
5bb360e @tewk Cardinal restart
tewk authored
3 cardinal.pir - A cardinal compiler.
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
4
5bb360e @tewk Cardinal restart
tewk authored
5 =head2 Description
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
6
5bb360e @tewk Cardinal restart
tewk authored
7 This is the base file for the cardinal compiler.
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
8
5bb360e @tewk Cardinal restart
tewk authored
9 This file includes the parsing and grammar rules from
10 the src/ directory, loads the relevant PGE libraries,
11 and registers the compiler under the name 'cardinal'.
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
12
5bb360e @tewk Cardinal restart
tewk authored
13 =head2 Functions
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
14
5bb360e @tewk Cardinal restart
tewk authored
15 =over 4
06b8a84 @tewk [Cardinal] refactor to follow Perl6 AST/OST example
tewk authored
16
5bb360e @tewk Cardinal restart
tewk authored
17 =item onload()
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
18
5bb360e @tewk Cardinal restart
tewk authored
19 Creates the cardinal compiler using a C<PCT::HLLCompiler>
20 object.
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
21
5bb360e @tewk Cardinal restart
tewk authored
22 =cut
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
23
5183792 @kjs [cardinal]
kjs authored
24
25 .namespace
26
27 .sub 'onload' :anon :load :init
28 $P0 = subclass 'ResizablePMCArray', 'List'
29 .end
30
31 .namespace [ 'List' ]
32
33
34
35
5bb360e @tewk Cardinal restart
tewk authored
36 .namespace [ 'cardinal::Compiler' ]
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
37
5bb360e @tewk Cardinal restart
tewk authored
38 .loadlib 'cardinal_group'
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
39
5bb360e @tewk Cardinal restart
tewk authored
40 .sub 'onload' :anon :load :init
41 load_bytecode 'PCT.pbc'
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
42
5bb360e @tewk Cardinal restart
tewk authored
43 $P0 = get_hll_global ['PCT'], 'HLLCompiler'
44 $P1 = $P0.'new'()
45 $P1.'language'('cardinal')
46 $P1.'parsegrammar'('cardinal::Grammar')
47 $P1.'parseactions'('cardinal::Grammar::Actions')
5183792 @kjs [cardinal]
kjs authored
48
65e2272 @kjs [cardinal] add 'and' and 'or' operators.
kjs authored
49 $P1.'commandline_banner'("Cardinal - Ruby for the Parrot VM\n\n")
50 $P1.'commandline_prompt'('irb(main):001:0>')
51
5183792 @kjs [cardinal]
kjs authored
52 ## create a list of END blocks to be run
53 $P0 = new 'List'
54 set_hll_global ['cardinal'], '@?END_BLOCKS', $P0
362250e @tewk [Cardinal] Closer to support for classes, blocking on .HLL bug
tewk authored
55 .end
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
56
5bb360e @tewk Cardinal restart
tewk authored
57 =item main(args :slurpy) :main
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
58
5bb360e @tewk Cardinal restart
tewk authored
59 Start compilation by passing any command line C<args>
60 to the cardinal compiler.
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
61
5bb360e @tewk Cardinal restart
tewk authored
62 =cut
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
63
5bb360e @tewk Cardinal restart
tewk authored
64 .sub 'main' :main
65 .param pmc args
4cfaaf2 @tewk Cleanup and refactor for class support
tewk authored
66
5bb360e @tewk Cardinal restart
tewk authored
67 $P0 = compreg 'cardinal'
68 $P1 = $P0.'command_line'(args)
5183792 @kjs [cardinal]
kjs authored
69
70 .include 'iterator.pasm'
71 .local pmc iter
72 $P0 = get_hll_global ['cardinal'], '@?END_BLOCKS'
73 iter = new 'Iterator', $P0
74 iter = .ITERATE_FROM_END
75 iter_loop:
76 unless iter goto iter_end
77 $P0 = pop iter
78 $P0()
79 goto iter_loop
80 iter_end:
4cfaaf2 @tewk Cleanup and refactor for class support
tewk authored
81 .end
82
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
83
5bb360e @tewk Cardinal restart
tewk authored
84 .include 'src/gen_builtins.pir'
85 .include 'src/gen_grammar.pir'
86 .include 'src/gen_actions.pir'
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
87
5183792 @kjs [cardinal]
kjs authored
88
89
5bb360e @tewk Cardinal restart
tewk authored
90 =back
272b0b9 @tewk languages/cardinal Initial checkin
tewk authored
91
92 =cut
9af6817 @paultcochrane [cardinal] Added emacs/vim coda as per coding standards
paultcochrane authored
93
94 # Local Variables:
95 # mode: pir
96 # fill-column: 100
97 # End:
a5fb08e @coke [codingstd]
coke authored
98 # vim: expandtab shiftwidth=4 ft=pir:
5bb360e @tewk Cardinal restart
tewk authored
99
Something went wrong with that request. Please try again.