3 source/highlightData.c | 2 +-
4 source/interpret.c | 14 ++++++++++++++
6 source/parse.y | 19 +++++++++++++++++--
7 4 files changed, 33 insertions(+), 3 deletions(-)
9 diff --quilt old/source/interpret.c new/source/interpret.c
10 --- old/source/interpret.c
11 +++ new/source/interpret.c
12 @@ -3955,6 +3955,20 @@ static int typeOfOut(void)
16 +static int readOnly(void)
23 + GET_SYM(sym, False);
25 + sym->attr |= READONLY_ATTR;
31 ** assign to the next numerical index array element of a referenced
33 diff --quilt old/source/ops.h new/source/ops.h
36 @@ -66,3 +66,4 @@ OP(SWAP_TOP2, swapTop2)
37 OP(SUBR_CALL_UNPACK_ARRAY, callSubroutineUnpackArray) /*s,N*/ /* pop(a), push(numerics(a)), call(s) */
38 OP(TYPEOF_IN, typeOfIn) /* enable typeof() */
39 OP(TYPEOF_OUT, typeOfOut) /* pop(v), push(typeof(v)) */
40 +OP(READONLY, readOnly) /* sym */ /* sym.attr |= READONLY_ATTR */
41 diff --quilt old/source/parse.y new/source/parse.y
42 --- old/source/parse.y
43 +++ new/source/parse.y
44 @@ -124,7 +124,7 @@ static int nextSymIsField = 0;
45 %token <str> SYMBOL STRING FIELD
47 %token DELETE ARG_LOOKUP
48 -%token IF WHILE DO ELSE FOR BREAK CONTINUE RETURN DEFINE TYPEOF KEYVAL
49 +%token IF WHILE DO ELSE FOR BREAK CONTINUE RETURN DEFINE TYPEOF KEYVAL READONLY
50 %type <num> keyargs key keyopt catlist fnarglsopt fnarglist fnarg
51 %type <inst> cond comastmts comastmtlst for while do else and or arrayexpr mark
53 @@ -213,7 +213,7 @@ definesym: SYMBOL {
57 - subrPtr.tag = MACRO_SUBR_TAG;
58 + subrPtr.tag = NO_TAG;
59 subrPtr.val.prog = NULL;
60 $$.sym = InstallSymbol($1, GLOBAL_SCOPE, NO_ATTR, subrPtr);
62 @@ -222,8 +222,15 @@ definesym: SYMBOL {
64 define: definekw blank definesym blank blockwb {
65 ADD_OP(OP_RETURN_NO_VAL);
66 + $3.sym->value.tag = MACRO_SUBR_TAG;
67 $3.sym->value.val.prog = FinishCreatingProgram($3.acc);
69 + | READONLY definekw blank definesym blank blockwb {
70 + ADD_OP(OP_RETURN_NO_VAL);
71 + $4.sym->value.tag = MACRO_SUBR_TAG;
72 + $4.sym->value.val.prog = FinishCreatingProgram($4.acc);
73 + $4.sym->attr |= READONLY_ATTR;
78 @@ -382,6 +389,13 @@ simpstmt: /* simple variable assignmen
79 | initarraylv '[' '@' ']' '=' blank expr {
80 ADD_OP(OP_ARRAY_ASSIGN_NEXT);
83 + ADD_OP(OP_READONLY); ADD_SYM($2);
85 + | READONLY SYMBOL '=' blank expr {
86 + ADD_OP(OP_ASSIGN); ADD_SYM($2);
87 + ADD_OP(OP_READONLY); ADD_SYM($2);
92 @@ -911,6 +925,7 @@ static int yylex(void)
93 if (!strcmp(symName, "delete") && follow_non_whitespace('(', SYMBOL, DELETE) == DELETE) return DELETE;
94 if (!strcmp(symName, "define") && follow_non_whitespace('(', SYMBOL, DEFINE) == DEFINE) return DEFINE;
95 if (!strcmp(symName, "typeof")) return TYPEOF;
96 + if (!strcmp(symName, "readonly")) return READONLY;
98 yylval.str = LookupString(symName, True);
100 diff --quilt old/source/highlightData.c new/source/highlightData.c
101 --- old/source/highlightData.c
102 +++ new/source/highlightData.c
103 @@ -558,7 +558,7 @@ static char *DefaultPatternSets[] = {
104 Menu Actions:\"<(?:new(?:_tab|_opposite)?|open|open-dialog|open_dialog|open-selected|open_selected|close|save|save-as|save_as|save-as-dialog|save_as_dialog|revert-to-saved|revert_to_saved|revert_to_saved_dialog|include-file|include_file|include-file-dialog|include_file_dialog|load-macro-file|load_macro_file|load-macro-file-dialog|load_macro_file_dialog|load-tags-file|load_tags_file|load-tags-file-dialog|load_tags_file_dialog|unload_tags_file|load_tips_file|load_tips_file_dialog|unload_tips_file|print|print-selection|print_selection|exit|undo|redo|delete|select-all|select_all|shift-left|shift_left|shift-left-by-tab|shift_left_by_tab|shift-right|shift_right|shift-right-by-tab|shift_right_by_tab|find|find-dialog|find_dialog|find-again|find_again|find-selection|find_selection|find_incremental|start_incremental_find|replace|replace-dialog|replace_dialog|replace-all|replace_all|replace-in-selection|replace_in_selection|replace-again|replace_again|replace_find|replace_find_same|replace_find_again|goto-line-number|goto_line_number|goto-line-number-dialog|goto_line_number_dialog|goto-selected|goto_selected|mark|mark-dialog|mark_dialog|goto-mark|goto_mark|goto-mark-dialog|goto_mark_dialog|match|select_to_matching|goto_matching|find-definition|find_definition|show_tip|split-pane|split_pane|close-pane|close_pane|detach_document(?:_dialog)?|move_document_dialog|(?:next|previous|last)_document|uppercase|lowercase|fill-paragraph|fill_paragraph|control-code-dialog|control_code_dialog|filter-selection-dialog|filter_selection_dialog|filter-selection|filter_selection|execute-command|execute_command|execute-command-dialog|execute_command_dialog|execute-command-line|execute_command_line|shell-menu-command|shell_menu_command|macro-menu-command|macro_menu_command|bg_menu_command|post_window_bg_menu|post_tab_context_menu|beginning-of-selection|beginning_of_selection|end-of-selection|end_of_selection|repeat_macro|repeat_dialog|raise_window|focus_pane|set_statistics_line|set_incremental_search_line|set_show_line_numbers|set_auto_indent|set_wrap_text|set_wrap_margin|set_highlight_syntax|set_make_backup_copy|set_incremental_backup|set_show_matching|set_match_syntax_based|set_overtype_mode|set_locked|set_tab_dist|set_em_tab_dist|set_use_tabs|set_fonts|set_language_mode)(?=\\s*\\()\":::Subroutine::\n\
105 Text Actions:\"<(?:self-insert|self_insert|grab-focus|grab_focus|extend-adjust|extend_adjust|extend-start|extend_start|extend-end|extend_end|secondary-adjust|secondary_adjust|secondary-or-drag-adjust|secondary_or_drag_adjust|secondary-start|secondary_start|secondary-or-drag-start|secondary_or_drag_start|process-bdrag|process_bdrag|move-destination|move_destination|move-to|move_to|move-to-or-end-drag|move_to_or_end_drag|end_drag|copy-to|copy_to|copy-to-or-end-drag|copy_to_or_end_drag|exchange|process-cancel|process_cancel|paste-clipboard|paste_clipboard|copy-clipboard|copy_clipboard|cut-clipboard|cut_clipboard|copy-primary|copy_primary|cut-primary|cut_primary|newline|newline-and-indent|newline_and_indent|newline-no-indent|newline_no_indent|delete-selection|delete_selection|delete-previous-character|delete_previous_character|delete-next-character|delete_next_character|delete-previous-word|delete_previous_word|delete-next-word|delete_next_word|delete-to-start-of-line|delete_to_start_of_line|delete-to-end-of-line|delete_to_end_of_line|forward-character|forward_character|backward-character|backward_character|key-select|key_select|process-up|process_up|process-down|process_down|process-shift-up|process_shift_up|process-shift-down|process_shift_down|process-home|process_home|forward-word|forward_word|backward-word|backward_word|forward-paragraph|forward_paragraph|backward-paragraph|backward_paragraph|beginning-of-line|beginning_of_line|end-of-line|end_of_line|beginning-of-file|beginning_of_file|end-of-file|end_of_file|next-page|next_page|previous-page|previous_page|page-left|page_left|page-right|page_right|toggle-overstrike|toggle_overstrike|scroll-up|scroll_up|scroll-down|scroll_down|scroll_left|scroll_right|scroll-to-line|scroll_to_line|select-all|select_all|select_word|deselect-all|deselect_all|focusIn|focusOut|process-return|process_return|process-tab|process_tab|insert-string|insert_string|mouse_pan)(?=\\s*\\()\":::Subroutine::\n\
106 Macro Hooks:\"<(?:(?:pre|post)_(?:open|save)|cursor_moved|modified|(?:losing_)?focus)_hook(?=\\s*\\()\":::Subroutine1::\n\
107 - Keyword:\"<(?:break|continue|define|delete|do|else|for|if|in|return|typeof|while)>\":::Keyword::\n\
108 + Keyword:\"<(?:break|continue|define|delete|do|else|for|if|in|readonly|return|typeof|while)>\":::Keyword::\n\
109 Braces:\"[{}\\[\\]]\":::Keyword::\n\
110 Global Variable:\"\\$[A-Za-z0-9_]+\":::Identifier1::\n\
111 String sq:\"'\":\"'\"::String::\n\