Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nqprx #12

Open
wants to merge 1 commit into
base: nqprx
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Compiler rewritten by nqprx can almost comiple now.
But I don't know how to adjust the 'quote_EXPR' method. So none of the tests
will pass right now.
Hongwe Qiu committed May 22, 2011
commit 04293aded24f2572b415ff671579af74b6b6c50b
31 changes: 7 additions & 24 deletions cardinal.pir
Original file line number Diff line number Diff line change
@@ -34,58 +34,43 @@ object.
.sub 'onload' :anon :load :init
load_bytecode 'HLL.pbc'
.local pmc hllns, parrotns, imports
hllns = get_hll_namespace
hllns = get_hll_namespace
parrotns = get_root_namespace ['parrot']
imports = split ' ', 'PAST PCT HLL Regex Hash'
imports = split ' ', 'PAST PCT HLL Regex Hash'
parrotns.'export_to'(hllns, imports)
.end

.include 'src/gen_grammar.pir'
.include 'src/parser/quote_expression.pir'
.include 'src/gen_actions.pir'
.include 'src/gen_compiler.pir'
.namespace [ 'cardinal';'Compiler' ]

#no caridinal_group found on my machine
#.loadlib 'cardinal_group'

=begin comment

.sub 'onload' :anon :load :init
.local pmc cardinalmeta, compilerclass, compiler
cardinalmeta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
compilerclass = cardinalmeta.'new_class'('cardinal::Compiler', 'parent'=>'PCT::HLLCompiler')

$P2 = new 'CardinalString'
$P2 = ""
set_hll_global '$,', $P2

compiler = compilerclass.'new'()
compiler.'language'('cardinal')
$P0 = get_hll_namespace ['cardinal';'Grammar']
compiler.'parsegrammar'($P0)
$P0 = get_hll_namespace ['cardinal';'Grammar';'Actions']
compiler.'parseactions'($P0)

compiler.'commandline_banner'("Cardinal - Ruby for the Parrot VM\n\n")
compiler.'commandline_prompt'('crb(main):001:0> ')
## create a list of END blocks to be run
## create a list of END blocks to be run
$P0 = new 'CardinalArray'
set_hll_global ['cardinal'], '@?END_BLOCKS', $P0

$P0 = new 'CardinalArray'
set_hll_global ['cardinal';'Grammar';'Actions'], '@?BLOCK', $P0
set_hll_global ['cardinal';'Actions'], '@?BLOCK', $P0

$P1 = get_hll_global ['PAST';'Compiler'], '%valflags'
$P1['CardinalString'] = 'e'
.end

=item main(args :slurpy) :main
=item main(args :slurpy) :main

Start compilation by passing any command line C<args>
to the cardinal compiler.

=cut
=cut

.sub 'main' :main
.param pmc args_str
@@ -141,8 +126,6 @@ to the cardinal compiler.
.return (retval)
.end

=end comment
=back

=cut
4 changes: 4 additions & 0 deletions src/compiler.pm
Original file line number Diff line number Diff line change
@@ -4,4 +4,8 @@ INIT {
cardinal::Compiler.language('cardinal');
cardinal::Compiler.parsegrammar(cardinal::Grammar);
cardinal::Compiler.parseactions(cardinal::Actions);
cardinal::Compiler.commandline_banner("Cardinal - Ruby for the Parrot VM\n\n");
cardinal::Compiler.commandline_prompt('crb(main):001:0> ');
}

# vim: sw=4 ts=4 ft=perl6 expandtab
344 changes: 119 additions & 225 deletions src/parser/actions.pm

Large diffs are not rendered by default.

509 changes: 168 additions & 341 deletions src/parser/grammar.pm

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/parser/quote_expression.pir
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
.end


.sub 'quote_expression' :method
.sub 'quote_EXPR' :method
.param string flags
.param pmc options :slurpy :named

@@ -175,9 +175,9 @@
pos += stoplen
mob.'to'(pos)
if null action goto succeed_done
$I0 = can action, 'quote_expression'
$I0 = can action, 'quote_EXPR'
unless $I0 goto succeed_done
action.'quote_expression'(mob, key)
action.'quote_EXPR'(mob, key)
succeed_done:
.return (mob)
fail: