comparison libinterp/parse-tree/lex.ll @ 31078:4d45392387ec stable

store token ID, not keyword ID when parsing keywords (bug #62587) * lex.ll (base_lexer::make_keyword_token): Use token ID, not keyword ID, when constructing token objects.
author John W. Eaton <jwe@octave.org>
date Tue, 07 Jun 2022 08:05:13 -0400
parents 1589a7967d1e
children f0343b3685df 4b6f03d7264a
comparison
equal deleted inserted replaced
31077:2dee06f4635c 31078:4d45392387ec
2703 { 2703 {
2704 m_at_beginning_of_statement = previous_at_bos; 2704 m_at_beginning_of_statement = previous_at_bos;
2705 return 0; 2705 return 0;
2706 } 2706 }
2707 2707
2708 tok_val = new token (end_kw, token::simple_end, m_tok_beg, m_tok_end); 2708 tok_val = new token (kw->tok, token::simple_end, m_tok_beg, m_tok_end);
2709 m_at_beginning_of_statement = true; 2709 m_at_beginning_of_statement = true;
2710 break; 2710 break;
2711 2711
2712 case end_try_catch_kw: 2712 case end_try_catch_kw:
2713 tok_val = new token (end_try_catch_kw, token::try_catch_end, m_tok_beg, 2713 tok_val = new token (kw->tok, token::try_catch_end, m_tok_beg,
2714 m_tok_end); 2714 m_tok_end);
2715 m_at_beginning_of_statement = true; 2715 m_at_beginning_of_statement = true;
2716 break; 2716 break;
2717 2717
2718 case end_unwind_protect_kw: 2718 case end_unwind_protect_kw:
2719 tok_val = new token (end_unwind_protect_kw, 2719 tok_val = new token (kw->tok, token::unwind_protect_end, m_tok_beg,
2720 token::unwind_protect_end, m_tok_beg, m_tok_end);
2721 m_at_beginning_of_statement = true;
2722 break;
2723
2724 case endfor_kw:
2725 tok_val = new token (endfor_kw, token::for_end, m_tok_beg, m_tok_end);
2726 m_at_beginning_of_statement = true;
2727 break;
2728
2729 case endfunction_kw:
2730 tok_val = new token (endfunction_kw, token::function_end, m_tok_beg,
2731 m_tok_end); 2720 m_tok_end);
2732 m_at_beginning_of_statement = true; 2721 m_at_beginning_of_statement = true;
2733 break; 2722 break;
2734 2723
2735 case endif_kw: 2724 case endfor_kw:
2736 tok_val = new token (endif_kw, token::if_end, m_tok_beg, m_tok_end); 2725 tok_val = new token (kw->tok, token::for_end, m_tok_beg, m_tok_end);
2737 m_at_beginning_of_statement = true; 2726 m_at_beginning_of_statement = true;
2738 break; 2727 break;
2739 2728
2740 case endparfor_kw: 2729 case endfunction_kw:
2741 tok_val = new token (endparfor_kw, token::parfor_end, m_tok_beg, 2730 tok_val = new token (kw->tok, token::function_end, m_tok_beg,
2742 m_tok_end); 2731 m_tok_end);
2743 m_at_beginning_of_statement = true; 2732 m_at_beginning_of_statement = true;
2744 break; 2733 break;
2745 2734
2735 case endif_kw:
2736 tok_val = new token (kw->tok, token::if_end, m_tok_beg, m_tok_end);
2737 m_at_beginning_of_statement = true;
2738 break;
2739
2740 case endparfor_kw:
2741 tok_val = new token (kw->tok, token::parfor_end, m_tok_beg, m_tok_end);
2742 m_at_beginning_of_statement = true;
2743 break;
2744
2746 case endswitch_kw: 2745 case endswitch_kw:
2747 tok_val = new token (endswitch_kw, token::switch_end, m_tok_beg, 2746 tok_val = new token (kw->tok, token::switch_end, m_tok_beg, m_tok_end);
2748 m_tok_end);
2749 m_at_beginning_of_statement = true; 2747 m_at_beginning_of_statement = true;
2750 break; 2748 break;
2751 2749
2752 case endwhile_kw: 2750 case endwhile_kw:
2753 tok_val = new token (endwhile_kw, token::while_end, m_tok_beg, 2751 tok_val = new token (kw->tok, token::while_end, m_tok_beg, m_tok_end);
2754 m_tok_end);
2755 m_at_beginning_of_statement = true; 2752 m_at_beginning_of_statement = true;
2756 break; 2753 break;
2757 2754
2758 case endarguments_kw: 2755 case endarguments_kw:
2759 #if defined (DISABLE_ARGUMENTS_VALIDATION_BLOCK) 2756 #if defined (DISABLE_ARGUMENTS_VALIDATION_BLOCK)
2760 return 0; 2757 return 0;
2761 #else 2758 #else
2762 tok_val = new token (endarguments_kw, token::arguments_end, m_tok_beg, 2759 tok_val = new token (kw->tok, token::arguments_end, m_tok_beg,
2763 m_tok_end); 2760 m_tok_end);
2764 m_at_beginning_of_statement = true; 2761 m_at_beginning_of_statement = true;
2765 break; 2762 break;
2766 #endif 2763 #endif
2767 2764
2768 case endclassdef_kw: 2765 case endclassdef_kw:
2769 tok_val = new token (endclassdef_kw, token::classdef_end, m_tok_beg, 2766 tok_val = new token (kw->tok, token::classdef_end, m_tok_beg,
2770 m_tok_end); 2767 m_tok_end);
2771 m_at_beginning_of_statement = true; 2768 m_at_beginning_of_statement = true;
2772 break; 2769 break;
2773 2770
2774 case endenumeration_kw: 2771 case endenumeration_kw:
2775 tok_val = new token (endenumeration_kw, token::enumeration_end, 2772 tok_val = new token (kw->tok, token::enumeration_end, m_tok_beg,
2776 m_tok_beg, m_tok_end);
2777 m_at_beginning_of_statement = true;
2778 break;
2779
2780 case endevents_kw:
2781 tok_val = new token (endevents_kw, token::events_end, m_tok_beg,
2782 m_tok_end); 2773 m_tok_end);
2783 m_at_beginning_of_statement = true; 2774 m_at_beginning_of_statement = true;
2784 break; 2775 break;
2785 2776
2786 case endmethods_kw: 2777 case endevents_kw:
2787 tok_val = new token (endmethods_kw, token::methods_end, m_tok_beg, 2778 tok_val = new token (kw->tok, token::events_end, m_tok_beg,
2788 m_tok_end); 2779 m_tok_end);
2789 m_at_beginning_of_statement = true; 2780 m_at_beginning_of_statement = true;
2790 break; 2781 break;
2791 2782
2783 case endmethods_kw:
2784 tok_val = new token (kw->tok, token::methods_end, m_tok_beg,
2785 m_tok_end);
2786 m_at_beginning_of_statement = true;
2787 break;
2788
2792 case endproperties_kw: 2789 case endproperties_kw:
2793 tok_val = new token (endproperties_kw, token::properties_end, m_tok_beg, 2790 tok_val = new token (kw->tok, token::properties_end, m_tok_beg,
2794 m_tok_end); 2791 m_tok_end);
2795 m_at_beginning_of_statement = true; 2792 m_at_beginning_of_statement = true;
2796 break; 2793 break;
2797 2794
2798 case for_kw: 2795 case for_kw:
2892 case spmd_kw: 2889 case spmd_kw:
2893 m_at_beginning_of_statement = true; 2890 m_at_beginning_of_statement = true;
2894 break; 2891 break;
2895 2892
2896 case endspmd_kw: 2893 case endspmd_kw:
2897 tok_val = new token (endspmd_kw, token::spmd_end, m_tok_beg, m_tok_end); 2894 tok_val = new token (kw->tok, token::spmd_end, m_tok_beg, m_tok_end);
2898 m_at_beginning_of_statement = true; 2895 m_at_beginning_of_statement = true;
2899 break; 2896 break;
2900 2897
2901 case magic_file_kw: 2898 case magic_file_kw:
2902 { 2899 {
2903 if ((m_reading_fcn_file || m_reading_script_file 2900 if ((m_reading_fcn_file || m_reading_script_file
2904 || m_reading_classdef_file) 2901 || m_reading_classdef_file)
2905 && ! m_fcn_file_full_name.empty ()) 2902 && ! m_fcn_file_full_name.empty ())
2906 tok_val = new token (magic_file_kw, m_fcn_file_full_name, 2903 tok_val = new token (kw->tok, m_fcn_file_full_name,
2907 m_tok_beg, m_tok_end); 2904 m_tok_beg, m_tok_end);
2908 else 2905 else
2909 tok_val = new token (magic_file_kw, "stdin", m_tok_beg, m_tok_end); 2906 tok_val = new token (kw->tok, "stdin", m_tok_beg, m_tok_end);
2910 } 2907 }
2911 break; 2908 break;
2912 2909
2913 case magic_line_kw: 2910 case magic_line_kw:
2914 { 2911 {
2915 int l = m_tok_beg.line (); 2912 int l = m_tok_beg.line ();
2916 octave_value ov_value (static_cast<double> (l)); 2913 octave_value ov_value (static_cast<double> (l));
2917 tok_val = new token (magic_line_kw, ov_value, "", 2914 tok_val = new token (kw->tok, ov_value, "", m_tok_beg, m_tok_end);
2918 m_tok_beg, m_tok_end);
2919 } 2915 }
2920 break; 2916 break;
2921 2917
2922 default: 2918 default:
2923 panic_impossible (); 2919 panic_impossible ();