From db48078736708a565805f33179fb8af477e024f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr> Date: Tue, 11 Sep 2012 14:26:53 +0200 Subject: [PATCH] Preprocessor interface for multiple graph formats --- doc/dynare.texi | 11 ++++++++--- preprocessor/DynareBison.yy | 21 +++++++++++++++------ preprocessor/ParsingDriver.cc | 14 ++++++++++++++ preprocessor/ParsingDriver.hh | 6 ++++++ 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index fb6d3e5d8..bf320a1db 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -3032,10 +3032,11 @@ used). (unless @code{nograph} is used). @item graph_format = @var{FORMAT} +@itemx graph_format = ( @var{FORMAT}, @var{FORMAT}@dots{} ) @anchor{graph_format} -Specify the file format for graphs saved to disk. Possible values are -@code{eps} (the default), @code{pdf} and @code{fig} (the latter is not -available under Octave). +Specify the file format(s) for graphs saved to disk. Possible values are +@code{eps} (the default), @code{pdf} and @code{fig} (under Octave, +only @code{eps} is available). @item noprint Don't print anything. Useful for loops. @@ -3959,6 +3960,7 @@ Default value is @code{1}. @xref{nodisplay}. @item graph_format = @var{FORMAT} +@itemx graph_format = ( @var{FORMAT}, @var{FORMAT}@dots{} ) @xref{graph_format}. @item lik_init = @var{INTEGER} @@ -4775,6 +4777,7 @@ interval. Default: @code{0.90} @xref{nodisplay}. @item graph_format = @var{FORMAT} +@itemx graph_format = ( @var{FORMAT}, @var{FORMAT}@dots{} ) @xref{graph_format}. @end table @@ -5711,6 +5714,7 @@ Critical value for correlation @math{\rho}: plot couples of parmaters with @xref{nodisplay}. @item graph_format = @var{FORMAT} +@itemx graph_format = ( @var{FORMAT}, @var{FORMAT}@dots{} ) @xref{graph_format}. @item conf_sig = @var{DOUBLE} @@ -5832,6 +5836,7 @@ Specify the parameter set to use. Default: @code{prior_mean} @xref{nodisplay}. @item graph_format = @var{FORMAT} +@itemx graph_format = ( @var{FORMAT}, @var{FORMAT}@dots{} ) @xref{graph_format}. @end table diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 2ee59d062..004291e16 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -2250,13 +2250,22 @@ o_nograph : NOGRAPH { driver.option_num("nograph", "0"); } ; o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); }; -o_graph_format : GRAPH_FORMAT EQUAL EPS - { driver.option_str("graph_format", "eps"); } - | GRAPH_FORMAT EQUAL FIG - { driver.option_str("graph_format", "fig"); } - | GRAPH_FORMAT EQUAL PDF - { driver.option_str("graph_format", "pdf"); } +o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats + { driver.process_graph_format_option(); } + | GRAPH_FORMAT EQUAL '(' list_allowed_graph_formats ')' + { driver.process_graph_format_option(); } ; +allowed_graph_formats : EPS + { driver.add_graph_format("eps"); } + | FIG + { driver.add_graph_format("fig"); } + | PDF + { driver.add_graph_format("pdf"); } + ; +list_allowed_graph_formats : allowed_graph_formats + | list_allowed_graph_formats COMMA allowed_graph_formats + ; + o_subsample_name : symbol EQUAL date_number ':' date_number { driver.set_subsample_name_equal_to_date_range($1, $3, $5); } ; diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 75dc4daaa..76a4e9515 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -2479,3 +2479,17 @@ ParsingDriver::add_steady_state_model_equal_multiple(expr_t expr) symbol_list.clear(); } + +void +ParsingDriver::add_graph_format(const string &name) +{ + graph_formats.addSymbol(name); +} + +void +ParsingDriver::process_graph_format_option() +{ + options_list.symbol_list_options["graph_format"] = graph_formats; + graph_formats.clear(); +} + diff --git a/preprocessor/ParsingDriver.hh b/preprocessor/ParsingDriver.hh index e6bbeba39..fdf188c3a 100644 --- a/preprocessor/ParsingDriver.hh +++ b/preprocessor/ParsingDriver.hh @@ -197,6 +197,8 @@ private: void reset_current_external_function_options(); //! Adds a model lagged variable to ModelTree and VariableTable expr_t add_model_variable(int symb_id, int lag); + //! For parsing the graph_format option + SymbolList graph_formats; //! The mod file representation constructed by this ParsingDriver ModFile *mod_file; @@ -628,6 +630,10 @@ public: void declare_nonstationary_var(string *name, string *tex_name = NULL); //! Ends declaration of nonstationary variable void end_nonstationary_var(expr_t deflator); + //! Add a graph format to the list of formats requested + void add_graph_format(const string &name); + //! Add the graph_format option to the OptionsList structure + void process_graph_format_option(); }; #endif // ! PARSING_DRIVER_HH -- GitLab