Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I'm bringing goto back

Name: Anonymous 2014-02-09 11:15

Yeah, "goto considered harmful" considered harmful.
It's so easy to parse when it's one command per line...

Here's what I did so far


open FILE, "filename.txt" or die $!;

my @lines = <FILE>;
my %labels;

my $ind = 0;

while ($ind < @lines.length){
    my $cmd = @lines[$ind];
    if ($cmd =~ /^\s*(\w+):$/){
        if (!exists($labels{$1})){
            $labels{$1} = $ind;
        }
    }
    $ind++;
}

$ind = 0;

while ($ind < @lines.length){
    my $cmd = @lines[$ind];
    if ($cmd =~ /^\s*goto (\w+);$/){
        if (exists($labels{$1})){
            $ind = $labels{$1};
        }
    } elsif ($cmd =~ /^\s*print \"(.+)\";$/){
        print $1;
    }
    $ind++;
}


example program:

asd:
print "asd";
goto doge;
print "never printed";
doge:
print "aw! aw!";
goto asd;

Name: Anonymous 2014-02-09 13:00

>>4
line = 0;
while (line++ > 0)

>while (0 > 0)

also, I know that is possible, etc, but I just wanted a simple language to make to play with, and getting that low-level feel is cool

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List