2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 #ifndef __PARSER_PRIVATE_HXX__
14 #define __PARSER_PRIVATE_HXX__
18 class ParserSingleInstance
21 static Parser::ControlStatus getControlStatus(void)
23 if (!_control_status.empty())
25 return _control_status.front();
27 return Parser::AllControlClosed;
30 static void pushControlStatus(Parser::ControlStatus control_status)
32 //std::cout << "Push front : " << control_status << std::endl;
33 _control_status.push_front(control_status);
36 static void popControlStatus(void)
38 if (!_control_status.empty())
40 //std::cout << "Pop front" << std::endl;
41 //std::cout << "size = " << _control_status.size() << std::endl;
42 _control_status.pop_front();
46 static void resetControlStatus(void)
48 _control_status.clear();
51 static Parser::ParserStatus getExitStatus(void)
55 static void setExitStatus(Parser::ParserStatus exit_status)
57 _exit_status = exit_status;
60 static ast::Exp* getTree(void)
64 static void setTree(ast::Exp* theProgram)
66 _the_program = theProgram;
72 static void parse(char *command);
73 static void parseFile(const std::wstring& fileName, const std::wstring& progName);
78 static bool isStrictMode(void)
82 static void enableStrictMode(void)
86 static void disableStrictMode(void)
92 ** Manage error recovery mode
94 static bool stopOnFirstError(void)
96 return _stop_on_first_error;
98 static void enableStopOnFirstError(void)
100 _stop_on_first_error = true;
102 static void disableStopOnFirstError(void)
104 _stop_on_first_error = false;
108 ** Bison Debug management
110 static void enableParseTrace(void);
111 static void disableParseTrace(void);
114 ** File name management
116 static const std::wstring getFileName(void)
120 static void setFileName(const std::wstring& fileName)
122 _file_name = fileName;
126 ** Program Name Management
128 static const std::wstring getProgName(void)
132 static void setProgName(const std::wstring& progName)
134 _prog_name = progName;
138 ** Error Message management
140 static std::wstring& getErrorMessage(void);
141 static void appendErrorMessage(std::wstring ostr);
142 static void resetErrorMessage(void)
144 _error_message.clear();
148 ** \brief This funnction returns the parsed code written
149 ** at the given line.
150 ** out = getCodeLine(10, codeline)
151 ** When returning, out == *codeLine, _BUT_ out is allocated by a inner
152 ** function and must be manually free.
154 static char* getCodeLine(int line, char **codeLine);
156 static void PrintError(std::wstring msg);
159 static std::wstring _file_name;
160 static std::wstring _prog_name;
161 static std::wstring _error_message;
162 static bool _strict_mode;
163 static bool _stop_on_first_error;
164 static ast::Exp* _the_program;
165 static Parser::ParserStatus _exit_status;
166 static std::list<Parser::ControlStatus> _control_status;
167 static FILE* fileLocker;
171 #endif /* !__PARSER_PRIVATE_HXX__ */