all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alexandr Karbivnichyi <ambulajan@gmail.com>
To: Lynn Winebarger <owinebar@gmail.com>
Cc: Eric Ludlam <ericludlam@gmail.com>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: Using the wisent parser-generator, as it creates faster parsers
Date: Mon, 26 Dec 2022 20:13:27 +0200	[thread overview]
Message-ID: <27990365a2b32aaa3f76fe8f0922a8481d953ef6.camel@gmail.com> (raw)
In-Reply-To: <CAM=F=bAw9rJb36kkxAweJ=1ieeWCNMav73y_zT+Zf4auAtyr4g@mail.gmail.com>

On Mon, 2022-12-26 at 08:54 -0500, Lynn Winebarger wrote:
> On Sun, Dec 25, 2022, 11:03 PM <ambulajan@gmail.com> wrote:
> 
> I don't agree - conflicts detected by the parser generator indicate
> that distinct ASTs map to the same text, at least according to the
> reduction method being used.  I like using LR derivations (including
> ones produced by LALR) because of the bottom-up recognition of
> grammar symbols. 

True for LALR parsers. Tried-and-tested system, for industrial
compilers built on a formal standard with simple grammar that doesn't
change often.
I explored parsing from time to time having in mind an idealistic view
of a system where given some grammar a lot of automatic features appear
almost ready for use.
So AST. It's required unambiguous to generate assembler mnemonics. It's
unavoidable in LALR to build AST in order to make any sense of the
parse.
Earley parser creates a state(list of grammar rules) at each scan
step(shift). I discovered that it's all what's needed at this stage in
the case when I don't intent to create executable. The state contains
all current grammar rules with a "dot" inside them(rule's progress at
point), from all possible parse trees. It's enough to compute
indentation, create smart completion, compose explicative error
messages.
The beauty of Early's algorithm is in possibility to write some grammar
and then keeping in mind the algorithm to write states by hand in a
text file for each token. The parser concept prints those states in
Message buffer, provides human readable interface. It gives an analogy
of 'syntax-ppss' function(elisp reader) but with full grammar contex. 

After all, the possibility of invoking one parser with different lexers
turns out to be an interesting idea. For different purposes. Some
tokens can be just blocks of text, either not contributing to the
current purpose or put aside to be reparsed recursively when contents
of that block-token change while editing.

> The above is not to discourage adding Earley parsing to the toolkit. 
> However, just defers the to resolution of ambiguities to your code
> rather than by refining your grammar. For specifying a programming
> language, this seems like inviting difficult to debug cases to me.  

And reciprocally not to discourage usage of existing tried-and-tested
parsers. Semantic allows that a parser may(should) be a separate
library. All in all, it's Emacs.

GLR algorithm doesn't reject grammar with conflicts and doesn't use
defaults to resolve. It's a LALR parser that starts parallel branches
for conflicts. Then after subsequent shifts only one branch survives -
conflict is resolved. The problem is that all parsing branches invoke
actions, all actions must be cached somehow during parsing and only
those actions of the survived branch to be included in parser's output.

In any case, there are no other tools in existence than Emacs that
would allow even reasoning about these ideas implying their practical
implementation.



  reply	other threads:[~2022-12-26 18:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26  4:02 Using the wisent parser-generator, as it creates faster parsers ambulajan
2022-12-26 13:54 ` Lynn Winebarger
2022-12-26 18:13   ` Alexandr Karbivnichyi [this message]
2022-12-28  3:22     ` Lynn Winebarger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27990365a2b32aaa3f76fe8f0922a8481d953ef6.camel@gmail.com \
    --to=ambulajan@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=ericludlam@gmail.com \
    --cc=owinebar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.