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

Semantic predicate failures as declared Exceptions #2

Closed
zhong-j-yu opened this issue Sep 3, 2021 · 1 comment
Closed

Semantic predicate failures as declared Exceptions #2

zhong-j-yu opened this issue Sep 3, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@zhong-j-yu
Copy link
Owner

zhong-j-yu commented Sep 3, 2021

If the invocation of a ctor throws an Exception, the type of which is declared in the throws clause, it is considered a semantic predicate failure; the corresponding production rule is considered to fail to match the input. But this is not fatal, the parser will try alternatives if there's any.

If a ctor throws any other Exception, it is a Fatal error that stops the parser immediately.

If a ctor throws an Error, we do not catch it or handle it, it will propagate out of our parser. It is more fatal than Fatal.

@zhong-j-yu zhong-j-yu changed the title Declared Exception as semantic predicate Semantic predicate failures as declared Exceptions Sep 4, 2021
@zhong-j-yu zhong-j-yu self-assigned this Sep 4, 2021
@zhong-j-yu zhong-j-yu added the enhancement New feature or request label Sep 4, 2021
@zhong-j-yu zhong-j-yu added this to the 1.1.0 milestone Sep 6, 2021
@zhong-j-yu
Copy link
Owner Author

Previously, whenever a ctor throws an IllegalArgumentException, it's considered a semantic predicate failure.

The new design requires that predicate failures be declared in method signature, thus the parser knows whether a ctor may contain semantic predicates. If a ctor contains semantic predicates, the ctor must be invoked to see if it satisfies the predicates; if not, move on to succeeding alternatives. But if a ctor does not contain predicates, it does not need to be invoked immediately; it could be invoked much later, e.g. at the end of the parsing process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant