cvsuser     03/02/03 03:49:27

  Modified:    languages/jako jakoc
               languages/jako/examples life.jako queens.jako
               languages/jako/lib/Jako Parser.pm
               languages/jako/lib/Jako/Construct Block.pm Label.pm Type.pm
               languages/jako/lib/Jako/Construct/Block Conditional.pm
                        Loop.pm Sub.pm
               languages/jako/lib/Jako/Construct/Declaration Constant.pm
                        Sub.pm Variable.pm
               languages/jako/lib/Jako/Construct/Expression Call.pm
               languages/jako/lib/Jako/Construct/Expression/Value
                        Identifier.pm Literal.pm
               languages/jako/lib/Jako/Construct/Statement Arithmetic.pm
                        Assign.pm Call.pm Decrement.pm Goto.pm Increment.pm
                        LoopControl.pm Return.pm
  Added:       languages/jako/lib/Jako/Construct/Block Bare.pm
  Log:
    * New -x jakoc command-line switch to get it to emit XML version of the
      parse tree.
  
    * Supporting code in the various parse tree node modules.
  
  Revision  Changes    Path
  1.32      +23 -3     parrot/languages/jako/jakoc
  
  Index: jakoc
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/jakoc,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -w -r1.31 -r1.32
  --- jakoc     15 Dec 2002 22:17:34 -0000      1.31
  +++ jakoc     3 Feb 2003 11:48:23 -0000       1.32
  @@ -8,7 +8,7 @@
   # This program is free software. It is subject to the same license
   # as Perl itself.
   #
  -# $Id: jakoc,v 1.31 2002/12/15 22:17:34 gregor Exp $
  +# $Id: jakoc,v 1.32 2003/02/03 11:48:23 gregor Exp $
   #
   
   use strict;
  @@ -37,7 +37,7 @@
   use Getopt::Std;
   
   my %opts;
  -getopts('ctT', \%opts);
  +getopts('ctTx', \%opts);
   
   die "$0: usage: $0 <source>\n" unless @ARGV == 1;
   $compiler->file(shift @ARGV);
  @@ -61,7 +61,27 @@
     exit 0;
   }
   
  -unless ($opts{c}) { # -c means "Check", like with Perl.
  +if ($opts{x}) { # -x means "XML"
  +  eval "use XML::Handler::YAWriter";
  +  die "Could not find XML::Handler::YAWriter!" if $@;
  +  my $handler = XML::Handler::YAWriter->new(
  +    Output => IO::File->new('>-'),
  +    Pretty => {
  +      PrettyWhiteIndent  => 1,
  +      PrettyWhiteNewline => 1,
  +      CatchEmptyElement  => 1,
  +      CompactAttrIndent  => 1
  +    }
  +  );
  +
  +  $handler->start_document;
  +  $root->sax($handler);
  +  $handler->end_document;
  +}
  +elsif ($opts{c}) { # -c means "Check", like with Perl.
  +  # DO NOTHING
  +}
  +else {
     my $fh = FileHandle->new('>-');
     $compiler->compile($root, $fh);
   }
  
  
  
  1.2       +39 -46    parrot/languages/jako/examples/life.jako
  
  Index: life.jako
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/examples/life.jako,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- life.jako 14 Dec 2002 11:08:51 -0000      1.1
  +++ life.jako 3 Feb 2003 11:48:29 -0000       1.2
  @@ -20,7 +20,7 @@
   sub int endwin   {fnlib = "libcurses.so"} ();
   sub int curs_set {fnlib = "libcurses.so"} (int x);
   sub int addstr   {fnlib = "libcurses.so"} (str s);
  -#sub int refresh  {fnlib = "libcurses.so"} ();
  +sub int refresh  {fnlib = "libcurses.so"} ();
   sub int move     {fnlib = "libcurses.so"} (int x, int y);
   
   var int foo; # Store result from above functions here.
  @@ -67,20 +67,17 @@
     offset = row * WIDTH;
     offset += col;
   
  -#  var int len;
  -#  len = length(cells);
  -#  foo = move(0, 19);
  -#  foo = addstr("length(cells) == $len");
  +  var int len;
  +  len = length(cells);
  +  foo = move(0, 19);
  +  foo = addstr("length(cells) == $len");
     foo = move(0, 20);
  -  foo = addstr("substr(cells, $offset, 1");
  -#  foo = refresh();
  -
  +  foo = addstr("substr(cells, $offset, 1)");
  +  foo = move(0, 25);
  +  foo = refresh();
     temp = substr(cells, offset, 1);
   
  -  if (temp == "*") {
  -    return 1;
  -  }
  -
  +  return 1 if (temp == "*");
     return 0;
   }
   
  @@ -117,28 +114,22 @@
         var int current;
         current = at(cells, row, col);
   
  +      var str ch;
         if (current != 0) {
  -        if (count == 3) {
  -          concat(temp, "*");
  -        }
  -        else {
  -          concat(temp, " ");
  -        }
  +        foo = move(0, 21);
  +        foo = addstr("substr(\"   *     \", $count, 1)");
  +        foo = move(0, 25);
  +        foo = refresh();
  +        ch = substr("   *     ", count, 1);
         }
         else {
  -        if (count < 2) {
  -          concat(temp, " ");
  -        }
  -        if (count == 2) {
  -          concat(temp, "*");
  -        }
  -        if (count == 3) {
  -          concat(temp, "*");
  -        }
  -        if (count > 3) {
  -          concat(temp, " ");
  -        }
  +        foo = move(0, 21);
  +        foo = addstr("substr(\"  **     \", $count, 1)");
  +        foo = move(0, 25);
  +        foo = refresh();
  +        ch = substr("  **     ", count, 1);
         }
  +      concat(temp, ch);
   
         col++;
       }
  @@ -157,25 +148,27 @@
   sub dump(str cells, int g)
   {
     foo = move(0, 0);
  -  foo = addstr("Generation: ");
  -  foo = addstr(g);
  -#  foo = refresh();
  -
  -  var int offset = 0;
  -  var int row;
  -  row = HEIGHT - 1;
  -
  -  while (row >= 0) {
  -    var str temp;
  +  foo = addstr("Generation $g of $G:");
   
  -    temp = substr(cells, offset, 15);
  -
  -    foo = addstr(temp);
  -    foo = addstr("\n");
  +  var int row = 0;
  +  while (row < HEIGHT) {
  +    var int col = 0;
  +    while (col < WIDTH) {
  +      var int current;
  +      current = at(cells, row, col);
   
  -    offset += 15;
  -    row--;
  +      if (current == 1) {
  +        addstr("*");
  +      }
  +      else {
  +        addstr(" ");
     }
  +    }
  +    addstr("\n");
  +  }
  +
  +  foo = move(0, 25);
  +  foo = refresh();
   }
   
   
  
  
  
  1.7       +152 -61   parrot/languages/jako/examples/queens.jako
  
  Index: queens.jako
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/examples/queens.jako,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- queens.jako       15 Dec 2002 05:14:36 -0000      1.6
  +++ queens.jako       3 Feb 2003 11:48:29 -0000       1.7
  @@ -7,35 +7,65 @@
   # This program is free software. It is subject to the same
   # license as the Parrot interpreter.
   #
  -# $Id: queens.jako,v 1.6 2002/12/15 05:14:36 gregor Exp $
  +# $Id: queens.jako,v 1.7 2003/02/03 11:48:29 gregor Exp $
   #
   
   sub print {op} (str s);
  -sub int not {op} (int i);
  -
  -# 4 bits per file, represent the rank of the queen, 0xf for none
  -
  -const int BITS_PER_FILE = 4;
  -const int NO_QUEEN      = 0xf;
  +sub str substr {op} (str s, int i, int l);
  +sub str concat {op} (str s, str t);
  +sub int length {op} (str s);
   
   const int NUM_FILES     = 8;
   const int NUM_RANKS     = 8;
   
   
   #
  +# remove_queen()
  +#
  +
  +sub str remove_queen (str board, int rank, int file)
  +{
  +  board = clear_file(board, file);
  +
  +  var int i;
  +  i  = rank * NUM_FILES;
  +  i += file;
  +
  +  var int x;
  +  x = i - 1;
  +
  +  var int y;
  +  y = i + 1;
  +
  +  var str prefix;
  +  prefix = substr(board, 0, x);
  +  var str suffix;
  +  suffix = substr(board, y, -1);
  +
  +  var str temp;
  +  temp = prefix;
  +  temp = concat(temp, " ");
  +  temp = concat(temp, suffix);
  +
  +  return temp;
  +}
  +
  +
  +#
   # clear_file()
   #
   # Clears the queen from the current file. Makes no assumption about current
   # nybble contents.
   #
   
  -sub int clear_file (int board, int file) {
  -  var int amount;
  -  var int temp;
  -
  -  amount = BITS_PER_FILE * file;
  -  temp   = NO_QUEEN << amount;
  -  board  = board | temp;
  +sub str clear_file (str board, int file)
  +{
  +  var int rank = 0;
  +
  +  while (rank < NUM_RANKS) {
  +    board = remove_queen(board, rank, file);
  +    rank++;
  +  }
   
     return board;
   }
  @@ -44,22 +74,35 @@
   #
   # place_queen()
   #
  -# Places a queen at the current rank of the current file. Assumes no queen for
  -# the file yet (which means its nybble is 0xf).
  +# Places a queen at the given rank and file, removing any other queen from the
  +# file.
   #
   
  -sub int place_queen (int board, int rank, int file) {
  -  var int amount;
  -  var int temp;
  +sub str place_queen (str board, int rank, int file)
  +{
  +  board = clear_file(board, file);
   
  -  amount = BITS_PER_FILE * file;
  -  temp   = NO_QUEEN << amount;
  -  temp   = not(temp);
  -  board  = board & temp;
  -  temp   = rank << amount;
  -  board  = board | temp;
  +  var int i;
  +  i  = rank * NUM_FILES;
  +  i += file;
  +
  +  var int x;
  +  x = i - 1;
  +
  +  var int y;
  +  y = i + 1;
  +
  +  var str prefix;
  +  prefix = substr(board, 0, x);
  +  var str suffix;
  +  suffix = substr(board, y, -1);
  +
  +  var str temp;
  +  temp = prefix;
  +  temp = concat(temp, "Q");
  +  temp = concat(temp, suffix);
   
  -  return board;
  +  return temp;
   }
   
   
  @@ -72,18 +115,50 @@
   # Ouptut: rank = queen's rank in that file
   #
   
  -sub int queen_rank (int board, int file) {
  -  var int amount;
  +sub int queen_rank (str board, int file)
  +{
  +  var int rank = 0;
  +
  +  while (rank < NUM_RANKS) {
     var int temp;
  +    temp = queen_at(board, rank, file);
  +    return rank if (temp == 1);
  +    rank++;
  +  }
   
  +  return -1;
  +}
  +
  +
  +#
  +# at()
  +#
  +# Determines whether or not there is a queen at a given location.
  +#
  +# Input:  rank, file
  +# Output: 1 (queen) or 0 (empty)
  +#
  +
  +sub str at (str board, int rank, int file) {
  +  var str temp;
  +
  +  print("Fetching contents of square at $rank, $file...\n");
  +
  +  return 0 if (rank < 0);
  +  return 0 if (rank >= NUM_RANKS);
     return 0 if (file < 0);
     return 0 if (file >= NUM_FILES);
   
  -  amount = BITS_PER_FILE *  file;
  -  temp   = NO_QUEEN      << amount;
  -  temp   = temp          &  board;
  -  temp   = temp          >> amount;
  -  temp   = temp          |  NO_QUEEN;
  +  var int i;
  +  i  = rank * NUM_FILES;
  +  i += file;
  + 
  +  var int l;
  +  l = length(board);
  +
  +  print("Board is $l characters long. Fetching character at index $i.\n");
  +
  +  temp = substr(board, i, 1);
   
     return temp;
   }
  @@ -95,22 +170,17 @@
   # Determines whether or not there is a queen at a given location.
   #
   # Input:  rank, file
  -# Ouptut: queen
  +# Output: 1 (queen) or 0 (empty)
   #
   
  -sub int queen_at (int board, int rank, int file) {
  -  var int temp;
  +sub int queen_at (str board, int rank, int file) {
  +  var str temp;
   
  -  return 0 if (rank < 0);
  -  return 0 if (rank >= NUM_RANKS);
  -  return 0 if (file < 0);
  -  return 0 if (file >= NUM_FILES);
  +  print("Looking for queen at $rank, $file...\n");
   
  -  temp = queen_rank(board, file);
  +  temp = at(board, rank, file);
    
  -  return 0 if (temp < 0);
  -  return 0 if (temp >= NUM_RANKS);
  -  return 1 if (temp == rank);
  +  return 1 if (temp == "Q");
     return 0;
   }
   
  @@ -118,10 +188,10 @@
   #
   # free_space()
   #
  -# Determines whether or not the current space is free for placing a queen.
  +# Determines whether or not a space is free for placing a queen.
   #
   
  -sub int free_space (int board, int rank, int file) {
  +sub int free_space (str board, int rank, int file) {
     var int i = 1;
   
     while (i <= file) {
  @@ -154,7 +224,7 @@
   # print_board()
   #
   
  -sub print_board (int board) {
  +sub print_board (str board) {
     var int rank, file;
     var int temp;
   
  @@ -198,25 +268,46 @@
   
   
   #
  -# main()
  +# new_board()
   #
   
  -sub main() {
  -  var int board;
  -  var int rank;
  -  var int file;
  -
  -  #
  -  # Clear the files:
  -  #
  +sub str new_board()
  +{
  +  var str board = "";
  +  var int rank = 0;
  +  var int file = 0;
   
  -  file = 0;
  +  print("Making new board with $NUM_RANKS ranks and $NUM_FILES files...\n");
   
  +  while (rank < NUM_RANKS) {
     while(file < NUM_FILES) {
  -    board = clear_file(board, file);
  +      board = concat(board, " ");
       file++;
     }
  +    rank++;
  +  }
  +
  +  var int l;
  +  l = length(board);
  +  print("Board length is $l.\n");
  +
  +  return board;
  +}
  +
  +
  +#
  +# main()
  +#
  +
  +sub main() {
  +  var str board;
  +  var int rank;
  +  var int file;
  +
  +  board = new_board();
   
  +  print_board(board);
  +  place_queen(board, 3, 3);
     print_board(board);
   
     #
  
  
  
  1.11      +3 -2      parrot/languages/jako/lib/Jako/Parser.pm
  
  Index: Parser.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Parser.pm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -r1.10 -r1.11
  --- Parser.pm 20 Dec 2002 01:58:52 -0000      1.10
  +++ Parser.pm 3 Feb 2003 11:48:34 -0000       1.11
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as Perl itself.
   #
  -# $Id: Parser.pm,v 1.10 2002/12/20 01:58:52 gregor Exp $
  +# $Id: Parser.pm,v 1.11 2003/02/03 11:48:34 gregor Exp $
   #
   
   use strict;
  @@ -18,6 +18,7 @@
   use base qw(Jako::Processor);
   
   use Jako::Construct::Block;
  +use Jako::Construct::Block::Bare;
   use Jako::Construct::Block::Conditional::Else;
   use Jako::Construct::Block::Conditional::If;
   use Jako::Construct::Block::Conditional::Unless;
  @@ -55,7 +56,7 @@
   {
     my $class = shift;
   
  -  my $root = Jako::Construct::Block->new(
  +  my $root = Jako::Construct::Block::Bare->new(
       undef,  # No parent
       'file', # File scope
       undef,  # No return type
  
  
  
  1.5       +6 -1      parrot/languages/jako/lib/Jako/Construct/Block.pm
  
  Index: Block.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Block.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- Block.pm  20 Dec 2002 01:58:54 -0000      1.4
  +++ Block.pm  3 Feb 2003 11:48:41 -0000       1.5
  @@ -7,7 +7,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Block.pm,v 1.4 2002/12/20 01:58:54 gregor Exp $
  +# $Id: Block.pm,v 1.5 2003/02/03 11:48:41 gregor Exp $
   #
   
   use strict;
  @@ -17,6 +17,8 @@
   
   use base qw(Jako::Construct);
   
  +use Carp;
  +
   
   #
   # CONSTRUCTOR:
  @@ -26,6 +28,9 @@
   {
     my $class = shift;
     my ($block, $kind, $type, $prefix) = @_;
  +
  +  confess "Use Jako::Construct::Block::Bare, not Jako::Construct::Block"
  +    if $class eq 'Jako::Construct::Block';
   
     return bless {
       BLOCK   => $block,  # Parent block
  
  
  
  1.4       +15 -1     parrot/languages/jako/lib/Jako/Construct/Label.pm
  
  Index: Label.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Label.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- Label.pm  20 Dec 2002 01:58:54 -0000      1.3
  +++ Label.pm  3 Feb 2003 11:48:41 -0000       1.4
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Label.pm,v 1.3 2002/12/20 01:58:54 gregor Exp $
  +# $Id: Label.pm,v 1.4 2003/02/03 11:48:41 gregor Exp $
   #
   
   use strict;
  @@ -69,6 +69,20 @@
     $compiler->emit("_LABEL_$ident:");
   
     return;
  +}
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +  
  +  $handler->start_element({ Name => 'label', Attributes => { name => 
$self->ident->value } });
  +  $handler->end_element({ Name => 'label' });
   }
   
   
  
  
  
  1.3       +7 -1      parrot/languages/jako/lib/Jako/Construct/Type.pm
  
  Index: Type.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Type.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- Type.pm   20 Dec 2002 01:58:54 -0000      1.2
  +++ Type.pm   3 Feb 2003 11:48:41 -0000       1.3
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Type.pm,v 1.2 2002/12/20 01:58:54 gregor Exp $
  +# $Id: Type.pm,v 1.3 2003/02/03 11:48:41 gregor Exp $
   #
   
   use strict;
  @@ -32,6 +32,11 @@
   
   my %types = ( 'I' => 'int', 'N' => 'num', 'P' => 'obj', 'S' => 'str');
   
  +sub CODE_TO_NAME {
  +  my ($class, $code) = @_;
  +  return $types{uc $code};
  +}
  +
   sub new
   {
     my $class = shift;
  @@ -74,6 +79,7 @@
   {
     return shift->{IMCC};
   }
  +
   
   1;
   
  
  
  
  1.9       +38 -1     parrot/languages/jako/lib/Jako/Construct/Block/Conditional.pm
  
  Index: Conditional.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Block/Conditional.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- Conditional.pm    20 Dec 2002 01:58:56 -0000      1.8
  +++ Conditional.pm    3 Feb 2003 11:48:52 -0000       1.9
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Conditional.pm,v 1.8 2002/12/20 01:58:56 gregor Exp $
  +# $Id: Conditional.pm,v 1.9 2003/02/03 11:48:52 gregor Exp $
   #
   
   use strict;
  @@ -90,6 +90,43 @@
     }
   
     return 1;
  +}
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  if (not $self->prefix and $self->peer and $self->peer->prefix) {
  +    $self->prefix($self->peer->prefix);
  +  }
  +
  +  if ($self->prefix) {
  +    $handler->start_element({ Name => 'cond', Attributes => { kind => $self->kind, 
name => $self->prefix } });
  +  }
  +  else {
  +    $handler->start_element({ Name => 'cond', Attributes => { kind => $self->kind } 
});
  +  }
  +
  +  if ($self->op) {
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'test' } });
  +    $handler->start_element({ Name => 'op', Attributes => { kind => 'infix', name 
=> $self->op } });
  +    $self->left->sax($handler);
  +    $self->right->sax($handler);
  +    $handler->end_element({ Name => 'op' });
  +    $handler->end_element({ Name => 'block' });
  +  }
  +
  +  $handler->start_element({ Name => 'block', Attributes => { kind => 'then' } });
  +  $_->sax($handler) foreach $self->content;
  +  $handler->end_element({ Name => 'block' });
  +
  +  $handler->end_element({ Name => $self->kind });
   }
   
   
  
  
  
  1.9       +39 -1     parrot/languages/jako/lib/Jako/Construct/Block/Loop.pm
  
  Index: Loop.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Block/Loop.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- Loop.pm   20 Dec 2002 01:58:56 -0000      1.8
  +++ Loop.pm   3 Feb 2003 11:48:52 -0000       1.9
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Loop.pm,v 1.8 2002/12/20 01:58:56 gregor Exp $
  +# $Id: Loop.pm,v 1.9 2003/02/03 11:48:52 gregor Exp $
   #
   
   use strict;
  @@ -91,6 +91,44 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  if (not $self->prefix and $self->peer and $self->peer->prefix) {
  +    $self->prefix($self->peer->prefix);
  +  }
  +
  +  if ($self->prefix) {
  +    $handler->start_element({ Name => 'loop', Attributes => { kind => $self->kind, 
name => $self->prefix } });
  +  }
  +  else {
  +    $handler->start_element({ Name => 'loop', Attributes => { kind => $self->kind } 
});
  +  }
  +
  +  if ($self->op) {
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'test' } });
  +    $handler->start_element({ Name => 'op', Attributes => { kind => 'infix', name 
=> $self->op } });
  +    $self->left->sax($handler);
  +    $self->right->sax($handler);
  +    $handler->end_element({ Name => 'op' });
  +    $handler->end_element({ Name => 'block' });
  +  }
  +
  +  $handler->start_element({ Name => 'block', Attributes => { kind => $self->kind } 
});
  +  $_->sax($handler) foreach $self->content;
  +  $handler->end_element({ Name => 'block' });
  +
  +  $handler->end_element({ Name => $self->kind });
  +}
  +
   
   
   1;
  
  
  
  1.5       +36 -1     parrot/languages/jako/lib/Jako/Construct/Block/Sub.pm
  
  Index: Sub.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Block/Sub.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- Sub.pm    20 Dec 2002 01:58:56 -0000      1.4
  +++ Sub.pm    3 Feb 2003 11:48:52 -0000       1.5
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Sub.pm,v 1.4 2002/12/20 01:58:56 gregor Exp $
  +# $Id: Sub.pm,v 1.5 2003/02/03 11:48:52 gregor Exp $
   #
   
   use strict;
  @@ -107,6 +107,41 @@
     $compiler->emit(".end");
   
     return 1;
  +}
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  my $type  = $self->type;
  +  my $name  = $self->name;
  +  my @args  = $self->args;
  +
  +  if ($type) {
  +    $handler->start_element({ Name => 'sub', Attributes => { name => $name, type => 
$type } });
  +  }
  +  else {
  +    $handler->start_element({ Name => 'sub', Attributes => { name => $name } });
  +  }
  +
  +  foreach my $arg (@args) {
  +    my ($arg_type, $arg_name) = @$arg;
  +
  +    $handler->start_element({ Name => 'arg', Attributes => { name => $arg_name, 
type => $arg_type } });
  +    $handler->end_element({ Name => 'arg' });
  +  }
  +
  +  foreach my $content ($self->content) {
  +    $content->sax($handler);
  +  }
  +
  +  $handler->end_element({ Name => 'sub' });
   }
   
   
  
  
  
  1.1                  parrot/languages/jako/lib/Jako/Construct/Block/Bare.pm
  
  Index: Bare.pm
  ===================================================================
  #
  # Bare.pm
  #
  # Copyright (C) 2002-2003 Gregor N. Purdy. All rights reserved.
  # This program is free software. It is subject to the same license
  # as the Parrot interpreter.
  #
  # $Id: Bare.pm,v 1.1 2003/02/03 11:48:52 gregor Exp $
  #
  
  use strict;
  eval "use warnings";
  
  package Jako::Construct::Block::Bare;
  
  use Carp;
  
  use Jako::Compiler;
  
  use base qw(Jako::Construct::Block);
  
  
  #
  # compile()
  #
  
  sub compile
  {
    my $self = shift;
    my ($compiler) = @_;
  
    my $namespace = "BARE"; # TODO: Don't we need to do better than this?
  
    if ($self->content) {
      $compiler->emit(".namespace ${namespace}");
      $compiler->indent;
      foreach my $content ($self->contents) {
        $content->compile($compiler);
      }
      $compiler->outdent;
      $compiler->emit(".endnamespace ${namespace}");
    }
  
    return 1;
  }
  
  
  #
  # sax()
  #
  
  sub sax
  {
    my $self = shift;
    my ($handler) = @_;
  
    $handler->start_element({ Name => 'block', Attributes => { kind => $self->kind } 
});
    foreach my $content ($self->content) {
      $content->sax($handler);
    }
    $handler->end_element({ Name => 'block' });
  }
  
  
  1;
  
  
  
  1.5       +17 -1     parrot/languages/jako/lib/Jako/Construct/Declaration/Constant.pm
  
  Index: Constant.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Declaration/Constant.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- Constant.pm       20 Dec 2002 01:59:03 -0000      1.4
  +++ Constant.pm       3 Feb 2003 11:49:02 -0000       1.5
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Constant.pm,v 1.4 2002/12/20 01:59:03 gregor Exp $
  +# $Id: Constant.pm,v 1.5 2003/02/03 11:49:02 gregor Exp $
   #
   
   use strict;
  @@ -142,6 +142,22 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'const', Attributes => { type => 
$self->type->name, name => $self->name } });
  +  $self->value->sax($handler);
  +  $handler->end_element({ Name => 'const' });
  +}
  +
   
   1;
   
  
  
  
  1.5       +97 -1     parrot/languages/jako/lib/Jako/Construct/Declaration/Sub.pm
  
  Index: Sub.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Declaration/Sub.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- Sub.pm    20 Dec 2002 01:59:03 -0000      1.4
  +++ Sub.pm    3 Feb 2003 11:49:02 -0000       1.5
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Sub.pm,v 1.4 2002/12/20 01:59:03 gregor Exp $
  +# $Id: Sub.pm,v 1.5 2003/02/03 11:49:02 gregor Exp $
   #
   
   use strict;
  @@ -185,6 +185,102 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  my $name  = $self->name;
  +  my $type  = $self->type;
  +
  +  my %reg = ('int' => 5, 'num' => 5, 'obj' => 5, 'str' => 5);
  +
  +  my $sym = $self->block->find_symbol($name);
  +
  +  my %props = $sym->props;
  +
  +  if (exists $props{op}) {
  +    my $oplib = $props{oplib} ? $props{oplib}->value : 'CORE'; # TODO: We should 
make sure its a string, somewhere.
  +    my $op    = $props{op}    ? $props{op}->value    : $name;
  +
  +    if ($type) {
  +      $handler->start_element({
  +        Name       => 'sub',
  +        Attributes => {
  +          name  => $name,
  +          type  => $type,
  +          kind  => 'op',
  +          oplib => $oplib,
  +          op    => $op
  +        }
  +      });
  +    }
  +    else {
  +      $handler->start_element({
  +        Name       => 'sub',
  +        Attributes => {
  +          name  => $name,
  +          kind  => 'op',
  +          oplib => $oplib,
  +          op    => $op
  +        }
  +      });
  +    }
  +  }
  +  elsif (exists $props{fnlib}) {
  +    my $fnlib = $props{fnlib}->value; # TODO: We should make sure its a string, 
somewhere.
  +    my $fn    = $props{fn} ? $props{fn}->value : $name;
  +
  +    if ($type) {
  +      $handler->start_element({
  +        Name       => 'sub',
  +        Attributes => {
  +          name  => $name,
  +          type  => $type,
  +          kind  => 'fn',
  +          fnlib => $fnlib,
  +          fn    => $fn
  +        }
  +      });
  +    }
  +    else {
  +      $handler->start_element({
  +        Name       => 'sub',
  +        Attributes => {
  +          name  => $name,
  +          kind  => 'fn',
  +          fnlib => $fnlib,
  +          fn    => $fn
  +        }
  +      });
  +    }
  +  }
  +  else {
  +    return;
  +  }
  +
  +  foreach my $arg ($self->args) {
  +    my ($arg_type_name, $arg_name) = @$arg;
  +
  +    $handler->start_element({
  +      Name       => 'arg',
  +      Attributes => {
  +        type => $arg_type_name,
  +        name => $arg_name
  +      }
  +    });
  +    $handler->end_element({ Name => 'arg' });
  +  }
  +
  +  $handler->end_element({ Name => 'sub' });
  +}
  +
   
   1;
   
  
  
  
  1.6       +16 -1     parrot/languages/jako/lib/Jako/Construct/Declaration/Variable.pm
  
  Index: Variable.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Declaration/Variable.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- Variable.pm       20 Dec 2002 01:59:03 -0000      1.5
  +++ Variable.pm       3 Feb 2003 11:49:02 -0000       1.6
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Variable.pm,v 1.5 2002/12/20 01:59:03 gregor Exp $
  +# $Id: Variable.pm,v 1.6 2003/02/03 11:49:02 gregor Exp $
   #
   
   use strict;
  @@ -135,6 +135,21 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'var', Attributes => { type => 
$self->type->name, name => $self->name } });
  +  $handler->end_element({ Name => 'var' });
  +}
  +
   
   1;
   
  
  
  
  1.6       +22 -1     parrot/languages/jako/lib/Jako/Construct/Expression/Call.pm
  
  Index: Call.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Expression/Call.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- Call.pm   20 Dec 2002 01:59:05 -0000      1.5
  +++ Call.pm   3 Feb 2003 11:49:15 -0000       1.6
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Call.pm,v 1.5 2002/12/20 01:59:05 gregor Exp $
  +# $Id: Call.pm,v 1.6 2003/02/03 11:49:15 gregor Exp $
   #
   
   use strict;
  @@ -135,5 +135,26 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'assign' });
  +  $self->dest->sax($handler);
  +
  +  $handler->start_element({ Name => 'call', Attributes => { name => 
$self->name->value } });
  +  $_->sax($handler) foreach $self->args;
  +  $handler->end_element({ Name => 'call' });
  +
  +  $handler->end_element({ Name => 'assign' });
  +}
  +
   
   1;
  
  
  
  1.3       +16 -1     
parrot/languages/jako/lib/Jako/Construct/Expression/Value/Identifier.pm
  
  Index: Identifier.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Expression/Value/Identifier.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- Identifier.pm     20 Dec 2002 01:59:06 -0000      1.2
  +++ Identifier.pm     3 Feb 2003 11:49:23 -0000       1.3
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Identifier.pm,v 1.2 2002/12/20 01:59:06 gregor Exp $
  +# $Id: Identifier.pm,v 1.3 2003/02/03 11:49:23 gregor Exp $
   #
   
   use strict;
  @@ -40,6 +40,21 @@
       LINE   => $token->line
     }, $class;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'ident', Attributes => { name => $self->value } 
});
  +  $handler->end_element({ Name => 'ident' });
  +}
  +
   
   1;
   
  
  
  
  1.5       +73 -8     
parrot/languages/jako/lib/Jako/Construct/Expression/Value/Literal.pm
  
  Index: Literal.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Expression/Value/Literal.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- Literal.pm        20 Dec 2002 01:59:06 -0000      1.4
  +++ Literal.pm        3 Feb 2003 11:49:23 -0000       1.5
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Literal.pm,v 1.4 2002/12/20 01:59:06 gregor Exp $
  +# $Id: Literal.pm,v 1.5 2003/02/03 11:49:23 gregor Exp $
   #
   
   use strict;
  @@ -88,21 +88,21 @@
         $compiler->emit("  concat $temp, \"$1\"")
           if defined $1 and $1 ne '';
   
  -      my $interp = $2;
  -      $interp =~ s/^{(.*)}$/$1/; # Strip '{' and '}'.
  +      my $ident = $2;
  +      $ident =~ s/^{(.*)}$/$1/; # Strip '{' and '}'.
   
  -      my $sym = $self->block->find_symbol($interp);
  +      my $sym = $self->block->find_symbol($ident);
   
  -      $self->SYNTAX_ERROR("Cannot interpolate '%s': symbol not found!", $interp)
  +      $self->SYNTAX_ERROR("Cannot interpolate '%s': symbol not found!", $ident)
           unless $sym;
   
         if (not UNIVERSAL::isa($sym->type, 'Jako::Construct::Type::String')) {
           my $temp2 = $compiler->temp_str();
  -        $compiler->emit("  $temp2 = $interp");
  -        $interp = $temp2;
  +        $compiler->emit("  $temp2 = $ident");
  +        $ident = $temp2;
         }
   
  -      $compiler->emit("  concat $temp, $interp");
  +      $compiler->emit("  concat $temp, $ident");
   
         $string = $6;
       }
  @@ -118,6 +118,71 @@
       return $self->value;
     }
   }
  +
  +
  +#
  +# sax()
  +#
  +# TODO: Convert escapes. For example, "\n" should be an actual newline.
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  my $type = $self->type;
  +
  +  if (UNIVERSAL::isa($type, 'Jako::Construct::Type::String')) {
  +    my $string = $self->value;
  +
  +    if ($string =~ m/(^"|^".*?[^\\])\$/) { # Double-quote with an unescaped '$'.
  +      $string = substr($string, 1, -1); # Without the surrounding double quotes.
  +
  +      $handler->start_element({ Name => 'concat' });
  +
  +      while (1) {
  +        last unless defined $string and
  +          $string =~ 
m/(^|^.*?[^\\])\$((([A-Za-z][A-Za-z0-9_]*)\b)|({[A-Za-z][A-Za-z0-9_]*}))(.*)$/;
  +
  +        if (defined $1 and $1 ne '') {
  +          $handler->start_element({ Name => 'literal', Attributes => { type => 
$type->name } });
  +          $handler->characters({ Data => $1 });
  +          $handler->end_element({ Name => 'literal' });
  +        }
  +
  +        my $ident = $2;
  +        $ident =~ s/^{(.*)}$/$1/; # Strip '{' and '}'.
  +
  +        $handler->start_element({ Name => 'ident', Attributes => { name => $ident } 
});
  +        $handler->end_element({ Name => 'ident' });
  +
  +        $string = $6;
  +      }
  +
  +      if (defined $string and $string ne '') {
  +        $handler->start_element({ Name => 'literal', Attributes => { type => 
$type->name } });
  +        $handler->characters({ Data => $string });
  +        $handler->end_element({ Name => 'literal' });
  +      }
  +
  +      $handler->end_element({ Name => 'concat' });
  +    }
  +    else {
  +      $string = substr($string, 1, -1); # Without the surrounding quotes.
  +
  +      $handler->start_element({ Name => 'literal', Attributes => { type => 
$type->name } });
  +      $handler->characters({ Data => $string });
  +      $handler->end_element({ Name => 'literal' });
  +    }
  +  }
  +  else {
  +    $handler->start_element({ Name => 'literal', Attributes => { type => 
$type->name } });
  +    $handler->characters({ Data => $self->value });
  +    $handler->end_element({ Name => 'literal' });
  +  }
  +}
  +
   
   1;
   
  
  
  
  1.5       +27 -1     parrot/languages/jako/lib/Jako/Construct/Statement/Arithmetic.pm
  
  Index: Arithmetic.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/Arithmetic.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- Arithmetic.pm     20 Dec 2002 01:59:08 -0000      1.4
  +++ Arithmetic.pm     3 Feb 2003 11:49:27 -0000       1.5
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Arithmetic.pm,v 1.4 2002/12/20 01:59:08 gregor Exp $
  +# $Id: Arithmetic.pm,v 1.5 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -146,5 +146,31 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  my $block = $self->block;
  +  my $dest  = $self->dest;
  +  my $left  = $self->left;
  +  my $op    = $self->op;
  +  my $right = $self->right;
  +
  +  $handler->start_element({ Name => 'assign' });
  +  $dest->sax($handler);
  +  $handler->start_element({ Name => 'op', Attributes => { kind => 'infix', name => 
$op } });
  +  $left->sax($handler);
  +  $right->sax($handler);
  +  $handler->end_element({ Name => 'op' });
  +  $handler->end_element({ Name => 'assign' });
  +}
  +
   
   1;
  
  
  
  1.4       +18 -1     parrot/languages/jako/lib/Jako/Construct/Statement/Assign.pm
  
  Index: Assign.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/Assign.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- Assign.pm 20 Dec 2002 01:59:08 -0000      1.3
  +++ Assign.pm 3 Feb 2003 11:49:27 -0000       1.4
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Assign.pm,v 1.3 2002/12/20 01:59:08 gregor Exp $
  +# $Id: Assign.pm,v 1.4 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -57,5 +57,22 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'assign' });
  +  $self->left->sax($handler);
  +  $self->right->sax($handler);
  +  $handler->end_element({ Name => 'assign' });
  +}
  +
   
   1;
  
  
  
  1.6       +17 -1     parrot/languages/jako/lib/Jako/Construct/Statement/Call.pm
  
  Index: Call.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/Call.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- Call.pm   20 Dec 2002 01:59:08 -0000      1.5
  +++ Call.pm   3 Feb 2003 11:49:27 -0000       1.6
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Call.pm,v 1.5 2002/12/20 01:59:08 gregor Exp $
  +# $Id: Call.pm,v 1.6 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -130,5 +130,21 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'call', Attributes => { name => $self->name } 
});
  +  $_->sax($handler) foreach $self->args;
  +  $handler->end_element({ Name => 'call' });
  +}
  +
   
   1;
  
  
  
  1.4       +17 -1     parrot/languages/jako/lib/Jako/Construct/Statement/Decrement.pm
  
  Index: Decrement.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/Decrement.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- Decrement.pm      20 Dec 2002 01:59:08 -0000      1.3
  +++ Decrement.pm      3 Feb 2003 11:49:27 -0000       1.4
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Decrement.pm,v 1.3 2002/12/20 01:59:08 gregor Exp $
  +# $Id: Decrement.pm,v 1.4 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -53,5 +53,21 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'op', Attributes => { kind => 'postfix', name 
=> '--' } });
  +  $self->ident->sax($handler);
  +  $handler->end_element({ Name => 'op' });
  +}
  +
   
   1;
  
  
  
  1.6       +38 -1     parrot/languages/jako/lib/Jako/Construct/Statement/Goto.pm
  
  Index: Goto.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/Goto.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- Goto.pm   20 Dec 2002 01:59:08 -0000      1.5
  +++ Goto.pm   3 Feb 2003 11:49:27 -0000       1.6
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Goto.pm,v 1.5 2002/12/20 01:59:08 gregor Exp $
  +# $Id: Goto.pm,v 1.6 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -100,6 +100,43 @@
     }
   
     return;
  +}
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  my $block = $self->block;
  +  my $name  = $self->ident ? $self->ident->value : undef;
  +  my $cond  = $self->cond;
  +  my $left  = $self->left;
  +  my $op    = $self->op;
  +  my $right = $self->right;
  +
  +  if (defined $cond) {
  +    $handler->start_element({ Name => 'cond', Attributes => { kind => $cond } });
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'test' } });
  +    $handler->start_element({ Name => 'op', Attributes => { kind => 'infix', name 
=> $op } });
  +    $left->sax($handler);
  +    $right->sax($handler);
  +    $handler->end_element({ Name => 'op' });
  +    $handler->end_element({ Name => 'block' });
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'then' } });
  +  }
  +
  +  $handler->start_element({ Name => 'goto', Attributes => { label => $name } });
  +  $handler->end_element({ Name => 'goto' });
  +
  +  if (defined $cond) {
  +    $handler->end_element({ Name => 'block' });
  +    $handler->end_element({ Name => 'cond' });
  +  }
   }
   
   
  
  
  
  1.4       +17 -1     parrot/languages/jako/lib/Jako/Construct/Statement/Increment.pm
  
  Index: Increment.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/Increment.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- Increment.pm      20 Dec 2002 01:59:08 -0000      1.3
  +++ Increment.pm      3 Feb 2003 11:49:27 -0000       1.4
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Increment.pm,v 1.3 2002/12/20 01:59:08 gregor Exp $
  +# $Id: Increment.pm,v 1.4 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -53,5 +53,21 @@
   
     return 1;
   }
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  $handler->start_element({ Name => 'op', Attributes => { kind => 'postfix', name 
=> '++' } });
  +  $self->ident->sax($handler);
  +  $handler->end_element({ Name => 'op' });
  +}
  +
   
   1;
  
  
  
  1.5       +44 -1     
parrot/languages/jako/lib/Jako/Construct/Statement/LoopControl.pm
  
  Index: LoopControl.pm
  ===================================================================
  RCS file: 
/cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/LoopControl.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- LoopControl.pm    20 Dec 2002 01:59:08 -0000      1.4
  +++ LoopControl.pm    3 Feb 2003 11:49:27 -0000       1.5
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: LoopControl.pm,v 1.4 2002/12/20 01:59:08 gregor Exp $
  +# $Id: LoopControl.pm,v 1.5 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -126,6 +126,49 @@
     }
   
     return;
  +}
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  my $block = $self->block;
  +  my $kind  = $self->kind;
  +  my $name  = $self->ident ? $self->ident->value : undef;
  +  my $cond  = $self->cond;
  +  my $left  = $self->left;
  +  my $op    = $self->op;
  +  my $right = $self->right;
  +
  +  if (defined $cond) {
  +    $handler->start_element({ Name => 'cond', Attributes => { kind => $kind } });
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'test' } });
  +    $handler->start_element({ Name => 'op', Attributes => { kind => 'infix', name 
=> $op } });
  +    $left->sax($handler);
  +    $right->sax($handler);
  +    $handler->end_element({ Name => 'op' });
  +    $handler->end_element({ Name => 'block' });
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'then' } });
  +  }
  +
  +  if ($name) {
  +    $handler->start_element({ Name => $kind, Attributes => { loop => $name } });
  +  }
  +  else {
  +    $handler->start_element({ Name => $kind });
  +  }
  +  $handler->end_element({ Name => $kind });
  +
  +  if (defined $cond) {
  +    $handler->end_element({ Name => 'block' });
  +    $handler->end_element({ Name => 'cond' });
  +  }
   }
   
   
  
  
  
  1.7       +39 -1     parrot/languages/jako/lib/Jako/Construct/Statement/Return.pm
  
  Index: Return.pm
  ===================================================================
  RCS file: /cvs/public/parrot/languages/jako/lib/Jako/Construct/Statement/Return.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- Return.pm 20 Dec 2002 01:59:08 -0000      1.6
  +++ Return.pm 3 Feb 2003 11:49:27 -0000       1.7
  @@ -5,7 +5,7 @@
   # This program is free software. It is subject to the same license
   # as the Parrot interpreter.
   #
  -# $Id: Return.pm,v 1.6 2002/12/20 01:59:08 gregor Exp $
  +# $Id: Return.pm,v 1.7 2003/02/03 11:49:27 gregor Exp $
   #
   
   use strict;
  @@ -141,6 +141,44 @@
     }
   
     return;
  +}
  +
  +
  +#
  +# sax()
  +#
  +
  +sub sax
  +{
  +  my $self = shift;
  +  my ($handler) = @_;
  +
  +  my $block = $self->block;
  +  my $value = $self->value;
  +  my $cond  = $self->cond;
  +  my $left  = $self->left;
  +  my $op    = $self->op;
  +  my $right = $self->right;
  +
  +  if (defined $cond) {
  +    $handler->start_element({ Name => 'cond', Attributes => { kind => $cond } });
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'test' } });
  +    $handler->start_element({ Name => 'op', Attributes => { kind => 'infix', name 
=> $op } });
  +    $left->sax($handler);
  +    $right->sax($handler);
  +    $handler->end_element({ Name => 'op' });
  +    $handler->end_element({ Name => 'block' });
  +    $handler->start_element({ Name => 'block', Attributes => { kind => 'then' } });
  +  }
  +
  +  $handler->start_element({ Name => 'return' });
  +  $value->sax($handler) if defined $value;
  +  $handler->end_element({ Name => 'return' });
  +
  +  if (defined $cond) {
  +    $handler->end_element({ Name => 'block' });
  +    $handler->end_element({ Name => 'cond' });
  +  }
   }
   
   
  
  
  


Reply via email to