Use push parser for selection parsing.
authorTeemu Murtola <teemu.murtola@gmail.com>
Thu, 14 Jun 2012 04:27:29 +0000 (07:27 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Wed, 20 Jun 2012 17:52:54 +0000 (20:52 +0300)
commit016d8bd9c73c58c54793d20bf7100f6293fdae9b
treecf565f181928e6113874e12ee45ea92c963bebd2
parentbe86c0ec9c246dcd1fc59ad11ebc3223c9234273
Use push parser for selection parsing.

The push parser is new in Bison 2.4 (current parser.cpp files generated
with 2.5), and has two benefits in our case:
- Clearer control flow, since the interactive prompt loop is now outside
  the parser, so it doesn't need to behave like a state machine.
- Allows better exception handling: since it is possible to directly
  return from Flex actions, we should also be able to throw exceptions.
  But without this change, they would go through the generated part of
  the Bison parser, causing memory leaks since the code is generated for
  C.  With this change, the Flex scanner is called directly from C++
  code, eliminating this problem.

Since the Bison and Flex parsers are now decoupled, it should also be
possible to clarify the code further, by having a separate data
structure for parser-specific data instead of using yyscan_t.  For now,
kept the changes to a minimum.

Related to #880.

Change-Id: I43ea11561d3dd0577dd95eae3794ca621953d038
13 files changed:
src/gromacs/selection/parser.cpp
src/gromacs/selection/parser.h
src/gromacs/selection/parser.y
src/gromacs/selection/scanner.cpp
src/gromacs/selection/scanner.h
src/gromacs/selection/scanner.l
src/gromacs/selection/scanner_flex.h
src/gromacs/selection/scanner_internal.cpp
src/gromacs/selection/scanner_internal.h
src/gromacs/selection/selectioncollection-impl.h
src/gromacs/selection/selectioncollection.cpp
src/gromacs/utility/file.cpp
src/gromacs/utility/file.h