-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow match to take a table of pattern -> handlers instead, and match the earliest and longest pattern that we find in the output buffer. Signed-off-by: Kyle Evans <[email protected]>
- Loading branch information
Showing
7 changed files
with
133 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- Executed like `./orch -f cat-multi.orch -- cat` -- this one won't spawn | ||
-- anything itself, so it must be done on the command line. | ||
|
||
-- We get released on first match anyways, so this doesn't need to be called: | ||
-- release() | ||
|
||
write "Send One Two\r" | ||
match { | ||
One = function() | ||
write "LOL\r" | ||
|
||
debug "Matched one" | ||
match "LOL" { | ||
callback = function() | ||
debug "lol" | ||
write "Foo\r" | ||
end | ||
} | ||
-- Also valid: | ||
-- write "Foo" | ||
match "Foo" { | ||
callback = function() | ||
debug "foo matched too" | ||
end | ||
} | ||
end, | ||
Two = function() | ||
debug "Called two" | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- What we write to cat(1) should come straight back to us. | ||
write "Hello\rPANIC: at the disco\r" | ||
|
||
match { | ||
PANIC = function() | ||
exit(1) | ||
end, | ||
Hello = function() | ||
-- Should trigger on Hello every time, since it's the earliest match. | ||
end, | ||
} | ||
|
||
-- Make sure that we didn't flush PANIC from the buffer. | ||
match "PANIC" |