Skip to content

Commit

Permalink
[Plumhead antlr3]
Browse files Browse the repository at this point in the history
Port to the PCT-PAST. Most tests are succeeding again.


git-svn-id: https://svn.parrot.org/parrot/trunk@23459 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bschmalhofer committed Dec 4, 2007
1 parent a67c5ef commit 74ef179
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions languages/plumhead/src/antlr3/GenPastPir.g
Expand Up @@ -35,12 +35,14 @@ gen_pir_past
+ " \n"
+ ".sub 'php_init' :load :init \n"
+ " \n"
+ " load_bytecode 'PGE.pbc' \n"
+ " load_bytecode 'PGE/Text.pbc' \n"
+ " load_bytecode 'PGE/Util.pbc' \n"
+ " load_bytecode 'PGE/Dumper.pbc' \n"
+ " load_bytecode 'PCT.pbc' \n"
+ " load_bytecode 'languages/plumhead/src/common/plumheadlib.pbc' \n"
+ " load_bytecode 'PAST-pm.pbc' \n"
+ " load_bytecode 'Parrot/HLLCompiler.pbc' \n"
+ " load_bytecode 'MIME/Base64.pbc' \n"
+ " load_bytecode 'dumper.pbc' \n"
+ " load_bytecode 'PGE.pbc' \n"
+ " load_bytecode 'CGI/QueryHash.pbc' \n"
+ " \n"
+ ".end \n"
Expand Down Expand Up @@ -94,11 +96,11 @@ gen_pir_past
+ " # pir = past_root.'compile'( 'target' => 'pir' ) \n"
+ " # print pir \n"
+ " \n"
+ " .local pmc pastcompiler, eval_past \n"
+ " pastcompiler = new 'HLLCompiler' \n"
+ " pastcompiler.'removestage'('parse') \n"
+ " pastcompiler.'removestage'('past') \n"
+ " eval_past = pastcompiler.'compile'(past_root) \n"
+ " .local pmc plumhead_compiler, eval_past \n"
+ " plumhead_compiler = new [ 'PCT::HLLCompiler' ] \n"
+ " plumhead_compiler.'removestage'('parse') \n"
+ " plumhead_compiler.'removestage'('past') \n"
+ " eval_past = plumhead_compiler.'compile'(past_root) \n"
+ " eval_past() \n"
+ " \n"
+ ".end \n"
Expand Down Expand Up @@ -155,7 +157,7 @@ node[String reg_mother]
+ " .local pmc code_string \n"
+ " code_string = new 'CodeString' \n"
+ " ( val ) = code_string.'escape'( val ) \n"
+ " past_temp.'init'( 'name' => val, 'vtype' => '.Undef' ) \n"
+ " past_temp.'init'( 'value' => val, 'returns' => 'Undef' ) \n"
+ " " + $node.reg_mother + ".'push'( past_temp ) \n"
+ " # end of NOQUOTE_STRING \n"
+ " \n"
Expand All @@ -174,9 +176,9 @@ node[String reg_mother]
+ " .local pmc code_string \n"
+ " code_string = new 'CodeString' \n"
+ " ( val ) = code_string.'escape'( val ) \n"
+ " past_temp.'init'( 'name' => val, 'vtype' => '.Undef' ) \n"
+ " past_temp.'init'( 'value' => val, 'returns' => 'Undef' ) \n"
+ " " + $node.reg_mother + ".'push'( past_temp ) \n"
+ " # end of SINGLEQUOTE_STRING \n"
+ " # end of SINGLEQUOTE_STRING \n"
+ " \n"
);
}
Expand All @@ -193,9 +195,9 @@ node[String reg_mother]
+ " .local pmc code_string \n"
+ " code_string = new 'CodeString' \n"
+ " ( val ) = code_string.'escape'( val ) \n"
+ " past_temp.'init'( 'name' => val, 'vtype' => '.Undef' ) \n"
+ " past_temp.'init'( 'value' => val, 'returns' => 'Undef' ) \n"
+ " " + $node.reg_mother + ".'push'( past_temp ) \n"
+ " # end of DOUBLEQUOTE_STRING \n"
+ " # end of DOUBLEQUOTE_STRING \n"
+ " \n"
);
}
Expand All @@ -205,9 +207,8 @@ node[String reg_mother]
" \n"
+ " # start of NUMBER \n"
+ " past_temp = new 'PAST::Val' \n"
+ " past_temp.'attr'( 'name', '" + $NUMBER.text + "', 1 ) \n"
+ " past_temp.'attr'( 'ctype', 'n+', 1 ) \n"
+ " past_temp.'attr'( 'vtype', '.Float', 1 ) \n"
+ " past_temp.'attr'( 'value', '" + $NUMBER.text + "', 1 ) \n"
+ " past_temp.'attr'( 'returns', 'Float', 1 ) \n"
+ " " + $node.reg_mother + ".'push'( past_temp ) \n"
+ " # end of NUMBER \n"
);
Expand All @@ -218,9 +219,8 @@ node[String reg_mother]
" \n"
+ " # start of INTEGER \n"
+ " past_temp = new 'PAST::Val' \n"
+ " past_temp.'attr'( 'name', '" + $INTEGER.text + "', 1 ) \n"
+ " past_temp.'attr'( 'ctype', 'i+', 1 ) \n"
+ " past_temp.'attr'( 'vtype', '.Integer', 1 ) \n"
+ " past_temp.'attr'( 'value', '" + $INTEGER.text + "', 1 ) \n"
+ " past_temp.'attr'( 'returns', 'Integer', 1 ) \n"
+ " " + $node.reg_mother + ".'push'( past_temp ) \n"
+ " # end of INTEGER \n"
);
Expand Down Expand Up @@ -255,7 +255,7 @@ node[String reg_mother]
System.out.print(
" " + reg + ".'attr'( 'pirop', '" + pirop + "', 1 ) \n"
+ " " + reg + ".'attr'( 'name', '" + name + "' , 1 ) \n"
+ " " + reg + ".'attr'( 'islvalue', 0 , 1 ) \n"
+ " " + reg + ".'attr'( 'lvalue', 0 , 1 ) \n"
+ " " + $node.reg_mother + ".'push'( " + reg + " ) \n"
+ " # leaving PLUS | MINUS | MUL_OP | BITWISE_OP \n"
);
Expand Down Expand Up @@ -370,7 +370,7 @@ node[String reg_mother]
" \n"
+ " # entering SCALAR \n"
+ " past_temp = new 'PAST::Var' \n"
+ " past_temp.'init'( 'name' => '" + $SCALAR.text + "', 'viviself' => '.Undef', 'islvalue' => 1 ) \n"
+ " past_temp.'init'( 'name' => '" + $SCALAR.text + "', 'scope' => 'package', 'viviself' => 'Undef', 'lvalue' => 1 ) \n"
+ " " + $node.reg_mother + ".'push'( past_temp ) \n"
+ " # leaving SCALAR \n"
);
Expand All @@ -383,15 +383,15 @@ node[String reg_mother]
+ " # entering ARRAY \n"
+ " .local pmc " + reg_array + " \n"
+ " " + reg_array + " = new 'PAST::Var' \n"
+ " " + reg_array + ".init( 'scope' => 'keyed', 'viviself' => '.Undef', 'islvalue' => 1 ) \n"
+ " " + reg_array + ".init( 'scope' => 'keyed', 'viviself' => 'Undef', 'lvalue' => 1 ) \n"
);
}
^( ARRAY node[reg_array] )
{
System.out.println(
" \n"
+ " past_name = new 'PAST::Var' \n"
+ " past_name.'init'( 'name' => '" + $ARRAY.text + "', 'viviself' => '.Hash', 'islvalue' => 1 ) \n"
+ " past_name.'init'( 'name' => '" + $ARRAY.text + "', 'scope' => 'package', 'viviself' => 'Hash', 'lvalue' => 1 ) \n"
+ " # PAST-pm has no unshift yet \n"
+ " \$P0 = " + reg_array + ".'get_array'() \n"
+ " unshift \$P0, past_name \n"
Expand Down

0 comments on commit 74ef179

Please sign in to comment.