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

[Question/Discussion] Rework of the Parser to support more information on its output #139

Open
ProIcons opened this issue Oct 2, 2022 · 0 comments

Comments

@ProIcons
Copy link

ProIcons commented Oct 2, 2022

Would you be open on a Parser that doesn't throw Exceptions but instead returns ParsingResults with the MustacheTemplate inside it, and the ParserContext. And in case of a failure the ParsingFailure and the state of the Processor up until this point to be included?

Then on the Rendering Side of things, the possible exceptions could be unwrapped and be thrown.

I'm considering into using your Parser for a LanguageServer I'm making to provide IntelliSense for Monaco Editors for Mustache. Exceptions are heavy, so I was thinking if you're open on this idea on converting your parser to support returning this Structure and exiting early when a failure happens, without the throwing of an exception.

This could be achieved in two ways; the first approach would be for all the Inline/Block parsers to return a Struct/Class object with the result of their processing. This however would throw an exception on an unhandled issue. The second approach would be to use LanguageExt and utilized their monads which can be used to catch an exception as early as possible and wrap it in a Try<>, Unit, Either<,> or whatever else. This minimizes the impact of the exception throwing.

@ProIcons ProIcons changed the title [Question/Discussion] [Question/Discussion] Rework of the Parser to support more information on its output Oct 2, 2022
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

1 participant