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

My take on Refactor2 #16

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open

Conversation

mingodad
Copy link
Contributor

No description provided.

ChrisHixon and others added 30 commits May 13, 2022 02:06
Removed the following from parser.h, which should only be in util.h:

char *esc_bytes(const unsigned char *bytes, int length, int limit);
Change Parser_parese signature to:

    int Parser_parse(Parser *self, const unsigned char *input, size_t length, size_t *consumed);

Previously, number of bytes consumed were returned on success, and negative values were returned for errors. To handle length up to SIZE_MAX, I changed the function to return bytes consumed in *consumed. Error return codes are now positive. Success is returned as 0, as before.

Extraneous input (consumed < length) is detected in Parser_parse and returned as error EXTRANEOUS_INPUT.
Remove unnecessary declaration of 'struct _CompilationUnit;'
previously:

    extern ChpegByteCode *Compiler_compile(const unsigned char *input, size_t length,
        int *result_return, int verbose);

now:

    extern int chpeg_compile(const unsigned char *input, size_t length,
        ChpegByteCode **bytecode_return, int verbose);

For consistency in API, return values should be int success/error codes;
anything else needs to be returned by setting a pointer passed in.
Replace ByteCode members with const ByteCode * inside Parser
Remove:
    const char *ChpegParser_def_name(ChpegParser *self, int index);
Use instead: (made extern)
    extern const char *ChpegByteCode_def_name(const ChpegByteCode *self, int index);
Remove error: CHPEG_ERR_INVALID_LENGTH = 5, (size_t length always >= 0)
Parser_parse() changes:
    - Use local variables to avoid following pointers in VM inner loop
    - Move RUNAWAY checking to SANITY_CHECKS
Add default memory allocation wrappers that exit upon failure.
mingodad added 30 commits May 31, 2022 10:20
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

Successfully merging this pull request may close these issues.

2 participants