Branch: Tag:

2004-10-30

2004-10-30 11:38:29 by Martin Stjernholm <mast@lysator.liu.se>

Implemented from-the-end indexing in ranges using the a[..<1] syntax. Added
`[..]. Still to do: Avoid fallback to `[] for ranges if it doesn't take two
args.

Rev: src/docode.c:1.181
Rev: src/interpret.c:1.358
Rev: src/interpret_functions.h:1.176
Rev: src/language.yacc:1.347
Rev: src/las.c:1.351
Rev: src/lexer.h:1.51
Rev: src/opcodes.h:1.41
Rev: src/operators.c:1.198
Rev: src/operators.h:1.16
Rev: src/pike_types.c:1.238
Rev: src/program.c:1.573
Rev: src/program.h:1.213
Rev: src/testsuite.in:1.741
Rev: src/treeopt.in:1.74

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: language.yacc,v 1.346 2004/10/26 17:27:31 grubba Exp $ + || $Id: language.yacc,v 1.347 2004/10/30 11:38:26 mast Exp $   */      %pure_parser
296:   %type <n> safe_comma_expr   %type <n> comma_expr   %type <n> comma_expr2 - %type <n> comma_expr_or_maxint - %type <n> comma_expr_or_zero + %type <n> range_bound   %type <n> cond   %type <n> continue   %type <n> default
3253:    free_node ($2);    }    | expr4 open_bracket_with_line_info -  comma_expr_or_zero expected_dot_dot comma_expr_or_maxint ']' +  range_bound expected_dot_dot range_bound ']'    { -  $$=mknode(F_RANGE,$1,mknode(F_ARG_LIST,$3,$5)); +  $$=mknode(F_RANGE,$1,mknode(':',$3,$5));    COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    }
3663:    }    ;    - comma_expr_or_zero: /* empty */ { $$=mkintnode(0); } + range_bound: +  /* empty */ +  {$$ = mknode (F_RANGE_OPEN, NULL, NULL);}    | comma_expr -  | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=0; } +  {$$ = mknode (F_RANGE_FROM_BEG, $1, NULL);} +  | '<' comma_expr +  {$$ = mknode (F_RANGE_FROM_END, $2, NULL);} +  | TOK_LEX_EOF +  { +  yyerror("Unexpected end of file."); +  $$ = mknode (F_RANGE_OPEN, NULL, NULL); +  } +  | '<' TOK_LEX_EOF +  { +  yyerror("Unexpected end of file."); +  $$ = mknode (F_RANGE_OPEN, NULL, NULL); +  }    ;    - comma_expr_or_maxint: /* empty */ { $$=mkintnode(MAX_INT_TYPE); } -  | comma_expr -  | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=mkintnode(MAX_INT_TYPE); } -  ; -  +    gauge: TOK_GAUGE catch_arg    {    $$=mkopernode("`/",