"Fossies" - the Fresh Open Source Software Archive

Member "fityk-1.3.1/fityk/runner.h" (13 May 2016, 3174 Bytes) of package /linux/misc/fityk-1.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "runner.h" see the Fossies "Dox" file reference documentation.

    1 // This file is part of fityk program. Copyright 2009 Marcin Wojdyr.
    2 // Licence: GNU General Public License ver. 2+
    3 
    4 #ifndef FITYK_RUNNER_H_
    5 #define FITYK_RUNNER_H_
    6 
    7 #include <vector>
    8 #include "lexer.h" // Token, TokenType
    9 #include "fityk.h" // RealRange
   10 #include "common.h" // DISALLOW_COPY_AND_ASSIGN
   11 #include "eparser.h" // for ExpressionParser
   12 #include "cparser.h" // Parser
   13 
   14 namespace fityk {
   15 
   16 class Full;
   17 struct Statement;
   18 struct Command;
   19 class Data;
   20 
   21 RealRange args2range(const Token& t1, const Token& t2);
   22 void token_to_data(Full* F, const Token& token, std::vector<Data*>& dms);
   23 
   24 class Runner
   25 {
   26 public:
   27     Runner(Full* F) : F_(F), vdlist_(NULL), ep_(F) {}
   28 
   29     // Execute the last parsed string.
   30     // Throws ExecuteError, ExitRequestedException.
   31     // The statement is not const, because expressions in it can be re-parsed 
   32     // when executing for multiple datasets.
   33     void execute_statement(Statement& st);
   34 
   35 private:
   36     Full* F_;
   37     std::vector<VMData>* vdlist_;
   38     ExpressionParser ep_;
   39 
   40     void execute_command(Command& c, int ds);
   41     void command_set(const std::vector<Token>& args);
   42     void command_delete(const std::vector<Token>& args);
   43     void command_delete_points(const std::vector<Token>& args, int ds);
   44     void command_exec(TokenType tt, const std::string& str);
   45     void command_fit(const std::vector<Token>& args, int ds);
   46     void command_guess(const std::vector<Token>& args, int ds);
   47     void command_plot(const std::vector<Token>& args, int ds);
   48     void command_ui(const std::vector<Token>& args);
   49     void command_undefine(const std::vector<Token>& args);
   50     void command_load(const std::vector<Token>& args);
   51     void command_dataset_tr(const std::vector<Token>& args);
   52     void command_name_func(const std::vector<Token>& args, int ds);
   53     void command_all_points_tr(const std::vector<Token>& args, int ds);
   54     void command_point_tr(const std::vector<Token>& args, int ds);
   55     void command_resize_p(const std::vector<Token>& args, int ds);
   56     void command_assign_param(const std::vector<Token>& args, int ds);
   57     void command_assign_all(const std::vector<Token>& args, int ds);
   58     void command_name_var(const std::vector<Token>& args, int ds);
   59     void command_change_model(const std::vector<Token>& args, int ds);
   60     void recalculate_command(Command& c, int ds, Statement& st);
   61     int make_func_from_template(const std::string& name,
   62                                 const std::vector<Token>& args, int pos);
   63     VMData* get_vm_from_token(const Token& t) const;
   64     void defval_to_vm(const std::string& dv,
   65                       const std::vector<std::string>& names,
   66                       const std::vector<realt>& values,
   67                       VMData& output);
   68 };
   69 
   70 class CommandExecutor
   71 {
   72 public:
   73     CommandExecutor(Full* F) : parser_(F), runner_(F) {}
   74 
   75     /// share parser -- it can be safely reused
   76     Parser* parser() { return &parser_; }
   77 
   78     // Calls Parser::parse_statement() and Runner::execute_statement().
   79     void raw_execute_line(const std::string& str);
   80 
   81 private:
   82     Parser parser_;
   83     Runner runner_;
   84     DISALLOW_COPY_AND_ASSIGN(CommandExecutor);
   85 };
   86 
   87 } // namespace fityk
   88 #endif //FITYK_RUNNER_H_