tagged release 0.7.1
[parrot.git] / languages / cardinal / cardinal.pir
blobd2a5166749bccda26c3f984e69b8174e894318b9
1 =head1 TITLE
3 cardinal.pir - A cardinal compiler.
5 =head2 Description
7 This is the base file for the cardinal compiler.
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'.
13 =head2 Functions
15 =over 4
17 =item onload()
19 Creates the cardinal compiler using a C<PCT::HLLCompiler>
20 object.
22 =cut
25 .namespace []
27 .include 'src/gen_builtins.pir'
29 .sub 'onload' :anon :load :init
30     $P0 = subclass 'ResizablePMCArray', 'List'
31 .end
33 .namespace [ 'List' ]
38 .namespace [ 'cardinal::Compiler' ]
40 .loadlib 'cardinal_group'
42 .sub 'onload' :anon :load :init
43     load_bytecode 'PCT.pbc'
44     .local pmc cardinalmeta
45     cardinalmeta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
46     cardinalmeta.'new_class'('cardinal::Compiler', 'parent'=>'PCT::HLLCompiler')
48     $P0 = get_hll_global ['PCT'], 'HLLCompiler'
49     $P1 = $P0.'new'()
50     $P1.'language'('cardinal')
51     $P1.'parsegrammar'('cardinal::Grammar')
52     $P1.'parseactions'('cardinal::Grammar::Actions')
54     $P1.'commandline_banner'("Cardinal - Ruby for the Parrot VM\n\n")
55     $P1.'commandline_prompt'('crb(main):001:0>')
57      ##  create a list of END blocks to be run
58     $P0 = new 'List'
59     set_hll_global ['cardinal'], '@?END_BLOCKS', $P0
61     $P0 = new 'List'
62     set_hll_global ['cardinal';'Grammar';'Actions'], '@?BLOCK', $P0
64     $P1 = get_hll_global ['PAST::Compiler'], '%valflags'
65     $P1['CardinalString'] = 'e'
66 .end
68 =item main(args :slurpy)  :main
70 Start compilation by passing any command line C<args>
71 to the cardinal compiler.
73 =cut
75 .sub 'main' :main
76     .param pmc args_str
78     ##  create ARGS global.
79     .local pmc args, iter
80     args = new 'CardinalArray'
81     iter = new 'Iterator', args_str
82     $P0 = shift iter
83   args_loop:
84     unless iter goto args_end
85     $P0 = shift iter
86     push args, $P0
87     goto args_loop
88   args_end:
89     set_hll_global 'ARGS', args
91     $P0 = compreg 'cardinal'
92     $P1 = $P0.'command_line'(args_str)
94     .include 'iterator.pasm'
95     $P0 = get_hll_global ['cardinal'], '@?END_BLOCKS'
96     iter = new 'Iterator', $P0
97     iter = .ITERATE_FROM_END
98   iter_loop:
99     unless iter goto iter_end
100     $P0 = pop iter
101     $P0()
102     goto iter_loop
103   iter_end:
104 .end
107 .include 'src/gen_grammar.pir'
108 .include 'src/parser/quote_expression.pir'
109 .include 'src/gen_actions.pir'
113 =back
115 =cut
117 # Local Variables:
118 #   mode: pir
119 #   fill-column: 100
120 # End:
121 # vim: expandtab shiftwidth=4 ft=pir: