| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/fm2js/xfa_fmparse.h" | 7 #include "xfa/fxfa/fm2js/xfa_fmparse.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 if (m_lexer->HasError()) { | 23 if (m_lexer->HasError()) { |
| 24 break; | 24 break; |
| 25 } | 25 } |
| 26 m_pToken = m_lexer->NextToken(); | 26 m_pToken = m_lexer->NextToken(); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 void CXFA_FMParse::Check(XFA_FM_TOKEN op) { | 30 void CXFA_FMParse::Check(XFA_FM_TOKEN op) { |
| 31 if (m_pToken->m_type != op) { | 31 if (m_pToken->m_type != op) { |
| 32 CFX_WideString ws_TempString = m_pToken->m_wstring; | 32 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 33 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 33 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, XFA_FM_KeywordToString(op), |
| 34 XFA_FM_KeywordToString(op), ws_TempString.c_str()); | 34 ws_TempString.c_str()); |
| 35 } | 35 } |
| 36 NextToken(); | 36 NextToken(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void CXFA_FMParse::Error(uint32_t lineNum, XFA_FM_ERRMSG msg, ...) { | 39 void CXFA_FMParse::Error(uint32_t lineNum, const FX_WCHAR* msg, ...) { |
| 40 m_pErrorInfo->linenum = lineNum; | 40 m_pErrorInfo->linenum = lineNum; |
| 41 const FX_WCHAR* lpMessageInfo = XFA_FM_ErrorMsg(msg); | |
| 42 va_list ap; | 41 va_list ap; |
| 43 va_start(ap, msg); | 42 va_start(ap, msg); |
| 44 m_pErrorInfo->message.FormatV(lpMessageInfo, ap); | 43 m_pErrorInfo->message.FormatV(msg, ap); |
| 45 va_end(ap); | 44 va_end(ap); |
| 46 } | 45 } |
| 47 | 46 |
| 48 CFX_PtrArray* CXFA_FMParse::ParseTopExpression() { | 47 CFX_PtrArray* CXFA_FMParse::ParseTopExpression() { |
| 49 std::unique_ptr<CXFA_FMExpression> e; | 48 std::unique_ptr<CXFA_FMExpression> e; |
| 50 CFX_PtrArray* expression = new CFX_PtrArray(); | 49 CFX_PtrArray* expression = new CFX_PtrArray(); |
| 51 while (1) { | 50 while (1) { |
| 52 if (m_pToken->m_type == TOKeof || m_pToken->m_type == TOKendfunc || | 51 if (m_pToken->m_type == TOKeof || m_pToken->m_type == TOKendfunc || |
| 53 m_pToken->m_type == TOKendif || m_pToken->m_type == TOKelseif || | 52 m_pToken->m_type == TOKendif || m_pToken->m_type == TOKelseif || |
| 54 m_pToken->m_type == TOKelse || m_pToken->m_type == TOKreserver) { | 53 m_pToken->m_type == TOKelse || m_pToken->m_type == TOKreserver) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 76 | 75 |
| 77 CXFA_FMExpression* CXFA_FMParse::ParseFunction() { | 76 CXFA_FMExpression* CXFA_FMParse::ParseFunction() { |
| 78 std::unique_ptr<CXFA_FMExpression> e; | 77 std::unique_ptr<CXFA_FMExpression> e; |
| 79 CFX_WideStringC ident; | 78 CFX_WideStringC ident; |
| 80 std::unique_ptr<CFX_WideStringCArray> pArguments; | 79 std::unique_ptr<CFX_WideStringCArray> pArguments; |
| 81 std::unique_ptr<CFX_PtrArray> pExpressions; | 80 std::unique_ptr<CFX_PtrArray> pExpressions; |
| 82 uint32_t line = m_pToken->m_uLinenum; | 81 uint32_t line = m_pToken->m_uLinenum; |
| 83 NextToken(); | 82 NextToken(); |
| 84 if (m_pToken->m_type != TOKidentifier) { | 83 if (m_pToken->m_type != TOKidentifier) { |
| 85 CFX_WideString ws_TempString = m_pToken->m_wstring; | 84 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 86 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, | 85 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, |
| 87 ws_TempString.c_str()); | 86 ws_TempString.c_str()); |
| 88 } else { | 87 } else { |
| 89 ident = m_pToken->m_wstring; | 88 ident = m_pToken->m_wstring; |
| 90 NextToken(); | 89 NextToken(); |
| 91 } | 90 } |
| 92 Check(TOKlparen); | 91 Check(TOKlparen); |
| 93 if (m_pToken->m_type == TOKrparen) { | 92 if (m_pToken->m_type == TOKrparen) { |
| 94 NextToken(); | 93 NextToken(); |
| 95 } else { | 94 } else { |
| 96 pArguments.reset(new CFX_WideStringCArray()); | 95 pArguments.reset(new CFX_WideStringCArray()); |
| 97 CFX_WideStringC p; | 96 CFX_WideStringC p; |
| 98 while (1) { | 97 while (1) { |
| 99 if (m_pToken->m_type == TOKidentifier) { | 98 if (m_pToken->m_type == TOKidentifier) { |
| 100 p = m_pToken->m_wstring; | 99 p = m_pToken->m_wstring; |
| 101 pArguments->Add(p); | 100 pArguments->Add(p); |
| 102 NextToken(); | 101 NextToken(); |
| 103 if (m_pToken->m_type == TOKcomma) { | 102 if (m_pToken->m_type == TOKcomma) { |
| 104 NextToken(); | 103 NextToken(); |
| 105 continue; | 104 continue; |
| 106 } else if (m_pToken->m_type == TOKrparen) { | 105 } else if (m_pToken->m_type == TOKrparen) { |
| 107 NextToken(); | 106 NextToken(); |
| 108 break; | 107 break; |
| 109 } else { | 108 } else { |
| 110 Check(TOKrparen); | 109 Check(TOKrparen); |
| 111 break; | 110 break; |
| 112 } | 111 } |
| 113 } else { | 112 } else { |
| 114 CFX_WideString ws_TempString = m_pToken->m_wstring; | 113 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 115 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, | 114 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, |
| 116 ws_TempString.c_str()); | 115 ws_TempString.c_str()); |
| 117 NextToken(); | 116 NextToken(); |
| 118 break; | 117 break; |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 } | 120 } |
| 122 Check(TOKdo); | 121 Check(TOKdo); |
| 123 if (m_pToken->m_type == TOKendfunc) { | 122 if (m_pToken->m_type == TOKendfunc) { |
| 124 NextToken(); | 123 NextToken(); |
| 125 } else { | 124 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 case TOKbreak: | 174 case TOKbreak: |
| 176 e.reset(new CXFA_FMBreakExpression(line)); | 175 e.reset(new CXFA_FMBreakExpression(line)); |
| 177 NextToken(); | 176 NextToken(); |
| 178 break; | 177 break; |
| 179 case TOKcontinue: | 178 case TOKcontinue: |
| 180 e.reset(new CXFA_FMContinueExpression(line)); | 179 e.reset(new CXFA_FMContinueExpression(line)); |
| 181 NextToken(); | 180 NextToken(); |
| 182 break; | 181 break; |
| 183 default: | 182 default: |
| 184 CFX_WideString ws_TempString = m_pToken->m_wstring; | 183 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 185 Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, | 184 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, |
| 186 ws_TempString.c_str()); | 185 ws_TempString.c_str()); |
| 187 NextToken(); | 186 NextToken(); |
| 188 break; | 187 break; |
| 189 } | 188 } |
| 190 return e.release(); | 189 return e.release(); |
| 191 } | 190 } |
| 192 | 191 |
| 193 CXFA_FMExpression* CXFA_FMParse::ParseVarExpression() { | 192 CXFA_FMExpression* CXFA_FMParse::ParseVarExpression() { |
| 194 std::unique_ptr<CXFA_FMExpression> e; | 193 std::unique_ptr<CXFA_FMExpression> e; |
| 195 CFX_WideStringC ident; | 194 CFX_WideStringC ident; |
| 196 uint32_t line = m_pToken->m_uLinenum; | 195 uint32_t line = m_pToken->m_uLinenum; |
| 197 NextToken(); | 196 NextToken(); |
| 198 if (m_pToken->m_type != TOKidentifier) { | 197 if (m_pToken->m_type != TOKidentifier) { |
| 199 CFX_WideString ws_TempString = m_pToken->m_wstring; | 198 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 200 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, | 199 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, |
| 201 ws_TempString.c_str()); | 200 ws_TempString.c_str()); |
| 202 } else { | 201 } else { |
| 203 ident = m_pToken->m_wstring; | 202 ident = m_pToken->m_wstring; |
| 204 NextToken(); | 203 NextToken(); |
| 205 } | 204 } |
| 206 if (m_pToken->m_type == TOKassign) { | 205 if (m_pToken->m_type == TOKassign) { |
| 207 NextToken(); | 206 NextToken(); |
| 208 e.reset(ParseExpExpression()); | 207 e.reset(ParseExpExpression()); |
| 209 } | 208 } |
| 210 if (m_pErrorInfo->message.IsEmpty()) { | 209 if (m_pErrorInfo->message.IsEmpty()) { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 break; | 525 break; |
| 527 case TOKnull: | 526 case TOKnull: |
| 528 e.reset(new CXFA_FMNullExpression(line)); | 527 e.reset(new CXFA_FMNullExpression(line)); |
| 529 NextToken(); | 528 NextToken(); |
| 530 break; | 529 break; |
| 531 case TOKlparen: | 530 case TOKlparen: |
| 532 e.reset(ParseParenExpression()); | 531 e.reset(ParseParenExpression()); |
| 533 break; | 532 break; |
| 534 default: | 533 default: |
| 535 CFX_WideString ws_TempString = m_pToken->m_wstring; | 534 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 536 Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, | 535 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, |
| 537 ws_TempString.c_str()); | 536 ws_TempString.c_str()); |
| 538 NextToken(); | 537 NextToken(); |
| 539 break; | 538 break; |
| 540 } | 539 } |
| 541 e.reset(ParsePostExpression(e.release())); | 540 e.reset(ParsePostExpression(e.release())); |
| 542 if (!(m_pErrorInfo->message.IsEmpty())) | 541 if (!(m_pErrorInfo->message.IsEmpty())) |
| 543 e.reset(); | 542 e.reset(); |
| 544 return e.release(); | 543 return e.release(); |
| 545 } | 544 } |
| 546 | 545 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 561 } | 560 } |
| 562 if (m_pToken->m_type == TOKcomma) { | 561 if (m_pToken->m_type == TOKcomma) { |
| 563 NextToken(); | 562 NextToken(); |
| 564 } else if (m_pToken->m_type == TOKeof || | 563 } else if (m_pToken->m_type == TOKeof || |
| 565 m_pToken->m_type == TOKreserver) { | 564 m_pToken->m_type == TOKreserver) { |
| 566 break; | 565 break; |
| 567 } | 566 } |
| 568 } | 567 } |
| 569 if (m_pToken->m_type != TOKrparen) { | 568 if (m_pToken->m_type != TOKrparen) { |
| 570 CFX_WideString ws_TempString = m_pToken->m_wstring; | 569 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 571 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 570 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, |
| 572 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); | 571 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); |
| 573 } | 572 } |
| 574 } | 573 } |
| 575 if (m_pErrorInfo->message.IsEmpty()) { | 574 if (m_pErrorInfo->message.IsEmpty()) { |
| 576 e = new CXFA_FMCallExpression(line, e, pArray.release(), FALSE); | 575 e = new CXFA_FMCallExpression(line, e, pArray.release(), FALSE); |
| 577 NextToken(); | 576 NextToken(); |
| 578 if (m_pToken->m_type != TOKlbracket) { | 577 if (m_pToken->m_type != TOKlbracket) { |
| 579 continue; | 578 continue; |
| 580 } | 579 } |
| 581 CXFA_FMSimpleExpression* s = ParseIndexExpression(); | 580 CXFA_FMSimpleExpression* s = ParseIndexExpression(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 pArray->Add(exp); | 613 pArray->Add(exp); |
| 615 if (m_pToken->m_type == TOKcomma) { | 614 if (m_pToken->m_type == TOKcomma) { |
| 616 NextToken(); | 615 NextToken(); |
| 617 } else if (m_pToken->m_type == TOKeof || | 616 } else if (m_pToken->m_type == TOKeof || |
| 618 m_pToken->m_type == TOKreserver) { | 617 m_pToken->m_type == TOKreserver) { |
| 619 break; | 618 break; |
| 620 } | 619 } |
| 621 } | 620 } |
| 622 if (m_pToken->m_type != TOKrparen) { | 621 if (m_pToken->m_type != TOKrparen) { |
| 623 CFX_WideString ws_TempString = m_pToken->m_wstring; | 622 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 624 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 623 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, |
| 625 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); | 624 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); |
| 626 } | 625 } |
| 627 } | 626 } |
| 628 if (m_pErrorInfo->message.IsEmpty()) { | 627 if (m_pErrorInfo->message.IsEmpty()) { |
| 629 CXFA_FMSimpleExpression* pIdentifier = | 628 CXFA_FMSimpleExpression* pIdentifier = |
| 630 new CXFA_FMIdentifierExpressionn(tempLine, tempStr); | 629 new CXFA_FMIdentifierExpressionn(tempLine, tempStr); |
| 631 pExpCall = new CXFA_FMCallExpression(line, pIdentifier, | 630 pExpCall = new CXFA_FMCallExpression(line, pIdentifier, |
| 632 pArray.release(), TRUE); | 631 pArray.release(), TRUE); |
| 633 e = new CXFA_FMMethodCallExpression(line, pExpAccessor, pExpCall); | 632 e = new CXFA_FMMethodCallExpression(line, pExpAccessor, pExpCall); |
| 634 NextToken(); | 633 NextToken(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 662 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdot, tempStr, | 661 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdot, tempStr, |
| 663 s.release()); | 662 s.release()); |
| 664 } else { | 663 } else { |
| 665 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( | 664 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( |
| 666 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); | 665 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); |
| 667 e = new CXFA_FMDotAccessorExpression(line, e, TOKdot, tempStr, s); | 666 e = new CXFA_FMDotAccessorExpression(line, e, TOKdot, tempStr, s); |
| 668 continue; | 667 continue; |
| 669 } | 668 } |
| 670 } else { | 669 } else { |
| 671 CFX_WideString ws_TempString = m_pToken->m_wstring; | 670 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 672 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, | 671 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, |
| 673 ws_TempString.c_str()); | 672 ws_TempString.c_str()); |
| 674 return e; | 673 return e; |
| 675 } | 674 } |
| 676 break; | 675 break; |
| 677 case TOKdotdot: | 676 case TOKdotdot: |
| 678 NextToken(); | 677 NextToken(); |
| 679 if (m_pToken->m_type == TOKidentifier) { | 678 if (m_pToken->m_type == TOKidentifier) { |
| 680 CFX_WideStringC tempStr = m_pToken->m_wstring; | 679 CFX_WideStringC tempStr = m_pToken->m_wstring; |
| 681 uint32_t tempLine = m_pToken->m_uLinenum; | 680 uint32_t tempLine = m_pToken->m_uLinenum; |
| 682 NextToken(); | 681 NextToken(); |
| 683 if (m_pToken->m_type == TOKlbracket) { | 682 if (m_pToken->m_type == TOKlbracket) { |
| 684 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); | 683 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); |
| 685 if (!(m_pErrorInfo->message.IsEmpty())) { | 684 if (!(m_pErrorInfo->message.IsEmpty())) { |
| 686 delete e; | 685 delete e; |
| 687 return nullptr; | 686 return nullptr; |
| 688 } | 687 } |
| 689 e = new CXFA_FMDotDotAccessorExpression(tempLine, e, TOKdotdot, | 688 e = new CXFA_FMDotDotAccessorExpression(tempLine, e, TOKdotdot, |
| 690 tempStr, s.release()); | 689 tempStr, s.release()); |
| 691 } else { | 690 } else { |
| 692 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( | 691 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( |
| 693 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); | 692 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); |
| 694 e = new CXFA_FMDotDotAccessorExpression(line, e, TOKdotdot, tempStr, | 693 e = new CXFA_FMDotDotAccessorExpression(line, e, TOKdotdot, tempStr, |
| 695 s); | 694 s); |
| 696 continue; | 695 continue; |
| 697 } | 696 } |
| 698 } else { | 697 } else { |
| 699 CFX_WideString ws_TempString = m_pToken->m_wstring; | 698 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 700 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, | 699 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, |
| 701 ws_TempString.c_str()); | 700 ws_TempString.c_str()); |
| 702 return e; | 701 return e; |
| 703 } | 702 } |
| 704 break; | 703 break; |
| 705 case TOKdotscream: | 704 case TOKdotscream: |
| 706 NextToken(); | 705 NextToken(); |
| 707 if (m_pToken->m_type == TOKidentifier) { | 706 if (m_pToken->m_type == TOKidentifier) { |
| 708 CFX_WideStringC tempStr = m_pToken->m_wstring; | 707 CFX_WideStringC tempStr = m_pToken->m_wstring; |
| 709 uint32_t tempLine = m_pToken->m_uLinenum; | 708 uint32_t tempLine = m_pToken->m_uLinenum; |
| 710 NextToken(); | 709 NextToken(); |
| 711 if (m_pToken->m_type == TOKlbracket) { | 710 if (m_pToken->m_type == TOKlbracket) { |
| 712 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); | 711 std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); |
| 713 if (!(m_pErrorInfo->message.IsEmpty())) { | 712 if (!(m_pErrorInfo->message.IsEmpty())) { |
| 714 delete e; | 713 delete e; |
| 715 return nullptr; | 714 return nullptr; |
| 716 } | 715 } |
| 717 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdotscream, | 716 e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdotscream, |
| 718 tempStr, s.release()); | 717 tempStr, s.release()); |
| 719 } else { | 718 } else { |
| 720 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( | 719 CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( |
| 721 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); | 720 tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); |
| 722 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotscream, tempStr, | 721 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotscream, tempStr, |
| 723 s); | 722 s); |
| 724 continue; | 723 continue; |
| 725 } | 724 } |
| 726 } else { | 725 } else { |
| 727 CFX_WideString ws_TempString = m_pToken->m_wstring; | 726 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 728 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, | 727 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, |
| 729 ws_TempString.c_str()); | 728 ws_TempString.c_str()); |
| 730 return e; | 729 return e; |
| 731 } | 730 } |
| 732 break; | 731 break; |
| 733 case TOKdotstar: { | 732 case TOKdotstar: { |
| 734 CXFA_FMSimpleExpression* s = | 733 CXFA_FMSimpleExpression* s = |
| 735 new CXFA_FMIndexExpression(line, ACCESSOR_NO_INDEX, NULL, FALSE); | 734 new CXFA_FMIndexExpression(line, ACCESSOR_NO_INDEX, NULL, FALSE); |
| 736 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotstar, | 735 e = new CXFA_FMDotAccessorExpression(line, e, TOKdotstar, |
| 737 FX_WSTRC(L"*"), s); | 736 FX_WSTRC(L"*"), s); |
| 738 } break; | 737 } break; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 749 uint32_t line = m_pToken->m_uLinenum; | 748 uint32_t line = m_pToken->m_uLinenum; |
| 750 NextToken(); | 749 NextToken(); |
| 751 std::unique_ptr<CXFA_FMSimpleExpression> s; | 750 std::unique_ptr<CXFA_FMSimpleExpression> s; |
| 752 XFA_FM_AccessorIndex accessorIndex = ACCESSOR_NO_RELATIVEINDEX; | 751 XFA_FM_AccessorIndex accessorIndex = ACCESSOR_NO_RELATIVEINDEX; |
| 753 if (m_pToken->m_type == TOKmul) { | 752 if (m_pToken->m_type == TOKmul) { |
| 754 pExp.reset( | 753 pExp.reset( |
| 755 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), TRUE)); | 754 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), TRUE)); |
| 756 NextToken(); | 755 NextToken(); |
| 757 if (m_pToken->m_type != TOKrbracket) { | 756 if (m_pToken->m_type != TOKrbracket) { |
| 758 CFX_WideString ws_TempString = m_pToken->m_wstring; | 757 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 759 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 758 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, |
| 760 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); | 759 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); |
| 761 pExp.reset(); | 760 pExp.reset(); |
| 762 } | 761 } |
| 763 return pExp.release(); | 762 return pExp.release(); |
| 764 } | 763 } |
| 765 if (m_pToken->m_type == TOKplus) { | 764 if (m_pToken->m_type == TOKplus) { |
| 766 accessorIndex = ACCESSOR_POSITIVE_INDEX; | 765 accessorIndex = ACCESSOR_POSITIVE_INDEX; |
| 767 NextToken(); | 766 NextToken(); |
| 768 } else if (m_pToken->m_type == TOKminus) { | 767 } else if (m_pToken->m_type == TOKminus) { |
| 769 accessorIndex = ACCESSOR_NEGATIVE_INDEX; | 768 accessorIndex = ACCESSOR_NEGATIVE_INDEX; |
| 770 NextToken(); | 769 NextToken(); |
| 771 } | 770 } |
| 772 s.reset(ParseSimpleExpression()); | 771 s.reset(ParseSimpleExpression()); |
| 773 if (m_pToken->m_type != TOKrbracket) { | 772 if (m_pToken->m_type != TOKrbracket) { |
| 774 CFX_WideString ws_TempString = m_pToken->m_wstring; | 773 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 775 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 774 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, |
| 776 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); | 775 XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); |
| 777 } else { | 776 } else { |
| 778 pExp.reset( | 777 pExp.reset( |
| 779 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), FALSE)); | 778 new CXFA_FMIndexExpression(line, accessorIndex, s.release(), FALSE)); |
| 780 } | 779 } |
| 781 return pExp.release(); | 780 return pExp.release(); |
| 782 } | 781 } |
| 783 | 782 |
| 784 CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() { | 783 CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() { |
| 785 Check(TOKlparen); | 784 Check(TOKlparen); |
| 786 | 785 |
| 787 if (m_pToken->m_type == TOKrparen) { | 786 if (m_pToken->m_type == TOKrparen) { |
| 788 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_NON_EMPTY_EXPRESSION); | 787 Error(m_pToken->m_uLinenum, kFMErrExpectedNonEmptyExpression); |
| 789 NextToken(); | 788 NextToken(); |
| 790 return nullptr; | 789 return nullptr; |
| 791 } | 790 } |
| 792 | 791 |
| 793 uint32_t line = m_pToken->m_uLinenum; | 792 uint32_t line = m_pToken->m_uLinenum; |
| 794 std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseLogicalOrExpression()); | 793 std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseLogicalOrExpression()); |
| 795 | 794 |
| 796 while (m_pToken->m_type == TOKassign) { | 795 while (m_pToken->m_type == TOKassign) { |
| 797 NextToken(); | 796 NextToken(); |
| 798 std::unique_ptr<CXFA_FMSimpleExpression> pExp2(ParseLogicalOrExpression()); | 797 std::unique_ptr<CXFA_FMSimpleExpression> pExp2(ParseLogicalOrExpression()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 case TOKelseif: | 884 case TOKelseif: |
| 886 pElseExpression.reset(ParseIfExpression()); | 885 pElseExpression.reset(ParseIfExpression()); |
| 887 break; | 886 break; |
| 888 case TOKelse: | 887 case TOKelse: |
| 889 NextToken(); | 888 NextToken(); |
| 890 pElseExpression.reset(ParseBlockExpression()); | 889 pElseExpression.reset(ParseBlockExpression()); |
| 891 Check(TOKendif); | 890 Check(TOKendif); |
| 892 break; | 891 break; |
| 893 default: | 892 default: |
| 894 CFX_WideString ws_TempString = m_pToken->m_wstring; | 893 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 895 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IFEND, ws_TempString.c_str()); | 894 Error(m_pToken->m_uLinenum, kFMErrExpectedEndIf, ws_TempString.c_str()); |
| 896 NextToken(); | 895 NextToken(); |
| 897 break; | 896 break; |
| 898 } | 897 } |
| 899 std::unique_ptr<CXFA_FMIfExpression> pExp; | 898 std::unique_ptr<CXFA_FMIfExpression> pExp; |
| 900 if (m_pErrorInfo->message.IsEmpty()) { | 899 if (m_pErrorInfo->message.IsEmpty()) { |
| 901 pExp.reset(new CXFA_FMIfExpression(line, pExpression.release(), | 900 pExp.reset(new CXFA_FMIfExpression(line, pExpression.release(), |
| 902 pIfExpression.release(), | 901 pIfExpression.release(), |
| 903 pElseExpression.release())); | 902 pElseExpression.release())); |
| 904 } | 903 } |
| 905 return pExp.release(); | 904 return pExp.release(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 921 } | 920 } |
| 922 | 921 |
| 923 CXFA_FMSimpleExpression* CXFA_FMParse::ParseSubassignmentInForExpression() { | 922 CXFA_FMSimpleExpression* CXFA_FMParse::ParseSubassignmentInForExpression() { |
| 924 std::unique_ptr<CXFA_FMSimpleExpression> e; | 923 std::unique_ptr<CXFA_FMSimpleExpression> e; |
| 925 switch (m_pToken->m_type) { | 924 switch (m_pToken->m_type) { |
| 926 case TOKidentifier: | 925 case TOKidentifier: |
| 927 e.reset(ParseSimpleExpression()); | 926 e.reset(ParseSimpleExpression()); |
| 928 break; | 927 break; |
| 929 default: | 928 default: |
| 930 CFX_WideString ws_TempString = m_pToken->m_wstring; | 929 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 931 Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, | 930 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, |
| 932 ws_TempString.c_str()); | 931 ws_TempString.c_str()); |
| 933 NextToken(); | 932 NextToken(); |
| 934 break; | 933 break; |
| 935 } | 934 } |
| 936 return e.release(); | 935 return e.release(); |
| 937 } | 936 } |
| 938 | 937 |
| 939 CXFA_FMExpression* CXFA_FMParse::ParseForExpression() { | 938 CXFA_FMExpression* CXFA_FMParse::ParseForExpression() { |
| 940 CFX_WideStringC wsVariant; | 939 CFX_WideStringC wsVariant; |
| 941 uint32_t line = m_pToken->m_uLinenum; | 940 uint32_t line = m_pToken->m_uLinenum; |
| 942 NextToken(); | 941 NextToken(); |
| 943 if (m_pToken->m_type != TOKidentifier) { | 942 if (m_pToken->m_type != TOKidentifier) { |
| 944 CFX_WideString ws_TempString = m_pToken->m_wstring; | 943 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 945 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 944 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, |
| 946 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); | 945 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); |
| 947 } | 946 } |
| 948 wsVariant = m_pToken->m_wstring; | 947 wsVariant = m_pToken->m_wstring; |
| 949 NextToken(); | 948 NextToken(); |
| 950 std::unique_ptr<CXFA_FMSimpleExpression> pAssignment; | 949 std::unique_ptr<CXFA_FMSimpleExpression> pAssignment; |
| 951 if (m_pToken->m_type == TOKassign) { | 950 if (m_pToken->m_type == TOKassign) { |
| 952 NextToken(); | 951 NextToken(); |
| 953 pAssignment.reset(ParseSimpleExpression()); | 952 pAssignment.reset(ParseSimpleExpression()); |
| 954 } else { | 953 } else { |
| 955 CFX_WideString ws_TempString = m_pToken->m_wstring; | 954 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 956 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 955 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, |
| 957 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); | 956 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); |
| 958 } | 957 } |
| 959 int32_t iDirection = 0; | 958 int32_t iDirection = 0; |
| 960 if (m_pToken->m_type == TOKupto) { | 959 if (m_pToken->m_type == TOKupto) { |
| 961 iDirection = 1; | 960 iDirection = 1; |
| 962 } else if (m_pToken->m_type == TOKdownto) { | 961 } else if (m_pToken->m_type == TOKdownto) { |
| 963 iDirection = -1; | 962 iDirection = -1; |
| 964 } else { | 963 } else { |
| 965 CFX_WideString ws_TempString = m_pToken->m_wstring; | 964 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 966 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, L"upto or downto", | 965 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, L"upto or downto", |
| 967 ws_TempString.c_str()); | 966 ws_TempString.c_str()); |
| 968 } | 967 } |
| 969 NextToken(); | 968 NextToken(); |
| 970 std::unique_ptr<CXFA_FMSimpleExpression> pAccessor(ParseSimpleExpression()); | 969 std::unique_ptr<CXFA_FMSimpleExpression> pAccessor(ParseSimpleExpression()); |
| 971 std::unique_ptr<CXFA_FMSimpleExpression> pStep; | 970 std::unique_ptr<CXFA_FMSimpleExpression> pStep; |
| 972 if (m_pToken->m_type == TOKstep) { | 971 if (m_pToken->m_type == TOKstep) { |
| 973 NextToken(); | 972 NextToken(); |
| 974 pStep.reset(ParseSimpleExpression()); | 973 pStep.reset(ParseSimpleExpression()); |
| 975 } | 974 } |
| 976 Check(TOKdo); | 975 Check(TOKdo); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 987 | 986 |
| 988 CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() { | 987 CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() { |
| 989 std::unique_ptr<CXFA_FMExpression> e; | 988 std::unique_ptr<CXFA_FMExpression> e; |
| 990 CFX_WideStringC wsIdentifier; | 989 CFX_WideStringC wsIdentifier; |
| 991 std::unique_ptr<CFX_PtrArray> pAccessors; | 990 std::unique_ptr<CFX_PtrArray> pAccessors; |
| 992 std::unique_ptr<CXFA_FMExpression> pList; | 991 std::unique_ptr<CXFA_FMExpression> pList; |
| 993 uint32_t line = m_pToken->m_uLinenum; | 992 uint32_t line = m_pToken->m_uLinenum; |
| 994 NextToken(); | 993 NextToken(); |
| 995 if (m_pToken->m_type != TOKidentifier) { | 994 if (m_pToken->m_type != TOKidentifier) { |
| 996 CFX_WideString ws_TempString = m_pToken->m_wstring; | 995 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 997 Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, | 996 Error(m_pToken->m_uLinenum, kFMErrExpectedToken, |
| 998 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); | 997 XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); |
| 999 } | 998 } |
| 1000 wsIdentifier = m_pToken->m_wstring; | 999 wsIdentifier = m_pToken->m_wstring; |
| 1001 NextToken(); | 1000 NextToken(); |
| 1002 Check(TOKin); | 1001 Check(TOKin); |
| 1003 Check(TOKlparen); | 1002 Check(TOKlparen); |
| 1004 if (m_pToken->m_type == TOKrparen) { | 1003 if (m_pToken->m_type == TOKrparen) { |
| 1005 CFX_WideString ws_TempString = m_pToken->m_wstring; | 1004 CFX_WideString ws_TempString = m_pToken->m_wstring; |
| 1006 Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, | 1005 Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression, |
| 1007 ws_TempString.c_str()); | 1006 ws_TempString.c_str()); |
| 1008 NextToken(); | 1007 NextToken(); |
| 1009 } else { | 1008 } else { |
| 1010 pAccessors.reset(new CFX_PtrArray()); | 1009 pAccessors.reset(new CFX_PtrArray()); |
| 1011 while (m_pToken->m_type != TOKrparen) { | 1010 while (m_pToken->m_type != TOKrparen) { |
| 1012 CXFA_FMSimpleExpression* s = ParseSimpleExpression(); | 1011 CXFA_FMSimpleExpression* s = ParseSimpleExpression(); |
| 1013 if (s) { | 1012 if (s) { |
| 1014 pAccessors->Add(s); | 1013 pAccessors->Add(s); |
| 1015 } | 1014 } |
| 1016 if (m_pToken->m_type == TOKcomma) { | 1015 if (m_pToken->m_type == TOKcomma) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1042 NextToken(); | 1041 NextToken(); |
| 1043 e.reset(ParseBlockExpression()); | 1042 e.reset(ParseBlockExpression()); |
| 1044 Check(TOKend); | 1043 Check(TOKend); |
| 1045 if (m_pErrorInfo->message.IsEmpty()) { | 1044 if (m_pErrorInfo->message.IsEmpty()) { |
| 1046 e.reset(new CXFA_FMDoExpression(line, e.release())); | 1045 e.reset(new CXFA_FMDoExpression(line, e.release())); |
| 1047 } else { | 1046 } else { |
| 1048 e.reset(); | 1047 e.reset(); |
| 1049 } | 1048 } |
| 1050 return e.release(); | 1049 return e.release(); |
| 1051 } | 1050 } |
| OLD | NEW |