3 nqp.pir - A nqp compiler.
7 This is the base file for the nqp 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 'nqp'.
19 Creates the nqp compiler using a C<PCT::HLLCompiler>
24 .namespace [ 'NQP::Compiler' ]
28 .sub 'onload' :anon :load :init
29 load_bytecode 'PCT.pbc'
31 $P0 = get_hll_global ['PCT'], 'HLLCompiler'
34 $P1.'parsegrammar'('NQP::Grammar')
35 $P1.'parseactions'('NQP::Grammar::Actions')
38 =item main(args :slurpy) :main
40 Start compilation by passing any command line C<args>
49 $P1 = $P0.'command_line'(args)
52 .include 'src/builtins.pir'
53 .include 'src/Grammar_gen.pir'
54 .include 'bootstrap/gen_actions.pir'
59 .sub 'initlist' :anon :load :init
60 subclass $P0, 'ResizablePMCArray', 'List'
62 set_hll_global ['NQP';'Grammar';'Actions'], '@?BLOCK', $P0
68 .sub 'unshift' :method
84 #.namespace [ 'NQP::Grammar::Actions' ]
86 #.sub 'package_declarator_helper'
91 # past = $P0.'get_scalar'()
94 # past.'namespace'($P1)
95 # past.'blocktype'('declaration')
96 # past.'pirflags'(':init :load')
99 # if $S0 != 'class' goto class_done
100 # .local string inline
101 # inline = <<' INLINE'
102 # $P0 = get_hll_global 'Protomaker'
103 # $P1 = split '::', '%s'
104 # push_eh subclass_done
105 # $P2 = $P0.'new_subclass'('Protoobject', $P1)
109 # $S0 = match['name']
110 # $I0 = index inline, '%s'
111 # substr inline, $I0, 2, $S0
112 # $P0 = get_hll_global ['PAST'], 'Op'
113 # $P1 = $P0.'new'('inline'=>inline, 'pasttype'=>'inline')
117 # match.'result_object'(past)
122 .sub '__onload' :init :load
124 ## initialize optable with inline PIR
126 optable = get_hll_global [ 'NQP::Grammar' ], '$optable'
127 optable['prefix:~'; 'inline'] = <<" END"
134 optable['prefix:+'; 'inline'] = <<" END"
141 optable['infix:=='; 'inline'] = <<" END"
149 optable['infix:!='; 'inline'] = <<" END"
157 optable['infix:eq'; 'inline'] = <<" END"
166 optable['infix:ne'; 'inline'] = <<" END"
175 optable['infix:=:='; 'inline'] = <<" END"
182 optable['prefix:!'; 'inline'] = <<" END"
189 optable['prefix:?'; 'inline'] = <<" END"
208 # vim: expandtab shiftwidth=4 ft=pir: