-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 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,20 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
[spicy-verbose] - state: type=sync::Xs input="A<gap>..." stream=0xXXXXXXXX offsets=0/0/1027 chunks=3 frozen=no mode=default trim=yes lah=n/a lah_token="n/a" recovering=no | ||
[spicy-verbose] - parsing production: Unit: sync_Xs -> xs | ||
[spicy] sync::Xs | ||
[spicy-verbose] - state: type=sync::Xs input="A<gap>..." stream=0xXXXXXXXX offsets=0/0/1027 chunks=3 frozen=no mode=default trim=no lah=n/a lah_token="n/a" recovering=no | ||
[spicy-verbose] - parsing production: While: xs -> while(<look-ahead-found>): anon | ||
[spicy-verbose] - state: type=sync::Xs input="A<gap>..." stream=0xXXXXXXXX offsets=0/0/1027 chunks=3 frozen=no mode=default trim=no lah=1 lah_token="A" recovering=no | ||
[spicy-verbose] - state: type=sync::Xs input="A<gap>..." stream=0xXXXXXXXX offsets=0/0/1027 chunks=3 frozen=no mode=default trim=no lah=1 lah_token="A" recovering=no | ||
[spicy-verbose] - parsing production: Ctor: anon -> /(A|B|C)/ (regexp) (container 'xs') | ||
[spicy-verbose] - consuming look-ahead token | ||
[spicy-verbose] - got container item | ||
[spicy] failed to parse list element, will try to synchronize at next possible element | ||
[spicy-verbose] - state: type=sync::Xs input="<gap>..." stream=0xXXXXXXXX offsets=0/1/1027 chunks=3 frozen=no mode=default trim=no lah=n/a lah_token="n/a" recovering=yes | ||
[spicy-verbose] - state: type=sync::Xs input="C" stream=0xXXXXXXXX offsets=0/1026/1027 chunks=3 frozen=no mode=default trim=no lah=1 lah_token="C" recovering=yes | ||
[spicy-verbose] - state: type=sync::Xs input="C" stream=0xXXXXXXXX offsets=0/1026/1027 chunks=3 frozen=no mode=default trim=no lah=1 lah_token="C" recovering=no | ||
[spicy-verbose] - parsing production: Ctor: anon -> /(A|B|C)/ (regexp) (container 'xs') | ||
[spicy-verbose] - consuming look-ahead token | ||
[spicy-verbose] - got container item | ||
[spicy-verbose] suspending to wait for more input for stream 0xXXXXXXXX, currently have 0 | ||
[$xs=[b"A", b"C"]] |
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,39 @@ | ||
# @TEST-DOC: Validates that if a gap is encountered during recovery we can still resynchronize. | ||
# | ||
# @TEST-EXEC: spicyc -cdo sync.cc sync.spicy | ||
# @TEST-EXEC: spicyc -ldo sync-linker.cc sync.spicy | ||
# @TEST-EXEC: spicyc -Pdo sync.h sync.spicy | ||
# @TEST-EXEC: $(spicy-config --cxx-launcher --cxx) -o main main.cc sync.cc sync-linker.cc $(spicy-config --debug --cxxflags --ldflags) | ||
# @TEST-EXEC: HILTI_DEBUG=spicy:spicy-verbose ./main >output 2>&1 | ||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=${SCRIPTS}/canonify-spicy-debug btest-diff output | ||
|
||
# @TEST-START-FILE sync.spicy | ||
module sync; | ||
|
||
public type Xs = unit { | ||
xs: (/(A|B|C)/ &synchronize)[]; | ||
on %synced { confirm; } | ||
}; | ||
# @TEST-END-FILE | ||
|
||
# @TEST-START-FILE main.cc | ||
#include <hilti/rt/libhilti.h> | ||
|
||
#include "sync.h" | ||
|
||
int main() { | ||
hilti::rt::init(); | ||
|
||
auto xs = hilti::rt::reference::make_value<__hlt::sync::Xs>(); | ||
|
||
hilti::rt::ValueReference<hilti::rt::Stream> stream; | ||
stream->append("A"); | ||
stream->append(nullptr, 1024); // Gap. | ||
stream->append("BC"); | ||
|
||
hlt::sync::Xs::parse2(xs, stream, {}, {}); | ||
std::cout << xs << '\n'; | ||
|
||
hilti::rt::done(); | ||
} | ||
# @TEST-END-FILE |