diff options
Diffstat (limited to 'src/gram.y')
-rwxr-xr-x | src/gram.y | 120 |
1 files changed, 90 insertions, 30 deletions
@@ -26,6 +26,8 @@ #include "plot.h" #include "subtotal.h" +#include "cmds_command.h" + void yyerror(char *err); // error routine for yacc (gram.y) int yylex(); @@ -88,9 +90,9 @@ int yylex(); /* token S_INSERTCOL token S_OPENCOL -token S_DELETECOL token S_YANKCOL */ +%token S_DELETECOL %token S_DATEFMT %token S_SUBTOTAL %token S_RSUBTOTAL @@ -118,6 +120,7 @@ token S_YANKCOL %token S_SEVAL %token S_ERROR %token S_FILL +%token S_STRTONUM /* token S_ADDNOTE token S_DELNOTE @@ -160,7 +163,9 @@ token S_YANKCOL token S_SELECT token S_INSERTROW token S_OPENROW - token S_DELETEROW +*/ +%token S_DELETEROW +/* token S_YANKROW token S_PULL token S_PULLMERGE @@ -182,6 +187,7 @@ token S_YANKCOL token S_PLUGIN token S_PLUGOUT */ +%token S_VALUEIZEALL %token S_SHIFT %token S_GETNUM %token S_GETSTRING @@ -189,6 +195,7 @@ token S_YANKCOL %token S_GETFMT %token S_GETFORMAT %token S_RECALC +%token S_EXECUTE %token S_QUIT %token S_REBUILD_GRAPH %token S_PRINT_GRAPH @@ -208,6 +215,7 @@ token S_YANKCOL %token S_CELLCOLOR %token S_UNFORMAT %token S_REDEFINE_COLOR +%token S_DEFINE_COLOR %token S_SET %token S_FCOPY %token S_FSUM @@ -234,8 +242,14 @@ token S_YANKCOL %token K_NONUMERIC_DECIMAL %token K_NUMERIC_ZERO %token K_NONUMERIC_ZERO +%token K_FILENAME_WITH_MODE +%token K_NOFILENAME_WITH_MODE %token K_OVERLAP %token K_NOOVERLAP +%token K_INPUT_BAR_BOTTOM +%token K_UNDERLINE_GRID +%token K_TRUNCATE +%token K_NOTRUNCATE %token K_QUIT_AFTERLOAD %token K_NOQUIT_AFTERLOAD %token K_XLSX_READFORMULAS @@ -316,6 +330,7 @@ token S_YANKCOL %token K_VLOOKUP %token K_INDEX %token K_STINDEX +%token K_GETENT /* token K_AUTO token K_AUTOINSERT @@ -334,14 +349,6 @@ token K_COLOR token K_COLORNEG token K_COLORERR token K_BRAILLE -token K_BLACK -token K_RED -token K_GREEN -token K_YELLOW -token K_BLUE -token K_MAGENTA -token K_CYAN -token K_WHITE */ %token K_TBLSTYLE %token K_TBL @@ -362,15 +369,13 @@ token K_WHITE %token K_ROWLIMIT %token K_COLLIMIT %token K_PAGESIZE -/* - token K_NUMITER -*/ %token K_ERR %token K_REF %token K_LOCALE %token K_SET8BIT %token K_ASCII %token K_CHR +%token K_FACT %right ';' %left '?' ':' @@ -472,6 +477,11 @@ command: | S_SHOW COL { show_col($2, 1); } // show de una unica columna | S_SHOW NUMBER { show_row($2, 1); } // show de una unica fila +/* more scripting commands */ + | S_DELETECOL COL { deletecol($2, 1); } + | S_DELETEROW NUMBER { deleterow($2, 1); } + + /* agregados para scim */ | S_HIDECOL COL { hide_col($2, 1); } // hide de una unica columna @@ -510,6 +520,7 @@ command: currow = r < currow ? r : r < currow + arg ? currow : r - arg; } + | S_VALUEIZEALL { valueize_area(0, 0, maxrow, maxcol); } | S_SHIFT var_or_range STRING { if (strlen($3) != 1 || ($3[0] != 'h' && $3[0] != 'j' && $3[0] != 'k' && $3[0] != 'l')) { sc_error("wrong parameter for shift command"); @@ -580,6 +591,7 @@ command: // | S_GOTO WORD { /* don't repeat last goto on "unintelligible word" */ ; } | S_CCOPY range { copy_to_clipboard($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col); } +| S_STRTONUM range { convert_string_to_number($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col); } | S_CPASTE { paste_from_clipboard(); } | S_LOCK var_or_range { lock_cells($2.left.vp, $2.right.vp); } | S_UNLOCK var_or_range { unlock_cells($2.left.vp, $2.right.vp); } @@ -640,7 +652,7 @@ command: | S_CELLCOLOR var_or_range STRING { #ifdef USECOLORS - if ( ! atoi(get_conf_value("nocurses"))) + if ( ! get_conf_int("nocurses")) color_cell($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col, $3); #endif scxfree($3); @@ -657,7 +669,7 @@ command: | S_CELLCOLOR STRING { #ifdef USECOLORS - if ( ! atoi(get_conf_value("nocurses"))) + if ( ! get_conf_int("nocurses")) color_cell(currow, curcol, currow, curcol, $2); #endif scxfree($2); @@ -665,20 +677,22 @@ command: | S_UNFORMAT var_or_range { #ifdef USECOLORS - if ( ! atoi(get_conf_value("nocurses"))) unformat($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col); + if ( ! get_conf_int("nocurses")) unformat($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col); #endif } | S_UNFORMAT { #ifdef USECOLORS - if ( ! atoi(get_conf_value("nocurses"))) unformat(currow, curcol, currow, curcol); + if ( ! get_conf_int("nocurses")) unformat(currow, curcol, currow, curcol); #endif } | S_REDEFINE_COLOR STRING NUMBER NUMBER NUMBER { redefine_color($2, $3, $4, $5); scxfree($2); } - + | S_DEFINE_COLOR STRING NUMBER NUMBER NUMBER { + define_color($2, $3, $4, $5); + scxfree($2); } | S_FCOPY { fcopy(""); } | S_FCOPY strarg { fcopy($2); } | S_FSUM { fsum(); } @@ -716,6 +730,30 @@ command: eval_result = eval(NULL, $2); efree($2); } + | S_EXECUTE STRING { + + inputline[0]=L'\0'; + + #ifdef HISTORY_FILE + commandline_history = (struct history *) create_history(':'); + load_history(commandline_history, ':'); // load the command history file + #endif + #ifdef INS_HISTORY_FILE + insert_history = (struct history *) create_history('='); + load_history(insert_history, '='); // load the insert history file + #endif + + (void) swprintf(inputline, BUFFERSIZE, L"%s", $2); + + struct block * auxb = (struct block *) create_buf(); + addto_buf(auxb, OKEY_ENTER); + do_commandmode(auxb); + flush_buf(auxb); + erase_buf(auxb); + auxb = NULL; + inputline[0]=L'\0'; + scxfree($2); + } | S_QUIT { printf("quitting. unsaved changes will be lost.\n"); shall_quit = 2; // unsaved changes are lost! @@ -781,6 +819,16 @@ term: var { $$ = new_var(O_VAR, $1); } | '@' K_FIXED term { $$ = new('f', $3, ENULL); } | '(' '@' K_FIXED ')' term { $$ = new('F', $5, ENULL); } + | '@' K_GETENT '(' NUMBER ',' NUMBER ')' { + struct ent_ptr ep; + ep.vp = lookat($4, $6); + ep.vf = 0; + $$ = new(GETENT, new_var(O_VAR, ep), ENULL); + + // Work on issue #451. + // @sum(A0:@getent(@lastrow, 2)) + // @sum(A0:@getent("A",@lastrow)) + } | '@' K_SUM '(' var_or_range ')' { $$ = new(SUM, new_range(REDUCE | SUM, $4), ENULL); } | '@' K_SUM '(' range ',' e ')' @@ -942,17 +990,7 @@ term: var { $$ = new_var(O_VAR, $1); } | K_ERR { $$ = new(ERR_, ENULL, ENULL); } | '@' K_REF { $$ = new(REF_, ENULL, ENULL); } | K_REF { $$ = new(REF_, ENULL, ENULL); } -/* - | '@' K_NUMITER { $$ = new(NUMITER, ENULL, ENULL);} - | '@' K_BLACK { $$ = new(BLACK, ENULL, ENULL); } - | '@' K_RED { $$ = new(RED, ENULL, ENULL); } - | '@' K_GREEN { $$ = new(GREEN, ENULL, ENULL); } - | '@' K_YELLOW { $$ = new(YELLOW, ENULL, ENULL); } - | '@' K_BLUE { $$ = new(BLUE, ENULL, ENULL); } - | '@' K_MAGENTA { $$ = new(MAGENTA, ENULL, ENULL); } - | '@' K_CYAN { $$ = new(CYAN, ENULL, ENULL); } - | '@' K_WHITE { $$ = new(WHITE, ENULL, ENULL); } -*/ + | '@' K_FACT '(' e ')' { $$ = new(FACT, $4, ENULL); } ; /* expressions */ @@ -1033,10 +1071,32 @@ setlist : /* things that you can 'set' */ setitem : - K_OVERLAP '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "overlap=0", TRUE); + K_FILENAME_WITH_MODE '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "filename_with_mode=0", TRUE); + else parse_str(user_conf_d, "filename_with_mode=1", TRUE); } + | K_FILENAME_WITH_MODE { parse_str(user_conf_d, "filename_with_mode=1", TRUE); } + | K_NOFILENAME_WITH_MODE { parse_str(user_conf_d, "filename_with_mode=0", TRUE); } + + | K_OVERLAP '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "overlap=0", TRUE); else parse_str(user_conf_d, "overlap=1", TRUE); } | K_OVERLAP { parse_str(user_conf_d, "overlap=1", TRUE); } + | K_INPUT_BAR_BOTTOM '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "input_bar_bottom=0", TRUE); + else parse_str(user_conf_d, "input_bar_bottom=1", TRUE); + ui_mv_bottom_bar(); } + | K_INPUT_BAR_BOTTOM { parse_str(user_conf_d, "input_bar_bottom=1", TRUE); + ui_mv_bottom_bar(); + } + + | K_UNDERLINE_GRID '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "underline_grid=0", TRUE); + else parse_str(user_conf_d, "underline_grid=1", TRUE); } + | K_UNDERLINE_GRID { parse_str(user_conf_d, "underline_grid=1", TRUE); + } + | K_NOOVERLAP { parse_str(user_conf_d, "overlap=0", TRUE); } + + | K_TRUNCATE '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "truncate=0", TRUE); + else parse_str(user_conf_d, "truncate=1", TRUE); } + | K_TRUNCATE { parse_str(user_conf_d, "truncate=1", TRUE); } + | K_NOTRUNCATE { parse_str(user_conf_d, "truncate=0", TRUE); } | K_AUTOBACKUP '=' NUMBER { char cmd[MAXCMD]; sprintf(cmd, "autobackup=%d", $3); |