patch:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/org/jruby/lexer/yacc/RubyYaccLexer.java b/src/org/jruby/lexer/yacc/RubyYaccLexer.java | |
index 422d4b9..d6173ab 100644 | |
--- a/src/org/jruby/lexer/yacc/RubyYaccLexer.java | |
+++ b/src/org/jruby/lexer/yacc/RubyYaccLexer.java | |
@@ -1751,6 +1751,10 @@ public class RubyYaccLexer { | |
private int plus(boolean spaceSeen) throws IOException { | |
int c = src.read(); | |
+ if (c == '+') { | |
+ yaccValue = new Token("++@", getPosition()); | |
+ return Tokens.tINCR; | |
+ } | |
if (lex_state == LexState.EXPR_FNAME || lex_state == LexState.EXPR_DOT) { | |
lex_state = LexState.EXPR_ARG; | |
if (c == '@') { | |
diff --git a/src/org/jruby/parser/DefaultRubyParser.y b/src/org/jruby/parser/DefaultRubyParser.y | |
index 66a9fe3..663f46b 100644 | |
--- a/src/org/jruby/parser/DefaultRubyParser.y | |
+++ b/src/org/jruby/parser/DefaultRubyParser.y | |
@@ -162,6 +162,7 @@ public class DefaultRubyParser implements RubyParser { | |
%type <Token> sym symbol operation operation2 operation3 cname fname op | |
%type <Token> f_norm_arg dot_or_colon restarg_mark blkarg_mark | |
%token <Token> tUPLUS /* unary+ */ | |
+%token <Token> tINCR /* ++ */ | |
%token <Token> tUMINUS /* unary- */ | |
%token <Token> tUMINUS_NUM /* unary- */ | |
%token <Token> tPOW /* ** */ | |
@@ -265,7 +266,7 @@ public class DefaultRubyParser implements RubyParser { | |
%left tSTAR2 tDIVIDE tPERCENT | |
%right tUMINUS_NUM tUMINUS | |
%right tPOW | |
-%right tBANG tTILDE tUPLUS | |
+%right tBANG tTILDE tUPLUS tINCR | |
%% | |
program : { | |
@@ -697,7 +698,7 @@ undef_list : fitem { | |
// Token:op - inline operations [!null] | |
op : tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ | tMATCH | tGT | |
| tGEQ | tLT | tLEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2 | |
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tTILDE | tUPLUS | tUMINUS | |
+ | tSTAR | tDIVIDE | tPERCENT | tPOW | tTILDE | tUPLUS | tINCR | tUMINUS | |
| tAREF | tASET | tBACK_REF2 | |
// Keyword:reswords - reserved words [!null] | |
@@ -1666,6 +1667,12 @@ variable : tIDENTIFIER | tIVAR | tGVAR | tCONSTANT | tCVAR | |
var_ref : variable { | |
$$ = support.gettable($1); | |
} | |
+ | tINCR variable { | |
+ $$ = support.assignable($2, NilImplicitNode.NIL); | |
+ //$$.setValueNode(support.getOperatorCallNode(support.gettable2((Node) $$), "||", $$)); | |
+ ((AssignableNode) $$).setValueNode(support.new_call(support.gettable2((AssignableNode) $$), (new Token("succ", support.getPosition($2))), null, null)); | |
+ //$$->nd_value = NEW_CALL(gettable($$->nd_vid), rb_intern("succ"), 0); | |
+ } | |
// AssignableNode:var_lhs - Variable on left hand side of assignment [!null] | |
var_lhs : variable { | |
diff --git a/src/org/jruby/parser/Tokens.java b/src/org/jruby/parser/Tokens.java | |
index 1ef6be8..7691243 100644 | |
--- a/src/org/jruby/parser/Tokens.java | |
+++ b/src/org/jruby/parser/Tokens.java | |
@@ -104,6 +104,7 @@ public interface Tokens { | |
int tNTH_REF = DefaultRubyParser.tNTH_REF; | |
int tUPLUS = DefaultRubyParser.tUPLUS; | |
+ int tINCR = DefaultRubyParser.tINCR; | |
int tUMINUS = DefaultRubyParser.tUMINUS; | |
int tUMINUS_NUM = DefaultRubyParser.tUMINUS_NUM; | |
int tPOW = DefaultRubyParser.tPOW; |