Another test - tokenizer.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-02-07 18:43:58 +01:00
parent 6927c5c038
commit 5d3acf74d0
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 40 additions and 0 deletions

36
tests/tokenizer.aer Normal file
View File

@ -0,0 +1,36 @@
class StringTokenizer {
private $token;
private $delim;
public function __construct(string $str, string $delim = ' ') {
$this->token = strtok($str, $delim);
$this->delim = $delim;
}
public function __destruct() {
unset($this);
}
public function hasMoreTokens() {
return ($this->token !== false);
}
public function nextToken() {
string $current = $this->token;
$this->token = strtok($this->delim);
return $current;
}
}
class Program {
function main() {
string $str = "This is:@\t\n a TEST!";
string $delim = " !@:\t\n";
object $st = new StringTokenizer($str, $delim);
while ($st->hasMoreTokens()) {
print($st->nextToken(), "\n");
}
unset($st);
}
}

4
tests/tokenizer.exp Normal file
View File

@ -0,0 +1,4 @@
This
is
a
TEST