Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

&parse-at cannot be used with external stream #1523

Open
bbannier opened this issue Sep 11, 2023 · 0 comments
Open

&parse-at cannot be used with external stream #1523

bbannier opened this issue Sep 11, 2023 · 0 comments
Labels
Enhancement Improvement of existing functionality

Comments

@bbannier
Copy link
Member

We currently explicitly disallow in the documentation to use &parse-at with an external stream. This is not symmetric with &parse-from which allows external data. I think it would make sense to allow using &parse-at with an external stream so users can directly control the stream (something which we do not allow for the usual input stream).

Properly supporting this probably requires correct tracking of current unit iterator (begin and position).

Currently the following fails (like documented):

module foo;

global s = stream(b"\x00\x01\x02");

public type X = unit {
    x: uint8 &parse-at=s.at(0);
};
$ echo | spicy-dump foo.spicy
[fatal error] terminating with uncaught exception of type hilti::rt::InvalidIterator: incompatible iterator (foo.spicy:6:8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

1 participant