bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 0/7] RFC: yypstate_clear (ATTENTION push parser users)


From: Akim Demaille
Subject: [PATCH 0/7] RFC: yypstate_clear (ATTENTION push parser users)
Date: Sun, 28 Jun 2020 16:52:13 +0200

(Also available on https://github.com/akimd/bison/pull/41)

Push parser users should pay special attention to these changes, and
provide feedback.

If you are used to code such as

```
yypstate *ps = yypstate_new ();
for (int i = 1; i < argc; ++i)
  yypull_parse (ps);
yypstate_delete (ps);
```

you will have to make it

```
yypstate *ps = yypstate_new ();
for (int i = 1; i < argc; ++i)
  {
    yypstate_clear (ps);
    yypull_parse (ps);
  }
yypstate_delete (ps);
```

IMHO, the previous design was flawed, as it prevented introspecting
the parser state to see what happened.  Besides, if the initial stacks
were too smalls, and had been enlarged, in the later runs we are back
to using the "small" stacks.

These changes allowed to fix undesirable behaviors in autocompletion.
But I also expect we will want more means to study the state stack in
the future, so we should really preserve our parser state.

In the future, we could also not clear the stack at the end of
parsing, but in yypstate_clear and yypstate_delete.  This could have
some impact on when users expect the destructors are called, so that's
a whole new chapter.

Akim Demaille (7):
  yacc.c: simplify yypull_parse
  yacc.c: style changes in push mode
  yacc.c: declare and initialize and the same time
  regen
  yacc.c: simplify initialization of push parsers
  bistromathic: don't display undefined locations
  yacc.c: push: don't clear the parser state when accepting/rejecting

 NEWS                                      |  16 +++
 TODO                                      |  14 --
 data/skeletons/yacc.c                     | 165 ++++++++++------------
 doc/bison.texi                            |  19 ++-
 examples/c/bistromathic/bistromathic.test |  22 +++
 examples/c/bistromathic/parse.y           |  15 +-
 src/parse-gram.c                          |  64 +++------
 src/parse-gram.h                          |   2 +-
 tests/torture.at                          |   3 +-
 9 files changed, 169 insertions(+), 151 deletions(-)

-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]