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.
77 /** \brief cleanup parser internal buffers */
78 static void cleanup();
80 /** \brief parse the given file name */
81 void parseFile(const std::wstring& name, const std::wstring& progName);
83 /** \brief parse the given file command */
84 void parse(wchar_t *command);
86 /** \brief enable Bison trace mode */
87 void setParseTrace(bool parseTrace)
89 _parse_trace = parseTrace;
91 bool getParseTrace(void)
99 ast::Exp* getTree(void)
103 void setTree(ast::Exp* theProgram)
105 _the_program = theProgram;
108 ParserStatus getExitStatus(void)
112 void setExitStatus(ParserStatus exit_status)
114 _exit_status = exit_status;
117 ControlStatus getControlStatus(void)
119 return _control_status;
121 void setControlStatus(ControlStatus controlStatus)
123 _control_status = controlStatus;
126 wchar_t *getErrorMessage(void)
128 return const_cast<wchar_t *>(_error_message.c_str());
130 void setErrorMessage(std::wstring& errorMessage)
132 _error_message = errorMessage;
135 void enableStrictMode(void)
139 void disableStrictMode(void)
141 _strict_mode = false;
144 bool stopOnFirstError(void)
146 return _stop_on_first_error;
148 void enableStopOnFirstError(void)
150 _stop_on_first_error = true;
152 void disableStopOnFirstError(void)
154 _stop_on_first_error = false;
159 const std::wstring _file_name;
160 const std::wstring _prog_name;
161 std::wstring _error_message;
162 bool _stop_on_first_error;
165 ParserStatus _exit_status;
166 ControlStatus _control_status;
167 ast::Exp* _the_program;
170 #endif /* !__PARSER_HXX__ */