Posted by Kspansel@xxx.xxx on 2000-02-12
That's kinda what I'm going for. But I want to check each element of an
array and take action depending on which one it matched. So I need to know
which one it matched. But..hmm..it's hard to explain what I'm thinking.
Okay lets say I'm creating a "new" programming language, keywords: string,
if, else, end. And i've parsed all of my source into tokens. Imaginary
source:
string str = "hello";
if (string == "hi")
{
end;
}
else
{
end;
}
Yeah..I know it's really original. But I've got my tokens and I want to
check each token to see if it's one of my keywords and take action depending
on which keyword it is. How would I do this? Or maybe there is a better
way? Any help appreciated. Thanks.
> my $userinput = <something>;
>
>
> #does it match?
> $userinput =~ /^(goodbye|hello|exit|quit|else)$/ || die ("you Luser\n");
To signoff send a mail to listserver@xxxx.xx.xx with
"signoff tcg" in the body of your message.
Previous post | Next post | Timeline | Home