Source

spix / spix.pir

Full commit
# Copyright (C) 2010, Parrot Foundation.

.namespace [ ]

.sub '' :anon :load :init
    load_bytecode 'HLL.pbc'
    load_bytecode 'Spix/PEG/Parser.pir'

    .local pmc hllns, parrotns, imports
    hllns = get_hll_namespace
    parrotns = get_root_namespace ['parrot']
    imports = split ' ', 'HLL'
    parrotns.'export_to'(hllns, imports)

    $P1 = get_root_global ["parrot"], "P6metaclass"
    $P2 = $P1."new_class"("Spix::Compiler", "HLL::Compiler" :named("parent"))
    $P2."language"("Spix")
    $P1 = split ' ', "parse"
    $P2.'stages'($P1)
.end

.sub 'main' :main
    .param pmc args
    $P0 = compreg 'Spix'

    $P2 = $P0.'command_line'(args)
    .return ($P2)
.end

.namespace [ 'Spix'; 'Compiler' ] 
 
.sub 'parse' :method 
    .param pmc source 
    .param pmc adverbs         :slurpy :named 
    $P0 = new ['Spix';'PEG';'Parser']
    $P1 = $P0.'parse'(source, adverbs :flat :named) 
    if null $P1 goto err_unmatched
    .return($P1)
  err_unmatched:
    $P2 = new ['Exception']
    $P2 = "Unable to parse source file"
    throw $P2
.end

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