Re: Supporting multiple input syntaxes

luser droog <mijoryx@yahoo.com.dmarc.email>
Thu, 20 Aug 2020 14:45:28 -0700 (PDT)

          From comp.compilers

Related articles
[3 earlier articles]
Re: Supporting multiple input syntaxes minforth@arcor.de (2020-08-13)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-13)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-13)
Supporting multiple input syntaxes davidlovemore@gmail.com (David Lovemore) (2020-08-15)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-15)
Re: Supporting multiple input syntaxes davidlovemore@gmail.com (David Lovemore) (2020-08-16)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-20)
Re: Supporting multiple input syntaxes gah4@u.washington.edu (gah4) (2020-08-23)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-23)
Re: implementation languages, was Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-23)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-23)
Re: implementation languages, was Supporting multiple input syntaxes tkoenig@netcologne.de (Thomas Koenig) (2020-08-24)
Re: stack languages, was Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-24)
[6 later articles]
| List of all articles for this month |
From: luser droog <mijoryx@yahoo.com.dmarc.email>
Newsgroups: comp.compilers
Date: Thu, 20 Aug 2020 14:45:28 -0700 (PDT)
Organization: Compilers Central
References: 20-08-002 20-08-009 20-08-010 20-08-011
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="68517"; mail-complaints-to="abuse@iecc.com"
Keywords: parse
Posted-Date: 23 Aug 2020 14:39:28 EDT
In-Reply-To: 20-08-011

On Sunday, August 16, 2020 at 10:53:24 AM UTC-5, davidl...@gmail.com wrote:
> My friend, reporting the furthest position examined by the parser I have [found]
> useful in error cases as a simple stop gap when using a combinator approach.
>
> Thinking about it you kind of want to see the furthest failed position and the
> stack of rules above it. Such requires meta information when the code is
> written in the most natural way. For this reason and others I believe it is
> good to represent your grammar in data structures which is further in the
> direction of a compiler compiler tool (or compiler interpreter tool).


Thanks. I've done some further investigating. I built my parsers following
two papers. Hutton and Meijer, Monadic Parser Combinators
    https://www.cs.nott.ac.uk/~pszgmh/monparsing.pdf
and Hutton, Higher-Order Functions for Parsing
    https://pdfs.semanticscholar.org/6669/f223fba59edaeed7fabe02b667809a5744d9.pdf


The first adds error reporting using Monad Transformers. I'm thinking about
how to move in this direction, but first I'd need to reformulate the code to
make the Monad more explicit. It should be something like an interface or
a mixin, like a base class with all virtual member functions. That could be
done by modelling my objects more like OO objects and have 'bind' and
'result' in a vtable in the Parser object.


But the second paper does it differently, and maybe something I can do
more easily. It redefines the parsers to no longer produce a list of results,
so there's no longer support for ambiguity. Then it defines them to
return a Maybe,


    maybe * ::= Fail [char] | Error [char] | OK *
.
where the OK branch has the parse tree, and Fail or Error both contain an error
message. It describes how a Fail can be transformed into an Error. But it isn't
entirely clear where the messages get injected.


Still need to do some thinking on it, but I think I can rewrite the parsers
to follow this model, and then decorate my grammar with possible errors
at each node.


Thanks for the encouragement. My classes start on Monday so I'm hoping
to accomplish something on this before then.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.