diff --git a/lib/config/config_lexer.ll b/lib/config/config_lexer.ll index 068f5ef2a..a46ae9f32 100644 --- a/lib/config/config_lexer.ll +++ b/lib/config/config_lexer.ll @@ -57,11 +57,21 @@ do { \ %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); + } \" { 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()); @@ -69,7 +79,7 @@ do { \ } \n { - BOOST_THROW_EXCEPTION(ScriptError("Unterminated string literal", *yylloc)); + BOOST_THROW_EXCEPTION(ScriptError("Unterminated string literal", DebugInfoRange(yyextra->m_LocationBegin, *yylloc))); } \\[0-7]{1,3} { @@ -80,7 +90,7 @@ do { \ if (result > 0xff) { /* error, constant is out-of-bounds */ - BOOST_THROW_EXCEPTION(ScriptError("Constant is out of bounds: " + String(yytext), *yylloc)); + BOOST_THROW_EXCEPTION(ScriptError("Constant is out of bounds: " + String(yytext), DebugInfoRange(yyextra->m_LocationBegin, *yylloc))); } yyextra->m_LexBuffer << static_cast(result); @@ -90,7 +100,7 @@ do { \ /* generate error - bad escape sequence; something * like '\48' or '\0777777' */ - BOOST_THROW_EXCEPTION(ScriptError("Bad escape sequence found: " + String(yytext), *yylloc)); + BOOST_THROW_EXCEPTION(ScriptError("Bad escape sequence found: " + String(yytext), DebugInfoRange(yyextra->m_LocationBegin, *yylloc))); } \\n { yyextra->m_LexBuffer << "\n"; } @@ -107,13 +117,25 @@ do { \ yyextra->m_LexBuffer << *yptr++; } -<> { BOOST_THROW_EXCEPTION(ScriptError("End-of-file while in string literal", *yylloc)); } +<> { + BOOST_THROW_EXCEPTION(ScriptError("End-of-file while in string literal", DebugInfoRange(yyextra->m_LocationBegin, *yylloc))); + } -\{\{\{ { yyextra->m_LexBuffer.str(""); yyextra->m_LexBuffer.clear(); BEGIN(HEREDOC); } +\{\{\{ { + yyextra->m_LexBuffer.str(""); + yyextra->m_LexBuffer.clear(); + + yyextra->m_LocationBegin = *yylloc; + + BEGIN(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()); diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index eb8a046d3..38dc2b22c 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -215,7 +215,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig %left T_SHIFT_LEFT T_SHIFT_RIGHT %left T_PLUS T_MINUS %left T_MULTIPLY T_DIVIDE_OP -%left UNARY_MINUS +%left UNARY_MINUS UNARY_PLUS %right '!' '~' %left '.' '(' '[' %left T_VAR T_THIS @@ -756,6 +756,10 @@ rterm: T_STRING { $$ = new NegateExpression($2, DebugInfoRange(@1, @2)); } + | T_PLUS rterm %prec UNARY_PLUS + { + $$ = $2; + } | T_MINUS rterm %prec UNARY_MINUS { $$ = new SubtractExpression(MakeLiteral(0), $2, DebugInfoRange(@1, @2)); diff --git a/lib/config/configcompiler.hpp b/lib/config/configcompiler.hpp index 6e2eb5dd6..84e2828c1 100644 --- a/lib/config/configcompiler.hpp +++ b/lib/config/configcompiler.hpp @@ -115,6 +115,7 @@ public: int m_IgnoreNewlines; std::ostringstream m_LexBuffer; + CompilerDebugInfo m_LocationBegin; std::stack m_RuleLists; ConfigType::Ptr m_Type; @@ -127,8 +128,6 @@ public: std::stack m_FKVar; std::stack m_FVVar; std::stack m_FTerm; - - }; class I2_CONFIG_API ConfigFragmentRegistry : public Registry