Feature/scanner/option #27

Merged
bazaah merged 19 commits from feature/scanner/option into master 2021-09-09 19:29:29 +00:00

19 Commits

Author SHA1 Message Date
Paul Stemmet c79bcc8114
ci/prtasks: add matrix test for feature.test_buffer_small 2021-09-09 19:11:22 +00:00
Paul Stemmet 0e5a0f7949
lib/scanner: add feature gated test harness for tokens!
In essence, this allows us to test the Scanner's ability to handle
chunked byte streams, hooking directly into the existing test suite.

It has three levels large, medium and small where large is probably the
smallest buffer size + increment that could be considered reasonable
(4k/64), with the smaller two testing absurd buffers (8/8 and 1/1).
2021-09-09 19:06:19 +00:00
Paul Stemmet 0c58500a9b
Cargo: dev-dependencies.cfg-if = 1 2021-09-09 19:06:19 +00:00
Paul Stemmet 2272f1d9b1
lib/scanner: place state mutation after any O_EXTENDABLE events
this simply prevents state corruption in the Scanner by waiting to make
the changes until _after_ any errors would have been returned.

While this works, its not immediately obvious in the code why the
operations are ordered the way they are. I should document this
probably.
2021-09-09 19:06:19 +00:00
Paul Stemmet 998c86c1e4
lib/scanner: save any changes that may occur after a ScanError::Extend
before there was a subtle error when eating whitespace wherein the
whitespace could be eaten twice, which corrupts the Scanner.stats.

Now we ensure that any movement is captured before returning the error
to the caller
2021-09-09 19:06:19 +00:00
Paul Stemmet e6ad1e8434
lib/scanner: clippy 2021-09-09 19:06:19 +00:00
Paul Stemmet fe79f121fb
scalar/block: cache! before fetch
also fix call stack in lib/scanner
2021-09-09 19:06:19 +00:00
Paul Stemmet 89225e1481
scalar/plain: cache! before fetch
also fix the call stack in lib/scanner
2021-09-09 19:06:19 +00:00
Paul Stemmet bca953716f
scanner/anchor: cache! before fetch 2021-09-09 19:06:19 +00:00
Paul Stemmet 39b33ccd7e
scalar/escape: fix tests 2021-09-09 19:06:18 +00:00
Paul Stemmet 8b68d2f8e4
scalar/flow: cache! before fetch
also fixes the call stack in lib/scanner
2021-09-09 19:06:18 +00:00
Paul Stemmet 0191169ad6
scanner/tag: cache! before fetch
note that this commit also fixes code that fetch_directive uses
2021-09-09 19:06:18 +00:00
Paul Stemmet dc10680862
scanner/directive: cache! before fetch 2021-09-09 19:06:18 +00:00
Paul Stemmet 55b8f31b7b
lib/scanner: cache! before fetch in scan_next_token 2021-09-09 19:06:17 +00:00
Paul Stemmet 71dd1a52d5
lib/scanner: add opts to scan_tokens, eat_whitespace cache!
This commit adds initial support for cache!-ing characters in the
Scanner, starting with eat_whitespace.
2021-09-09 19:06:17 +00:00
Paul Stemmet c00e78a601
scanner/macros: add cache!
cache! allows the Scanner to state that it requires 'N' more codepoints
before it can correctly process the byte stream.

Its primary purpose is its interaction with O_EXTENDABLE, which allows
the caller to hint to the Scanner that the buffer could grow, likewise
cache! returns an error that hints to the caller that they should extend
the byte stream before calling the Scanner again -- or pass opts without
O_EXTENDABLE.
2021-09-09 19:06:17 +00:00
Paul Stemmet e7d68e8514
scanner/error: add variant Extend
This variant suggests to the caller that they should extend the byte
stream before calling the Scanner again.
2021-09-09 12:17:06 +00:00
Paul Stemmet a0ad61b7ba
scanner/flag: add Flags for Scanner control
This struct is a C style bitflag container, which controls various
aspects of Scanner functionality.

The initial flags available are O_ZEROED, O_EXTENDABLE and O_LAZY. Read
each's documentation for an explanation.
2021-09-09 08:12:50 +00:00
Paul Stemmet 6d09555178
Cargo: add dependencies.bitflags = 1 2021-09-09 08:04:10 +00:00