biod.pnpi.spb.ru
/
alexxy
/
gromacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor for testing interactive selection input
[alexxy/gromacs.git]
/
src
/
gromacs
/
selection
/
parsetree.cpp
diff --git
a/src/gromacs/selection/parsetree.cpp
b/src/gromacs/selection/parsetree.cpp
index 79162acd922aeeef53b394c5a21a6fd3363eaaea..d1eb39fcf3081e1f5e1769c12b36677cea8d2f9e 100644
(file)
--- a/
src/gromacs/selection/parsetree.cpp
+++ b/
src/gromacs/selection/parsetree.cpp
@@
-66,8
+66,9
@@
* methods and initializes the children of the method element.
* - selectioncollection.h, selectioncollection.cpp:
* These files define the high-level public interface to the parser
* methods and initializes the children of the method element.
* - selectioncollection.h, selectioncollection.cpp:
* These files define the high-level public interface to the parser
- * through SelectionCollection::parseFromStdin(),
- * SelectionCollection::parseFromFile() and
+ * through SelectionCollection::parseInteractive(),
+ * SelectionCollection::parseFromStdin(),
+ * SelectionCollection::parseFromFile(), and
* SelectionCollection::parseFromString().
*
* The basic control flow in the parser is as follows: when a parser function
* SelectionCollection::parseFromString().
*
* The basic control flow in the parser is as follows: when a parser function
@@
-234,6
+235,7
@@
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
+#include "gromacs/utility/textwriter.h"
#include "keywords.h"
#include "poscalc.h"
#include "keywords.h"
#include "poscalc.h"
@@
-309,9
+311,11
@@
_gmx_selparser_handle_error(yyscan_t scanner)
catch (gmx::UserInputError &ex)
{
ex.prependContext(context);
catch (gmx::UserInputError &ex)
{
ex.prependContext(context);
- if (_gmx_sel_is_lexer_interactive(scanner))
+ gmx::TextWriter *statusWriter
+ = _gmx_sel_lexer_get_status_writer(scanner);
+ if (statusWriter != NULL)
{
{
- gmx::formatExceptionMessageTo
File(stder
r, ex);
+ gmx::formatExceptionMessageTo
Writer(statusWrite
r, ex);
return true;
}
throw;
return true;
}
throw;
@@
-1061,10
+1065,13
@@
_gmx_sel_init_selection(const char *name,
root->fillNameIfMissing(_gmx_sel_lexer_pselstr(scanner));
/* Print out some information if the parser is interactive */
root->fillNameIfMissing(_gmx_sel_lexer_pselstr(scanner));
/* Print out some information if the parser is interactive */
- if (_gmx_sel_is_lexer_interactive(scanner))
+ gmx::TextWriter *statusWriter = _gmx_sel_lexer_get_status_writer(scanner);
+ if (statusWriter != NULL)
{
{
- fprintf(stderr, "Selection '%s' parsed\n",
- _gmx_sel_lexer_pselstr(scanner));
+ const std::string message
+ = gmx::formatString("Selection '%s' parsed",
+ _gmx_sel_lexer_pselstr(scanner));
+ statusWriter->writeLine(message);
}
return root;
}
return root;
@@
-1128,9
+1135,12
@@
_gmx_sel_assign_variable(const char *name,
srenew(sc->varstrs, sc->nvars + 1);
sc->varstrs[sc->nvars] = gmx_strdup(pselstr);
++sc->nvars;
srenew(sc->varstrs, sc->nvars + 1);
sc->varstrs[sc->nvars] = gmx_strdup(pselstr);
++sc->nvars;
- if (_gmx_sel_is_lexer_interactive(scanner))
+ gmx::TextWriter *statusWriter = _gmx_sel_lexer_get_status_writer(scanner);
+ if (statusWriter != NULL)
{
{
- fprintf(stderr, "Variable '%s' parsed\n", pselstr);
+ const std::string message
+ = gmx::formatString("Variable '%s' parsed", pselstr);
+ statusWriter->writeLine(message);
}
return root;
}
}
return root;
}