[m-users.] Determinism issue with parser

Volker Wysk post at volker-wysk.de
Mon Jul 5 01:21:07 AEST 2021

Am Sonntag, den 04.07.2021, 14:17 +0100 schrieb Sean Charles
> I parse a file into a stream of tokens, there can be only one correct way
> to parse those into a well formed program. One. So the ast builder either
> fails or it doesnt, that is trapped in the code and a maybe_error is
> handed back, hence I figure the predicate, as seen by the caller (the REPL
> atm) should be `det`.

I've built a big parser for my project, too. It should always produce one
solution; it can't fail. But the compiler can't infer that it is
deterministic, for many parts of it. (That would be undecidable.) 

So I've resigned to this state of affairs. I just collect all the (exactly
one) solutions with solutions/2 and produce an error message in case there
should be more than one, which would be a bug in my parser.

So maybe this would be the way to go for you, too.

Good luck,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20210704/f07a8927/attachment.sig>

More information about the users mailing list