Skip to content

Commit

Permalink
refactor with opcode load_language
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Nov 28, 2009
1 parent d5c4641 commit e002e93
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 42 deletions.
35 changes: 4 additions & 31 deletions gil.pir
@@ -1,40 +1,16 @@

=head1 TITLE

gil.pir - A gil compiler.

=head2 Description

This is the base file for the gil compiler.

This file includes the parsing and grammar rules from
the src/ directory, loads the relevant PGE libraries,
and registers the compiler under the name 'gil'.
This is the entry point for the gil compiler.

=head2 Functions

=over 4

=item onload()

Creates the gil compiler using a C<PCT::HLLCompiler>
object.

=cut

.namespace [ 'gil::Compiler' ]

.loadlib 'gil_group'

.sub 'onload' :anon :load :init
load_bytecode 'PCT.pbc'

$P0 = get_hll_global ['PCT'], 'HLLCompiler'
$P1 = $P0.'new'()
$P1.'language'('gil')
$P1.'parsegrammar'('gil::Grammar')
$P1.'parseactions'('gil::Grammar::Actions')
.end
=item main(args :slurpy) :main

Start compilation by passing any command line C<args>
Expand All @@ -45,15 +21,12 @@ to the gil compiler.
.sub 'main' :main
.param pmc args

load_language 'gil'

$P0 = compreg 'gil'
$P1 = $P0.'command_line'(args)
.end

.include 'src/builtins.pir'
.include 'src/gen_grammar.pir'
.include 'src/gen_actions.pir'
=back

=cut
Expand Down
5 changes: 3 additions & 2 deletions src/builtins.pir → gil/builtins.pir
@@ -1,9 +1,10 @@

.include 'src/builtins/math.pir'
.include 'src/builtins/say.pir'
.include 'gil/builtins/math.pir'
.include 'gil/builtins/say.pir'

# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions gil/gil.pir
@@ -0,0 +1,50 @@

=head1 TITLE

gil.pir - A gil compiler.

=head2 Description

This is the base file for the gil compiler.

This file includes the parsing and grammar rules from
the src/ directory, loads the relevant PGE libraries,
and registers the compiler under the name 'gil'.

=head2 Functions

=over 4

=item onload()

Creates thegil compiler using a C<PCT::HLLCompiler>
object.

=cut

.namespace [ 'gil::Compiler' ]

.sub 'onload' :anon :load :init
load_bytecode 'PCT.pbc'

$P0 = get_hll_global ['PCT'], 'HLLCompiler'
$P1 = $P0.'new'()
$P1.'language'('gil')
$P1.'parsegrammar'('gil::Grammar')
$P1.'parseactions'('gil::Grammar::Actions')
.end
.include 'gil/builtins.pir'
.include 'gil/gen_grammar.pir'
.include 'gil/gen_actions.pir'
=back
=cut
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
File renamed without changes.
File renamed without changes.
23 changes: 14 additions & 9 deletions setup.pir
Expand Up @@ -35,24 +35,25 @@ No Configure step, no Makefile generated.

# build
$P1 = new 'Hash'
$P1['src/gen_grammar.pir'] = 'src/parser/grammar.pg'
$P1['gil/gen_grammar.pir'] = 'gil/parser/grammar.pg'
$P0['pir_pge'] = $P1

$P2 = new 'Hash'
$P2['src/gen_actions.pir'] = 'src/parser/actions.pm'
$P2['gil/gen_actions.pir'] = 'gil/parser/actions.pm'
$P0['pir_nqp'] = $P2

$P3 = new 'Hash'
$P4 = split "\n", <<'SOURCES'
gil.pir
src/gen_grammar.pir
src/gen_actions.pir
src/builtins.pir
src/builtins/math.pir
src/builtins/say.pir
gil/gil.pir
gil/gen_grammar.pir
gil/gen_actions.pir
gil/builtins.pir
gil/builtins/math.pir
gil/builtins/say.pir
SOURCES
$S0 = pop $P4
$P3['gil.pbc'] = $P4
$P3['gil/gil.pbc'] = $P4
$P3['gil.pbc'] = 'gil.pir'
$P0['pbc_pir'] = $P3

$P5 = new 'Hash'
Expand All @@ -64,6 +65,9 @@ SOURCES
$S0 .= ' gil.pbc'
$P0['prove_exec'] = $S0

# install
$P0['inst_lang'] = 'gil/gil.pbc'

.tailcall setup(args :flat, $P0 :flat :named)
.end

Expand All @@ -73,3 +77,4 @@ SOURCES
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

0 comments on commit e002e93

Please sign in to comment.