Skip to content

Commit

Permalink
fixed more things, added split function in variable dec, and also got…
Browse files Browse the repository at this point in the history
… variable dec working for variable interpolation
  • Loading branch information
haydenvr committed Oct 7, 2013
1 parent 617e9da commit 8f9a81a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
5 changes: 3 additions & 2 deletions diary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ Date Start Stop Activity Comments
8:00pm 8.25pm finished append to lists func
07/10 12:50pm 2:00pm fixed bug with comments
2:30pm 3.10pm trying to fix variable dec
4:40pm
Total Time: 1210min = 20hr 10min
4:40pm 6:00pm implemented more fixes including split in variable dec

Total Time: 1290min = 21hr 30min
27 changes: 19 additions & 8 deletions perl2python
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
# edited by hwav057@cse.unsw.edu.au for more functionality September and October 2013

#Do in order:
#3. need to do simple uses of printf in perl
#4. split function (happens in variable dec)
#5. range things such as 1..3
#5. arrays and push pop unshift reverse
#6. need to handle @array = <STDIN> or @array = <F>
#7. need to handle print "@array" and also note that print "@array hi there this is a message\n"
#8. need to be able to alter existing array elements, and use them?
#9. double hashes? ??
#??. split function (happens in variable dec) !!!!implemented successfully in variable dec, not sure where else
#1. arrays and push pop unshift reverse
#2. need to handle @array = <STDIN> or @array = <F>
#3. need to handle print "@array" and also note that print "@array hi there this is a message\n"
#4. need to be able to alter existing array elements, and use them?
#5. need to do simple uses of printf in perl
#6. double hashes? ??

our $tab = 0;
our @python_source = ();
Expand Down Expand Up @@ -133,6 +132,12 @@ sub handleOpen {
addToSourceArray("$arguments[0] = open(\"$arguments[1]\")\n");
}

sub handleSplit {
my $delimeter = $_[0];
my $variable = $_[1];
return "$variable.split('$delimeter')";
}

sub handleIntegerVariables {
#read in variables passed from the conditionHandling function
#and determine if it is a variable or constant
Expand Down Expand Up @@ -174,6 +179,11 @@ sub variableDec {
if ($variable_assign =~ /^\$([1-9])$/) {
$variable_assign = "m.group($1)";
}
if ($variable_assign =~ s/split\s*\/(.*)\/\,\s*\$([^ \.]+)/FIXME/) {
my $fix = handleSplit($1,$2);
$fix =~ s/\./LEGITDOT/;
$variable_assign =~ s/FIXME/$fix/;
}
if ($variable_name =~ /\[(.*)\]/) {
$variable_name = handleArray($variable_name);
($variable_name, $extra) = split /CUTMEHERE/,$variable_name;
Expand Down Expand Up @@ -284,6 +294,7 @@ sub variableDec {
$variable_assign =~ s/\$//g;
$line_to_print .= "$variable_assign";

$line_to_print =~ s/LEGITDOT/\./;
#$line_to_print .= "\n";
if ($using_array == 1) {
addToSourceArray("$variable_name$line_to_print)\n");
Expand Down

0 comments on commit 8f9a81a

Please sign in to comment.