Skip to content

Instantly share code, notes, and snippets.

@ujihisa
Created July 29, 2009 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ujihisa/158449 to your computer and use it in GitHub Desktop.
Save ujihisa/158449 to your computer and use it in GitHub Desktop.
diff --git a/parse.y b/parse.y
index 10ac878..e02a1b1 100644
--- a/parse.y
+++ b/parse.y
@@ -685,6 +685,7 @@ static void token_info_pop(struct parser_params*, const char *token);
%type <val> program reswords then do dot_or_colon
%*/
%token tUPLUS /* unary+ */
+%token tINCR /* ++var */
%token tUMINUS /* unary- */
%token tPOW /* ** */
%token tCMP /* <=> */
@@ -1783,6 +1784,7 @@ op : '|' { ifndef_ripper($$ = '|'); }
| '!' { ifndef_ripper($$ = '!'); }
| '~' { ifndef_ripper($$ = '~'); }
| tUPLUS { ifndef_ripper($$ = tUPLUS); }
+ | tINCR { ifndef_ripper($$ = tINCR); }
| tUMINUS { ifndef_ripper($$ = tUMINUS); }
| tAREF { ifndef_ripper($$ = tAREF); }
| tASET { ifndef_ripper($$ = tASET); }
@@ -4130,6 +4132,15 @@ var_ref : variable
$$ = dispatch1(var_ref, $1);
%*/
}
+ | tINCR variable
+ {
+ /*%%%*/
+ $$ = assignable($2, 0);
+ $$->nd_value = NEW_CALL(gettable($$->nd_vid), rb_intern("succ"), 0);
+ /*%
+ $$ = dispatch2(unary, ripper_intern("++@"), $2);
+ %*/
+ }
;
var_lhs : variable
@@ -6773,6 +6784,9 @@ parser_yylex(struct parser_params *parser)
case '+':
c = nextc();
+ if (c == '+') {
+ return tINCR;
+ }
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
lex_state = EXPR_ARG;
if (c == '@') {
@@ -8277,6 +8291,7 @@ void_expr_gen(struct parser_params *parser, NODE *node)
case '%':
case tPOW:
case tUPLUS:
+ case tINCR:
case tUMINUS:
case '|':
case '^':
@@ -9111,6 +9126,7 @@ static const struct {
{'-', "-(binary)"},
{tPOW, "**"},
{tUPLUS, "+@"},
+ {tINCR, "++@"},
{tUMINUS, "-@"},
{tCMP, "<=>"},
{tGEQ, ">="},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment