Releases: mnemnion/zitron
Use types as minor union tags
This update exploits one of Zig's distinctive features, allowing
any string to serve as an identifier using @"at syntax", to reuse
as tags the actual definition of the types they refer to.
This greatly improves the readability of generated code, which, as
Zig presently lacks a facility to map generated code in errors etc.
back to its origin, is expected to substantially ameliorate the impact
of that deficit on debugging of Zitron parsers.
Correctly handle whitespace padding in %extra-type declarations
Before this release, any left-side whitespace as in
%extra_context { foo: *Bar }
Would result in attempting to use the variable name foo:. A shallow bug, which could be worked around by removing the whitespace. But this is no longer necessary as of v0.1.7.
Suppress action compression when rule uses %impl
The compression of the action tables is meant to skip rules which
have associated code, which is tracked by a Boolean flag on the
Rule. Rules where the code action is defined by an %impl were not
being set correctly, and if they were optimize-able, this would
prevent the action from triggering during the reduction. The code
translation sets this flag, such that the code was emitted, but
this happens after the rule compression, all of which was fairly
mysterious.
This has been corrected.
Always decrement stack
The infinite loop was, in fact, a scope error: the stack decrement was
only executed when the object on the stack had a destructor.
This is no longer the case.
Flips boolean flag, errors at end of input don't infinite loop
The sense of an a-bit-clever @hasDecl boolean was flipped, affecting the error recovery strategy chosen (default: none, instead of default: default).
When combined with a syntax error consisting of truncated input (that is, the first invalid 'token' is .end_of_input / comes from .finalize() (same-same)), this triggered an infinite loop.
This release provides the intended default. I am still diagnosing whether the opposite-valence behavior is itself a bug, it involves undocumented features of Lemon which are only mentioned in passing in the Zitron manual.
In any case, an unexpected end-of-input syntax error will do the expected thing, provided the "magic zitron string" zitron_no_error_recovery is not set in the parser code. I would suggest not doing so, and if you do, throw from a %parse_failure block.
Handle destructors with no code
If a type has a destructor, and a reduction of that type has no captures
and no code body, a prefix is generated to run that destructor. Zitron
incorrectly looked for the code body to gate all of the codegen, not
checking the prefix, code, and suffix separately.
This situation resulted in a reduce action which is malformed Zig, which
has now been corrected.
Parser fix for `@foo(A)` with no `;`
The parser wanted a ; even when the rule has no RHS alias,
which is unreasonable. Compounding the problem, error recovery
was not properly clearing state, triggering a (correct) assertion
which would crash the program.
The syntax is now accepted, and comparable errors clean up properly,
and hence, will not crash.
Include templates in build.zig.zon
As well as samples/, and docs/. That last one may not be
necessary, but I'd rather not find out.
So this release might just build correctly. Please raise an issue if it doesn't!
The Zitron Parser Generator
Initial release.
See the documentation for details.