diff --git a/neverwinter/nwscript/native/scriptcompparsetree.cpp b/neverwinter/nwscript/native/scriptcompparsetree.cpp index a1a5f2b..9bea5d9 100644 --- a/neverwinter/nwscript/native/scriptcompparsetree.cpp +++ b/neverwinter/nwscript/native/scriptcompparsetree.cpp @@ -993,7 +993,8 @@ int32_t CScriptCompiler::GenerateParseTree() // (3) ! post-expression // (4) ++ post-expression // (5) -- post_expression - // (6) post-expression + // (6) + post_expression + // (7) post-expression //////////////////////////////////// case CSCRIPTCOMPILER_GRAMMAR_UNARY_EXPRESSION: @@ -1035,10 +1036,16 @@ int32_t CScriptCompiler::GenerateParseTree() PushSRStack(CSCRIPTCOMPILER_GRAMMAR_POST_EXPRESSION,0,0,NULL); return 0; } - else + else if (m_nTokenStatus == CSCRIPTCOMPILER_TOKEN_PLUS) { PushSRStack(CSCRIPTCOMPILER_GRAMMAR_UNARY_EXPRESSION,6,1,NULL); PushSRStack(CSCRIPTCOMPILER_GRAMMAR_POST_EXPRESSION,0,0,NULL); + return 0; + } + else + { + PushSRStack(CSCRIPTCOMPILER_GRAMMAR_UNARY_EXPRESSION,7,1,NULL); + PushSRStack(CSCRIPTCOMPILER_GRAMMAR_POST_EXPRESSION,0,0,NULL); } } if ((nTopStackRule >= 1 && nTopStackRule <= 5) && nTopStackTerm == 1) @@ -1046,7 +1053,7 @@ int32_t CScriptCompiler::GenerateParseTree() pTopStackCurrentNode->pLeft = pTopStackReturnNode; ModifySRStackReturnTree(pTopStackCurrentNode); } - if (nTopStackRule == 6 && nTopStackTerm == 1) + if (nTopStackRule >= 6 && nTopStackTerm == 1) { ModifySRStackReturnTree(pTopStackReturnNode); } diff --git a/tests/scriptcomp/corpus/constants.nss b/tests/scriptcomp/corpus/constants.nss index 63c2ff8..5f0113d 100644 --- a/tests/scriptcomp/corpus/constants.nss +++ b/tests/scriptcomp/corpus/constants.nss @@ -41,6 +41,7 @@ const int CONSTINT_MODULUS = A % B; const int CONSTINT_BOOLEAN_NOT = !A; const int CONSTINT_ONES_COMPLEMENT = ~A; const int CONSTINT_NEGATION = -A; +const int CONSTINT_AFFIRMATION = +A; const int CONSTINT_COMPLEX_EXPRESSION = A * (B/A) + !A + !B; @@ -129,6 +130,7 @@ void main() Assert(CONSTINT_BOOLEAN_NOT == 0); Assert(CONSTINT_ONES_COMPLEMENT == -11); Assert(CONSTINT_NEGATION == -10); + Assert(CONSTINT_AFFIRMATION == 10); Assert(CONSTINT_COMPLEX_EXPRESSION == 20);