Generic character translation server.
This is not efficient. An efficient implementation would compile the candidates into a finite-state machine first. This doesn't do that.
send/2 | Sends a character or characters to an xlat server for translation. |
server/2 | Spawned by start/2 , should not be called
directly by user code. |
start/2 | Starts an xlat server. |
send(Pid::xlat(), Chars::char() | string()) -> ok
Sends a character or characters to an xlat server for translation.
server(Candidates::candidates(), Dest::pid()) -> never_returns()
Spawned by start/2
, should not be called
directly by user code.
start(Candidates::candidates(), Dest::pid()) -> xlat()
Starts an xlat server. Candidates is a list of pairs of strings.
Characters are sent to the xlat server with the send/2
function. When they match the left
string of a candidate, the right string is sent to Dest instead.
If they do not match any candidates, they are sent through unaltered.
Characters are sent to Dest in the form
{xlat(), xlat_char, char()}
.
Note that if two candidates have the same left string, the result of
the translation is undefined. Also note that if one candidate has
a left string that is a prefix of another candidate's left string,
that second candidate will never match (the shorter one will always
be matched first.)
Generated by EDoc, Feb 18 2008, 06:48:11.