2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2008-2008 - INRIA - 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_HXX__
14 #define __PARSER_HXX__
24 #include "charEncoding.h"
25 #include "sci_malloc.h"
26 #include "dynlib_ast.h"
29 class EXTERN_AST Parser
33 _stop_on_first_error(false),
36 _exit_status(Succeded),
37 _control_status(AllControlClosed),
44 // Do not delete Tree here.
78 /** \brief parse the given file name */
79 void parseFile(const std::wstring& name, const std::wstring& progName);
81 /** \brief parse the given file command */
82 void parse(wchar_t *command);
84 /** \brief enable Bison trace mode */
85 void setParseTrace(bool parseTrace)
87 _parse_trace = parseTrace;
89 bool getParseTrace(void)
97 ast::Exp* getTree(void)
101 void setTree(ast::Exp* theProgram)
103 _the_program = theProgram;
106 ParserStatus getExitStatus(void)
110 void setExitStatus(ParserStatus exit_status)
112 _exit_status = exit_status;
115 ControlStatus getControlStatus(void)
117 return _control_status;
119 void setControlStatus(ControlStatus controlStatus)
121 _control_status = controlStatus;
124 wchar_t *getErrorMessage(void)
126 return const_cast<wchar_t *>(_error_message.c_str());
128 void setErrorMessage(std::wstring& errorMessage)
130 _error_message = errorMessage;
133 void enableStrictMode(void)
137 void disableStrictMode(void)
139 _strict_mode = false;
142 bool stopOnFirstError(void)
144 return _stop_on_first_error;
146 void enableStopOnFirstError(void)
148 _stop_on_first_error = true;
150 void disableStopOnFirstError(void)
152 _stop_on_first_error = false;
157 const std::wstring _file_name;
158 const std::wstring _prog_name;
159 std::wstring _error_message;
160 bool _stop_on_first_error;
163 ParserStatus _exit_status;
164 ControlStatus _control_status;
165 ast::Exp* _the_program;
168 #endif /* !__PARSER_HXX__ */