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

Way to represent repetition until terminator #2

Open
hansihe opened this issue Apr 6, 2017 · 6 comments
Open

Way to represent repetition until terminator #2

hansihe opened this issue Apr 6, 2017 · 6 comments

Comments

@hansihe
Copy link
Member

hansihe commented Apr 6, 2017

No description provided.

@ghost
Copy link

ghost commented May 2, 2017

ProtoDef-io/ProtoDef#8

@type binary("utf8")
def_native("delimited_string") {
    argument("terminator", match: "\x00");
};

Or maybe match: "0" or match: 0, but accept different constant types?

@hansihe
Copy link
Member Author

hansihe commented May 3, 2017

I think you misunderstand what argument for native types does.

It declares a slot where you can pass an argument when using the type.

@CertainLach
Copy link
Contributor

Is this thing needed? May be cstring should be implemented in native instead of defining it?

@hansihe
Copy link
Member Author

hansihe commented Aug 27, 2017

@creeplays Sure, cstring would probably be implemented as a native type.

The reason we need this is mainly because of other things. An example of this is the NBT format, where a compound tag is a list of named values until a terminator tag.

@CertainLach
Copy link
Contributor

What about implementing new syntax for this?
Like this:

array(terminator: "0") => container {};

@hansihe
Copy link
Member Author

hansihe commented Aug 28, 2017

That would work for that one specific case, but it's not a general solution, and it doesn't scale to other things.

For it to be a truly general solution, it would need to compose well with the other parts of the language.

rom1504 pushed a commit that referenced this issue Jun 8, 2018
Fix compilation with wasm32-unknown-unknown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants