- Sep 29, 2022
-
-
Sven M. Hallberg authored
Matches e.g. lr_answer, cached_lr, and our lower-case naming style in general.
-
Sven M. Hallberg authored
Use a consistent style for the heads of function definitions. Also breaks up the last line that was wider than 80 columns.
-
Sven M. Hallberg authored
Use one style consistently. C-style comments /* */ were originally prevalent in this file, so let's go with that.
-
Sven M. Hallberg authored
Not much left to do but to handle the out-of-input condition on all calls to perform_level_parse().
-
Sven M. Hallberg authored
Side benefit: Makes some copies and the hashtable lookups cheaper.
-
Sven M. Hallberg authored
This is a straight-forward refactoring that collects the 5 fields base, index, bit_offset, margin, and endianness from HInputStream into a substructure. They define the actual input position while the remaining fields input, length, overflow, and last_chunk represent dynamic stream state that changes between chunks. This should let us move to using only the HInputPosition in the packrat cache (HParserCacheKey).
-
- Sep 28, 2022
-
-
Sven M. Hallberg authored
This reads a bit clearer, but really it is in prepration for reusing 'pos' for a substructure holding all the members that make up the actual position. That in turn prepares for using only that structure as the key in the packrat cache. To carry the cache over from one chunk to the next, the keys must not depend on parts of the HInputStream that change between chunks, e.g. the 'input' pointer.
-
Sven M. Hallberg authored
-
Sven M. Hallberg authored
Chip away the small cases: finding a cached result, initiating LR handling. Add or reword some comments.
-
Sven M. Hallberg authored
This should be functionally equivalent, because a parser that isn't in the head's involved set cannot show up in it's eval set, either. Right?
-
Sven M. Hallberg authored
Eliminates an unneeded level of if and expands comments. Should be exactly equivalent code-wise.
-
Sven M. Hallberg authored
Analyzing the call sites of update_cached_result shows, I hope, that the call to perform_lowlevel_parse() in grow() will not modify the cached result if it fails: 1. The call in h_do_parse() is in the non-recursive case. 2. The call in lr_answer() happens before entering the grow() recursion. 3. The call at the end of grow() is not reached until later because grow() is only called recursively by itself. 4. The call in recall() only applies to parsers in the eval set of the parser in question, which is initialized from its involved set and only shrunk after that. The involved set of a parser p, however, does not include p itself.
-
Sven M. Hallberg authored
No longer needed since all cache updates are made in place (cf. 7f9f2808).
-
Sven M. Hallberg authored
This was a leftover from before the refactor of 38e47a62.
-
Sven M. Hallberg authored
Looking at the call site, the errx() case is properly unreachable.
-
Sven M. Hallberg authored
This is preparation to remove the re-lookup of cached results from grow().
-
Sven M. Hallberg authored
Remove an unnecessary variable in h_do_parse() and use the nicer freed-up name for another. Apply the same rename in perform_lowlevel_parse() for consistency.
-
Sven M. Hallberg authored
Should be an equivalent refactor that instead of conditionally enabling everything but one line in the higher-order case, chips off the primitive case at the very beginning.
-
Sven M. Hallberg authored
Consistently use one style of pointer syntax.
-
Sven M. Hallberg authored
- Declare variables at the top. - Convert to chip-away style. - Avoid come code duplication (done path). - Use assert() as appropriate, instead of errx(). - Add more comments.
-
Sven M. Hallberg authored
Includes a test that exercises both. Also fixes tracking of input position when suspending on the first chunk and adapts h_input_stream_pos and h_input_stream_length to multi-chunk operation.
-
- Sep 23, 2022
-
-
Sven M. Hallberg authored
The naive implementation concatenates all input and blindly re-runs the full parse on every chunk. Keeping state between chunks is for later. Note: The iterative API expects us to always consume an entire input chunk when we suspend, even if packrat later backtracks into it. We will produce the correct parse result and accurately consume from a final chunk, but all earlier chunks will be reported as fully consumed and as being part of the HParseResult in terms of its bit_length field.
-
Sven M. Hallberg authored
-
Sven M. Hallberg authored
NB: The 'z' size modifier is in C99.
-
- Sep 22, 2022
-
-
Sven M. Hallberg authored
This commit changes the contract for the combinator parse functions: (1) The input state on failure must retain valid overrun and last_chunk fields. The latter is never changed, but overrun would be cleared by various combinators that backtrack in case of failure. All other fields of the input stream are still considered indeterminate after a failed parse. (2) If an overrun condition is encountered before the final chunk (last_chunk is false), the parse *must* fail. A helper want_suspend() is introduced as a shorthand for this check. Fixes the packrat/iterative/dummy test.
-
Sven M. Hallberg authored
There's no need.
-
Sven M. Hallberg authored
This is the case where parsing stops, which may be a parse error or not, depending on how many elements were read.
-
Sven M. Hallberg authored
Replace it with an assert. This case could never occur because it tests precisely the loop condition and there are no break statements in the loop. This was the only use of the 'err' label, so that can go. The code under it remains the fall-through case for 'err0', i.e. the actual error (parse failure) case.
-
Sven M. Hallberg authored
The test fails because currently parsers that fail may leave the input stream in any indeterminate state. Parsers that backtrack (h_many, h_choice, h_optional, etc.) do not propagate an overrun of their subordinate parsers to h_packrat_parse_chunk where we would detect it and fail.
-
Sven M. Hallberg authored
-
Sven M. Hallberg authored
-
Sven M. Hallberg authored
Also includes a very important cosmetic whitespace change.
-
Sven M. Hallberg authored
Drive-by elimination of an age-old TODO. :) Code should be functionally equivalent. Changes: - Remove broken code under CONSISTENCY_CHECK. - Transform to chip-away style. - Remove braces around single statements. - Declare variables at top of function. - Shorten some variable names (tmp_res and bit_length). - Limit line length to 80 columns.
-
Sven M. Hallberg authored
A very first step. This implementation still expects all input in a single chunk but allows the use of the iterative API. If the parser attempts to read past the first chunk, the parse fails. Contains some comments for next steps towards full support. Adds tests for the single-chunk case.
-
- Sep 21, 2022
-
-
Andrea Shepard authored
add clang to tools if necessary See merge request hammer/hammer!50
-
- Aug 11, 2022
-
-
Sven M. Hallberg authored
-
Meredith L. Patterson authored
Ticket 95: Fix backends with params that currently ignore requested params to use them. Closes #95 See merge request hammer/hammer!49
-
- Aug 09, 2022
- Aug 08, 2022
-
-
Sven M. Hallberg authored
Lets one, e.g., add -fPIC if compiling with GCC but linking with LLD.
-