#include "config/configcompiler.hpp"
#include "config/typerule.hpp"
-#include "config/configcompilercontext.hpp"
#include "config/expression.hpp"
using namespace icinga;
#include "config/config_parser.hh"
#include <sstream>
-#define YYLTYPE icinga::DebugInfo
+#define YYLTYPE icinga::CompilerDebugInfo
#define YY_EXTRA_TYPE ConfigCompiler *
#define YY_USER_ACTION \
yycolumn += yyleng; \
} while (0);
-#define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } else { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC(Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC(Rhs, 0).last_column; \
- } \
- while (YYID(0))
-
#define YY_INPUT(buf, result, max_size) \
do { \
result = yyextra->ReadInput(buf, max_size); \
%x HEREDOC
%%
-\" { yyextra->m_LexBuffer.str(""); yyextra->m_LexBuffer.clear(); BEGIN(STRING); }
+\" {
+ yyextra->m_LexBuffer.str("");
+ yyextra->m_LexBuffer.clear();
+
+ yyextra->m_LocationBegin = *yylloc;
+
+ BEGIN(STRING);
+ }
<STRING>\" {
BEGIN(INITIAL);
+ yylloc->FirstLine = yyextra->m_LocationBegin.FirstLine;
+ yylloc->FirstColumn = yyextra->m_LocationBegin.FirstColumn;
+
std::string str = yyextra->m_LexBuffer.str();
yylval->text = strdup(str.c_str());
}
<STRING>\n {
- BOOST_THROW_EXCEPTION(ConfigError("Unterminated string literal") << errinfo_debuginfo(*yylloc));
+ BOOST_THROW_EXCEPTION(ScriptError("Unterminated string literal", DebugInfoRange(yyextra->m_LocationBegin, *yylloc)));
}
<STRING>\\[0-7]{1,3} {
if (result > 0xff) {
/* error, constant is out-of-bounds */
- BOOST_THROW_EXCEPTION(ConfigError("Constant is out of bounds: " + String(yytext)) << errinfo_debuginfo(*yylloc));
+ BOOST_THROW_EXCEPTION(ScriptError("Constant is out of bounds: " + String(yytext), *yylloc));
}
yyextra->m_LexBuffer << static_cast<char>(result);
/* generate error - bad escape sequence; something
* like '\48' or '\0777777'
*/
- BOOST_THROW_EXCEPTION(ConfigError("Bad escape sequence found: " + String(yytext)) << errinfo_debuginfo(*yylloc));
+ BOOST_THROW_EXCEPTION(ScriptError("Bad escape sequence found: " + String(yytext), *yylloc));
}
-
<STRING>\\n { yyextra->m_LexBuffer << "\n"; }
+<STRING>\\\\ { yyextra->m_LexBuffer << "\\"; }
<STRING>\\t { yyextra->m_LexBuffer << "\t"; }
<STRING>\\r { yyextra->m_LexBuffer << "\r"; }
<STRING>\\b { yyextra->m_LexBuffer << "\b"; }
<STRING>\\f { yyextra->m_LexBuffer << "\f"; }
-<STRING>\\(.|\n) { yyextra->m_LexBuffer << yytext[1]; }
+<STRING>\\\n { yyextra->m_LexBuffer << yytext[1]; }
+<STRING>\\. {
+ BOOST_THROW_EXCEPTION(ScriptError("Bad escape sequence found: " + String(yytext), *yylloc));
+ }
<STRING>[^\\\n\"]+ {
char *yptr = yytext;
yyextra->m_LexBuffer << *yptr++;
}
-<STRING><<EOF>> { BOOST_THROW_EXCEPTION(ConfigError("End-of-file while in string literal") << errinfo_debuginfo(*yylloc)); }
+<STRING><<EOF>> {
+ BOOST_THROW_EXCEPTION(ScriptError("End-of-file while in string literal", DebugInfoRange(yyextra->m_LocationBegin, *yylloc)));
+ }
+
+\{\{\{ {
+ yyextra->m_LexBuffer.str("");
+ yyextra->m_LexBuffer.clear();
+
+ yyextra->m_LocationBegin = *yylloc;
-\{\{\{ { yyextra->m_LexBuffer.str(""); yyextra->m_LexBuffer.clear(); BEGIN(HEREDOC); }
+ BEGIN(HEREDOC);
+ }
<HEREDOC>\}\}\} {
BEGIN(INITIAL);
+ yylloc->FirstLine = yyextra->m_LocationBegin.FirstLine;
+ yylloc->FirstColumn = yyextra->m_LocationBegin.FirstColumn;
+
std::string str = yyextra->m_LexBuffer.str();
yylval->text = strdup(str.c_str());
}
<C_COMMENT><<EOF>> {
- BOOST_THROW_EXCEPTION(ConfigError("End-of-file while in comment") << errinfo_debuginfo(*yylloc));
- }
+ BOOST_THROW_EXCEPTION(ScriptError("End-of-file while in comment", *yylloc));
+ }
\/\/[^\n]* /* ignore C++-style comments */
include_recursive return T_INCLUDE_RECURSIVE;
library return T_LIBRARY;
null return T_NULL;
-true { yylval->num = 1; return T_NUMBER; }
-false { yylval->num = 0; return T_NUMBER; }
+true { yylval->boolean = 1; return T_BOOLEAN; }
+false { yylval->boolean = 0; return T_BOOLEAN; }
const return T_CONST;
-local return T_LOCAL;
+var return T_VAR;
+this return T_THIS;
use return T_USE;
apply return T_APPLY;
to return T_TO;
import return T_IMPORT;
assign return T_ASSIGN;
ignore return T_IGNORE;
-for return T_APPLY_FOR;
-__function return T_FUNCTION;
-__return return T_RETURN;
-__for return T_FOR;
-__signal return T_SIGNAL;
-__if return T_IF;
-__else return T_ELSE;
+function return T_FUNCTION;
+return return T_RETURN;
+for return T_FOR;
+if return T_IF;
+else return T_ELSE;
=\> return T_FOLLOWS;
\<\< return T_SHIFT_LEFT;
\>\> return T_SHIFT_RIGHT;