rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
| meta
stringlengths 141
403
|
---|---|---|---|
while (ISSPACE(c)) { | while (isSpace(c)) { | private int parse_quotedwords(int term, int paren) { Node qwords = null; int strstart; int c; int nest = 0; strstart = ruby.getSourceLine(); newtok(); c = nextc(); while (ISSPACE(c)) { c = nextc(); } /* * skip preceding spaces */ pushback(c); while ((c = nextc()) != term || nest > 0) { if (c == -1) { ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } if (c == '\\') { c = nextc(); switch (c) { case '\n' : continue; case '\\' : c = '\\'; break; default : if (c == term || (paren != 0 && c == paren)) { tokadd(c); continue; } if (!ISSPACE(c)) { tokadd('\\'); } break; } } else if (ISSPACE(c)) { tokfix(); Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); newtok(); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } c = nextc(); while (ISSPACE(c)) { c = nextc(); } // skip continuous spaces pushback(c); continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); if (toklen() > 0) { Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } } if (qwords == null) { qwords = nf.newZArray(); } yyVal = qwords; ph.setLexState(LexState.EXPR_END); return Token.tDSTRING; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (!ISSPACE(c)) { | if (!isSpace(c)) { | private int parse_quotedwords(int term, int paren) { Node qwords = null; int strstart; int c; int nest = 0; strstart = ruby.getSourceLine(); newtok(); c = nextc(); while (ISSPACE(c)) { c = nextc(); } /* * skip preceding spaces */ pushback(c); while ((c = nextc()) != term || nest > 0) { if (c == -1) { ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } if (c == '\\') { c = nextc(); switch (c) { case '\n' : continue; case '\\' : c = '\\'; break; default : if (c == term || (paren != 0 && c == paren)) { tokadd(c); continue; } if (!ISSPACE(c)) { tokadd('\\'); } break; } } else if (ISSPACE(c)) { tokfix(); Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); newtok(); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } c = nextc(); while (ISSPACE(c)) { c = nextc(); } // skip continuous spaces pushback(c); continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); if (toklen() > 0) { Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } } if (qwords == null) { qwords = nf.newZArray(); } yyVal = qwords; ph.setLexState(LexState.EXPR_END); return Token.tDSTRING; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
} else if (ISSPACE(c)) { | } else if (isSpace(c)) { | private int parse_quotedwords(int term, int paren) { Node qwords = null; int strstart; int c; int nest = 0; strstart = ruby.getSourceLine(); newtok(); c = nextc(); while (ISSPACE(c)) { c = nextc(); } /* * skip preceding spaces */ pushback(c); while ((c = nextc()) != term || nest > 0) { if (c == -1) { ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } if (c == '\\') { c = nextc(); switch (c) { case '\n' : continue; case '\\' : c = '\\'; break; default : if (c == term || (paren != 0 && c == paren)) { tokadd(c); continue; } if (!ISSPACE(c)) { tokadd('\\'); } break; } } else if (ISSPACE(c)) { tokfix(); Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); newtok(); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } c = nextc(); while (ISSPACE(c)) { c = nextc(); } // skip continuous spaces pushback(c); continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); if (toklen() > 0) { Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } } if (qwords == null) { qwords = nf.newZArray(); } yyVal = qwords; ph.setLexState(LexState.EXPR_END); return Token.tDSTRING; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int parse_quotedwords(int term, int paren) { Node qwords = null; int strstart; int c; int nest = 0; strstart = ruby.getSourceLine(); newtok(); c = nextc(); while (ISSPACE(c)) { c = nextc(); } /* * skip preceding spaces */ pushback(c); while ((c = nextc()) != term || nest > 0) { if (c == -1) { ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } if (c == '\\') { c = nextc(); switch (c) { case '\n' : continue; case '\\' : c = '\\'; break; default : if (c == term || (paren != 0 && c == paren)) { tokadd(c); continue; } if (!ISSPACE(c)) { tokadd('\\'); } break; } } else if (ISSPACE(c)) { tokfix(); Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); newtok(); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } c = nextc(); while (ISSPACE(c)) { c = nextc(); } // skip continuous spaces pushback(c); continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); if (toklen() > 0) { Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } } if (qwords == null) { qwords = nf.newZArray(); } yyVal = qwords; ph.setLexState(LexState.EXPR_END); return Token.tDSTRING; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
while (ISSPACE(c)) { | while (isSpace(c)) { | private int parse_quotedwords(int term, int paren) { Node qwords = null; int strstart; int c; int nest = 0; strstart = ruby.getSourceLine(); newtok(); c = nextc(); while (ISSPACE(c)) { c = nextc(); } /* * skip preceding spaces */ pushback(c); while ((c = nextc()) != term || nest > 0) { if (c == -1) { ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } if (c == '\\') { c = nextc(); switch (c) { case '\n' : continue; case '\\' : c = '\\'; break; default : if (c == term || (paren != 0 && c == paren)) { tokadd(c); continue; } if (!ISSPACE(c)) { tokadd('\\'); } break; } } else if (ISSPACE(c)) { tokfix(); Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); newtok(); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } c = nextc(); while (ISSPACE(c)) { c = nextc(); } // skip continuous spaces pushback(c); continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); if (toklen() > 0) { Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } } if (qwords == null) { qwords = nf.newZArray(); } yyVal = qwords; ph.setLexState(LexState.EXPR_END); return Token.tDSTRING; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int parse_quotedwords(int term, int paren) { Node qwords = null; int strstart; int c; int nest = 0; strstart = ruby.getSourceLine(); newtok(); c = nextc(); while (ISSPACE(c)) { c = nextc(); } /* * skip preceding spaces */ pushback(c); while ((c = nextc()) != term || nest > 0) { if (c == -1) { ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } if (c == '\\') { c = nextc(); switch (c) { case '\n' : continue; case '\\' : c = '\\'; break; default : if (c == term || (paren != 0 && c == paren)) { tokadd(c); continue; } if (!ISSPACE(c)) { tokadd('\\'); } break; } } else if (ISSPACE(c)) { tokfix(); Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); newtok(); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } c = nextc(); while (ISSPACE(c)) { c = nextc(); } // skip continuous spaces pushback(c); continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); if (toklen() > 0) { Node str = nf.newStr(RubyString.newString(ruby, tok(), toklen())); if (qwords == null) { qwords = nf.newList(str); } else { ph.list_append(qwords, str); } } if (qwords == null) { qwords = nf.newZArray(); } yyVal = qwords; ph.setLexState(LexState.EXPR_END); return Token.tDSTRING; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
tokfix(); | private int parse_regx(int term, int paren) { int c; char kcode = 0; boolean once = false; int nest = 0; int options = 0; int re_start = ruby.getSourceLine(); Node list = null; newtok(); regx_end : while ((c = nextc()) != -1) { if (c == term && nest == 0) { break regx_end; } switch (c) { case '#' : list = str_extend(list, term); if (list == Node.MINUS_ONE) { return 0; } continue; case '\\' : if (tokadd_escape(term) < 0) { /* * FIX 1.6.5 */ return 0; } continue; case -1 : //goto unterminated; ruby.setSourceLine(re_start); ph.rb_compile_error("unterminated regexp meets end of file"); return 0; default : if (paren != 0) { if (c == paren) { nest++; } if (c == term) { nest--; } } break; } tokadd(c); } end_options : for (;;) { switch (c = nextc()) { case 'i' : options |= ReOptions.RE_OPTION_IGNORECASE; break; case 'x' : options |= ReOptions.RE_OPTION_EXTENDED; break; case 'p' : // /p is obsolete ph.rb_warn("/p option is obsolete; use /m\n\tnote: /m does not change ^, $ behavior"); options |= ReOptions.RE_OPTION_POSIXLINE; break; case 'm' : options |= ReOptions.RE_OPTION_MULTILINE; break; case 'o' : once = true; break; case 'n' : kcode = 16; break; case 'e' : kcode = 32; break; case 's' : kcode = 48; break; case 'u' : kcode = 64; break; default : pushback(c); break end_options; } } tokfix(); ph.setLexState(LexState.EXPR_END); if (list != null) { list.setLine(re_start); if (toklen() > 0) { RubyObject ss = RubyString.newString(ruby, tok(), toklen()); ph.list_append(list, nf.newStr(ss)); } // new RuntimeException("Want to change " + list.getClass().getName() + "to DRegxNode").printStackTrace(); // list.nd_set_type(once ? NODE.NODE_DREGX_ONCE : NODE.NODE_DREGX); if (once) { list = new DRegxOnceNode(list.getLiteral(), options | kcode); } else { list = new DRegxNode(list.getLiteral(), options | kcode); } // list.setCFlag(options | kcode); yyVal = list; return Token.tDREGEXP; } else { yyVal = rb_reg_new(tok(), toklen(), options | kcode); return Token.tREGEXP; } //unterminated: //ruby_sourceline = re_start; //rb_compile_error("unterminated regexp meets end of file"); //return 0; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
yyVal = rb_reg_new(tok(), toklen(), options | kcode); | yyVal = newRegexp(tok(), toklen(), options | kcode); | private int parse_regx(int term, int paren) { int c; char kcode = 0; boolean once = false; int nest = 0; int options = 0; int re_start = ruby.getSourceLine(); Node list = null; newtok(); regx_end : while ((c = nextc()) != -1) { if (c == term && nest == 0) { break regx_end; } switch (c) { case '#' : list = str_extend(list, term); if (list == Node.MINUS_ONE) { return 0; } continue; case '\\' : if (tokadd_escape(term) < 0) { /* * FIX 1.6.5 */ return 0; } continue; case -1 : //goto unterminated; ruby.setSourceLine(re_start); ph.rb_compile_error("unterminated regexp meets end of file"); return 0; default : if (paren != 0) { if (c == paren) { nest++; } if (c == term) { nest--; } } break; } tokadd(c); } end_options : for (;;) { switch (c = nextc()) { case 'i' : options |= ReOptions.RE_OPTION_IGNORECASE; break; case 'x' : options |= ReOptions.RE_OPTION_EXTENDED; break; case 'p' : // /p is obsolete ph.rb_warn("/p option is obsolete; use /m\n\tnote: /m does not change ^, $ behavior"); options |= ReOptions.RE_OPTION_POSIXLINE; break; case 'm' : options |= ReOptions.RE_OPTION_MULTILINE; break; case 'o' : once = true; break; case 'n' : kcode = 16; break; case 'e' : kcode = 32; break; case 's' : kcode = 48; break; case 'u' : kcode = 64; break; default : pushback(c); break end_options; } } tokfix(); ph.setLexState(LexState.EXPR_END); if (list != null) { list.setLine(re_start); if (toklen() > 0) { RubyObject ss = RubyString.newString(ruby, tok(), toklen()); ph.list_append(list, nf.newStr(ss)); } // new RuntimeException("Want to change " + list.getClass().getName() + "to DRegxNode").printStackTrace(); // list.nd_set_type(once ? NODE.NODE_DREGX_ONCE : NODE.NODE_DREGX); if (once) { list = new DRegxOnceNode(list.getLiteral(), options | kcode); } else { list = new DRegxNode(list.getLiteral(), options | kcode); } // list.setCFlag(options | kcode); yyVal = list; return Token.tDREGEXP; } else { yyVal = rb_reg_new(tok(), toklen(), options | kcode); return Token.tREGEXP; } //unterminated: //ruby_sourceline = re_start; //rb_compile_error("unterminated regexp meets end of file"); //return 0; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
yyVal = RubyString.newString(ruby, lex_curline, lex_pend - 1); lex_p = lex_pend; | yyVal = RubyString.newString(ruby, support.readLine()); | private int parse_string(int func, int term, int paren) { int c; Node list = null; int strstart; int nest = 0; if (func == '\'') { return parse_qstring(term, paren); } if (func == 0) { // read 1 line for heredoc // -1 for chomp yyVal = RubyString.newString(ruby, lex_curline, lex_pend - 1); lex_p = lex_pend; return Token.tSTRING; } strstart = ruby.getSourceLine(); newtok(); while ((c = nextc()) != term || nest > 0) { if (c == -1) { //unterm_str: ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * tokadd(c); * c = nextc(); * } * } * else */ if (c == '#') { list = str_extend(list, term); if (list == Node.MINUS_ONE) { //goto unterm_str; ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } continue; } else if (c == '\\') { c = nextc(); if (c == '\n') { continue; } if (c == term) { tokadd(c); } else { pushback(c); if (func != '"') { tokadd('\\'); } tokadd(read_escape()); } continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); ph.setLexState(LexState.EXPR_END); if (list != null) { list.setLine(strstart); if (toklen() > 0) { RubyObject ss = RubyString.newString(ruby, tok(), toklen()); ph.list_append(list, nf.newStr(ss)); } yyVal = list; if (func == '`') { // new RuntimeException("[BUG] want to change " + list.getClass().getName() + " to DXStrNode").printStackTrace(); // list.nd_set_type(Constants.NODE_DXSTR); list = new DXStrNode(list.getLiteral()); yyVal = list; return Token.tDXSTRING; } else { return Token.tDSTRING; } } else { yyVal = RubyString.newString(ruby, tok(), toklen()); return (func == '`') ? Token.tXSTRING : Token.tSTRING; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int parse_string(int func, int term, int paren) { int c; Node list = null; int strstart; int nest = 0; if (func == '\'') { return parse_qstring(term, paren); } if (func == 0) { // read 1 line for heredoc // -1 for chomp yyVal = RubyString.newString(ruby, lex_curline, lex_pend - 1); lex_p = lex_pend; return Token.tSTRING; } strstart = ruby.getSourceLine(); newtok(); while ((c = nextc()) != term || nest > 0) { if (c == -1) { //unterm_str: ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * tokadd(c); * c = nextc(); * } * } * else */ if (c == '#') { list = str_extend(list, term); if (list == Node.MINUS_ONE) { //goto unterm_str; ruby.setSourceLine(strstart); ph.rb_compile_error("unterminated string meets end of file"); return 0; } continue; } else if (c == '\\') { c = nextc(); if (c == '\n') { continue; } if (c == term) { tokadd(c); } else { pushback(c); if (func != '"') { tokadd('\\'); } tokadd(read_escape()); } continue; } if (paren != 0) { if (c == paren) { nest++; } if (c == term && nest-- == 0) { break; } } tokadd(c); } tokfix(); ph.setLexState(LexState.EXPR_END); if (list != null) { list.setLine(strstart); if (toklen() > 0) { RubyObject ss = RubyString.newString(ruby, tok(), toklen()); ph.list_append(list, nf.newStr(ss)); } yyVal = list; if (func == '`') { // new RuntimeException("[BUG] want to change " + list.getClass().getName() + " to DXStrNode").printStackTrace(); // list.nd_set_type(Constants.NODE_DXSTR); list = new DXStrNode(list.getLiteral()); yyVal = list; return Token.tDXSTRING; } else { return Token.tDSTRING; } } else { yyVal = RubyString.newString(ruby, tok(), toklen()); return (func == '`') ? Token.tXSTRING : Token.tSTRING; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
return lex_p != lex_pend && c == lex_curline.charAt(lex_p); | return source.isNext((char) c); | private boolean peek(int c) { return lex_p != lex_pend && c == lex_curline.charAt(lex_p); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (c == -1) { return; } lex_p--; | source.unread(); | private void pushback(int c) { if (c == -1) { return; } lex_p--; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
c = (int) scan_hex(lex_curline, lex_p, 2, numlen); lex_p += numlen[0]; | c = (int) support.readHexAsInt(2); | private int read_escape() { int c; switch (c = nextc()) { case '\\' : // Backslash return c; case 'n' : // newline return '\n'; case 't' : // horizontal tab return '\t'; case 'r' : // carriage-return return '\r'; case 'f' : // form-feed return '\f'; case 'v' : // vertical tab return '\013'; case 'a' : // alarm(bell) return '\007'; case 'e' : // escape return '\033'; case '0' : case '1' : case '2' : case '3' : // octal constant case '4' : case '5' : case '6' : case '7' : { int cc = 0; pushback(c); for (int i = 0; i < 3; i++) { c = nextc(); if (c == -1) { // goto eof yyerror("Invalid escape character syntax"); return '\0'; } if (c < '0' || '7' < c) { pushback(c); break; } cc = cc * 8 + c - '0'; } c = cc; } return c; case 'x' : // hex constant { int[] numlen = new int[1]; c = (int) scan_hex(lex_curline, lex_p, 2, numlen); lex_p += numlen[0]; } return c; case 'b' : // backspace return '\010'; case 's' : // space return ' '; case 'M' : if ((c = nextc()) != '-') { yyerror("Invalid escape character syntax"); pushback(c); return '\0'; } if ((c = nextc()) == '\\') { return read_escape() | 0x80; } else if (c == -1) { // goto eof yyerror("Invalid escape character syntax"); return '\0'; } else { return ((c & 0xff) | 0x80); } case 'C' : if ((c = nextc()) != '-') { yyerror("Invalid escape character syntax"); pushback(c); return '\0'; } case 'c' : if ((c = nextc()) == '\\') { c = read_escape(); } else if (c == '?') { return 0177; } else if (c == -1) { // goto eof yyerror("Invalid escape character syntax"); return '\0'; } return c & 0x9f; case -1 : // eof: yyerror("Invalid escape character syntax"); return '\0'; default : return c; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; | boolean is_float = false; boolean seen_point = false; boolean seen_e = false; boolean seen_uc = false; | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
is_float = seen_point = seen_e = seen_uc = false; | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
if (!ISXDIGIT(c)) { | if (!isHexDigit(c)) { | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
yyVal = rb_cstr2inum(tok(), 16); | yyVal = getNumFromString(tok(), 16); | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
yyVal = rb_cstr2inum(tok(), 2); | yyVal = getNumFromString(tok(), 2); | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
yyVal = rb_cstr2inum(tok(), 8); | yyVal = getNumFromString(tok(), 8); | private int start_num(int c) { boolean is_float; boolean seen_point; boolean seen_e; boolean seen_uc; is_float = seen_point = seen_e = seen_uc = false; ph.setLexState(LexState.EXPR_END); newtok(); if (c == '-' || c == '+') { tokadd(c); c = nextc(); } if (c == '0') { c = nextc(); if (c == 'x' || c == 'X') { // hexadecimal c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (!ISXDIGIT(c)) { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("hexadecimal number without hex-digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 16); return Token.tINTEGER; } if (c == 'b' || c == 'B') { // binary c = nextc(); do { if (c == '_') { seen_uc = true; continue; } if (c != '0' && c != '1') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (toklen() == 0) { yyerror("numeric literal without digits"); } else if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 2); return Token.tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { // octal do { if (c == '_') { seen_uc = true; continue; } if (c < '0' || c > '7') { break; } seen_uc = false; tokadd(c); } while ((c = nextc()) != 0); pushback(c); tokfix(); if (seen_uc) { return decode_num(c, is_float, seen_uc, true); } yyVal = rb_cstr2inum(tok(), 8); return Token.tINTEGER; } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); } else if (c == '.') { tokadd('0'); } else { pushback(c); yyVal = RubyFixnum.zero(ruby); return Token.tINTEGER; } } for (;;) { switch (c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : seen_uc = false; tokadd(c); break; case '.' : if (seen_point || seen_e) { return decode_num(c, is_float, seen_uc); } else { int c0 = nextc(); if (!Character.isDigit((char) c0)) { pushback(c0); return decode_num(c, is_float, seen_uc); } c = c0; } tokadd('.'); tokadd(c); is_float = true; seen_point = true; seen_uc = false; break; case 'e' : case 'E' : if (seen_e) { return decode_num(c, is_float, seen_uc); } tokadd(c); seen_e = true; is_float = true; while ((c = nextc()) == '_') { seen_uc = true; } if (c == '-' || c == '+') { tokadd(c); } else { continue; } break; case '_' : // '_' in number just ignored seen_uc = true; break; default : return decode_num(c, is_float, seen_uc); } c = nextc(); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (!is_identchar(c)) { | if (!isIdentifierChar(c)) { | private Node str_extend(Node list, int term) { int c; int brace = -1; RubyObject ss; Node node; int nest; c = nextc(); switch (c) { case '$' : case '@' : case '{' : break; default : tokadd('#'); pushback(c); return list; } ss = RubyString.newString(ruby, tok(), toklen()); if (list == null) { list = nf.newDStr(ss); } else if (toklen() > 0) { ph.list_append(list, nf.newStr(ss)); } newtok(); fetch_id : for (;;) { switch (c) { case '$' : tokadd('$'); c = nextc(); if (c == -1) { return Node.MINUS_ONE; } switch (c) { case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } pushback(c); break fetch_id; case '&' : case '+' : case '_' : case '~' : case '*' : case '$' : case '?' : case '!' : case '@' : case ',' : case '.' : case '=' : case ':' : case '<' : case '>' : case '\\' : //refetch: tokadd(c); break fetch_id; default : if (c == term) { ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#$"))); pushback(c); newtok(); return list; } switch (c) { case '\"' : case '/' : case '\'' : case '`' : //goto refetch; tokadd(c); break fetch_id; } if (!is_identchar(c)) { yyerror("bad global variable in string"); newtok(); return list; } } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '@' : tokadd(c); c = nextc(); if (c == '@') { tokadd(c); c = nextc(); } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '{' : if (c == '{') { brace = '}'; } nest = 0; do { loop_again : for (;;) { c = nextc(); switch (c) { case -1 : if (nest > 0) { yyerror("bad substitution in string"); newtok(); return list; } return Node.MINUS_ONE; case '}' : if (c == brace) { if (nest == 0) { break; } nest--; } tokadd(c); continue loop_again; case '\\' : c = nextc(); if (c == -1) { return Node.MINUS_ONE; } if (c == term) { tokadd(c); } else { tokadd('\\'); tokadd(c); } break; case '{' : if (brace != -1) { nest++; } case '\"' : case '/' : case '`' : if (c == term) { pushback(c); ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#"))); ph.rb_warning("bad substitution in string"); tokfix(); ph.list_append(list, nf.newStr(RubyString.newString(ruby, tok(), toklen()))); newtok(); return list; } default : tokadd(c); break; } break loop_again; } } while (c != brace); } break; } //fetch_id: tokfix(); node = nf.newEVStr(tok(), toklen()); ph.list_append(list, node); newtok(); return list; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
while (is_identchar(c)) { | while (isIdentifierChar(c)) { | private Node str_extend(Node list, int term) { int c; int brace = -1; RubyObject ss; Node node; int nest; c = nextc(); switch (c) { case '$' : case '@' : case '{' : break; default : tokadd('#'); pushback(c); return list; } ss = RubyString.newString(ruby, tok(), toklen()); if (list == null) { list = nf.newDStr(ss); } else if (toklen() > 0) { ph.list_append(list, nf.newStr(ss)); } newtok(); fetch_id : for (;;) { switch (c) { case '$' : tokadd('$'); c = nextc(); if (c == -1) { return Node.MINUS_ONE; } switch (c) { case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } pushback(c); break fetch_id; case '&' : case '+' : case '_' : case '~' : case '*' : case '$' : case '?' : case '!' : case '@' : case ',' : case '.' : case '=' : case ':' : case '<' : case '>' : case '\\' : //refetch: tokadd(c); break fetch_id; default : if (c == term) { ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#$"))); pushback(c); newtok(); return list; } switch (c) { case '\"' : case '/' : case '\'' : case '`' : //goto refetch; tokadd(c); break fetch_id; } if (!is_identchar(c)) { yyerror("bad global variable in string"); newtok(); return list; } } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '@' : tokadd(c); c = nextc(); if (c == '@') { tokadd(c); c = nextc(); } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '{' : if (c == '{') { brace = '}'; } nest = 0; do { loop_again : for (;;) { c = nextc(); switch (c) { case -1 : if (nest > 0) { yyerror("bad substitution in string"); newtok(); return list; } return Node.MINUS_ONE; case '}' : if (c == brace) { if (nest == 0) { break; } nest--; } tokadd(c); continue loop_again; case '\\' : c = nextc(); if (c == -1) { return Node.MINUS_ONE; } if (c == term) { tokadd(c); } else { tokadd('\\'); tokadd(c); } break; case '{' : if (brace != -1) { nest++; } case '\"' : case '/' : case '`' : if (c == term) { pushback(c); ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#"))); ph.rb_warning("bad substitution in string"); tokfix(); ph.list_append(list, nf.newStr(RubyString.newString(ruby, tok(), toklen()))); newtok(); return list; } default : tokadd(c); break; } break loop_again; } } while (c != brace); } break; } //fetch_id: tokfix(); node = nf.newEVStr(tok(), toklen()); ph.list_append(list, node); newtok(); return list; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
while (is_identchar(c)) { | while (isIdentifierChar(c)) { | private Node str_extend(Node list, int term) { int c; int brace = -1; RubyObject ss; Node node; int nest; c = nextc(); switch (c) { case '$' : case '@' : case '{' : break; default : tokadd('#'); pushback(c); return list; } ss = RubyString.newString(ruby, tok(), toklen()); if (list == null) { list = nf.newDStr(ss); } else if (toklen() > 0) { ph.list_append(list, nf.newStr(ss)); } newtok(); fetch_id : for (;;) { switch (c) { case '$' : tokadd('$'); c = nextc(); if (c == -1) { return Node.MINUS_ONE; } switch (c) { case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } pushback(c); break fetch_id; case '&' : case '+' : case '_' : case '~' : case '*' : case '$' : case '?' : case '!' : case '@' : case ',' : case '.' : case '=' : case ':' : case '<' : case '>' : case '\\' : //refetch: tokadd(c); break fetch_id; default : if (c == term) { ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#$"))); pushback(c); newtok(); return list; } switch (c) { case '\"' : case '/' : case '\'' : case '`' : //goto refetch; tokadd(c); break fetch_id; } if (!is_identchar(c)) { yyerror("bad global variable in string"); newtok(); return list; } } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '@' : tokadd(c); c = nextc(); if (c == '@') { tokadd(c); c = nextc(); } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '{' : if (c == '{') { brace = '}'; } nest = 0; do { loop_again : for (;;) { c = nextc(); switch (c) { case -1 : if (nest > 0) { yyerror("bad substitution in string"); newtok(); return list; } return Node.MINUS_ONE; case '}' : if (c == brace) { if (nest == 0) { break; } nest--; } tokadd(c); continue loop_again; case '\\' : c = nextc(); if (c == -1) { return Node.MINUS_ONE; } if (c == term) { tokadd(c); } else { tokadd('\\'); tokadd(c); } break; case '{' : if (brace != -1) { nest++; } case '\"' : case '/' : case '`' : if (c == term) { pushback(c); ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#"))); ph.rb_warning("bad substitution in string"); tokfix(); ph.list_append(list, nf.newStr(RubyString.newString(ruby, tok(), toklen()))); newtok(); return list; } default : tokadd(c); break; } break loop_again; } } while (c != brace); } break; } //fetch_id: tokfix(); node = nf.newEVStr(tok(), toklen()); ph.list_append(list, node); newtok(); return list; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private Node str_extend(Node list, int term) { int c; int brace = -1; RubyObject ss; Node node; int nest; c = nextc(); switch (c) { case '$' : case '@' : case '{' : break; default : tokadd('#'); pushback(c); return list; } ss = RubyString.newString(ruby, tok(), toklen()); if (list == null) { list = nf.newDStr(ss); } else if (toklen() > 0) { ph.list_append(list, nf.newStr(ss)); } newtok(); fetch_id : for (;;) { switch (c) { case '$' : tokadd('$'); c = nextc(); if (c == -1) { return Node.MINUS_ONE; } switch (c) { case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } pushback(c); break fetch_id; case '&' : case '+' : case '_' : case '~' : case '*' : case '$' : case '?' : case '!' : case '@' : case ',' : case '.' : case '=' : case ':' : case '<' : case '>' : case '\\' : //refetch: tokadd(c); break fetch_id; default : if (c == term) { ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#$"))); pushback(c); newtok(); return list; } switch (c) { case '\"' : case '/' : case '\'' : case '`' : //goto refetch; tokadd(c); break fetch_id; } if (!is_identchar(c)) { yyerror("bad global variable in string"); newtok(); return list; } } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '@' : tokadd(c); c = nextc(); if (c == '@') { tokadd(c); c = nextc(); } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '{' : if (c == '{') { brace = '}'; } nest = 0; do { loop_again : for (;;) { c = nextc(); switch (c) { case -1 : if (nest > 0) { yyerror("bad substitution in string"); newtok(); return list; } return Node.MINUS_ONE; case '}' : if (c == brace) { if (nest == 0) { break; } nest--; } tokadd(c); continue loop_again; case '\\' : c = nextc(); if (c == -1) { return Node.MINUS_ONE; } if (c == term) { tokadd(c); } else { tokadd('\\'); tokadd(c); } break; case '{' : if (brace != -1) { nest++; } case '\"' : case '/' : case '`' : if (c == term) { pushback(c); ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#"))); ph.rb_warning("bad substitution in string"); tokfix(); ph.list_append(list, nf.newStr(RubyString.newString(ruby, tok(), toklen()))); newtok(); return list; } default : tokadd(c); break; } break loop_again; } } while (c != brace); } break; } //fetch_id: tokfix(); node = nf.newEVStr(tok(), toklen()); ph.list_append(list, node); newtok(); return list; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
tokfix(); | private Node str_extend(Node list, int term) { int c; int brace = -1; RubyObject ss; Node node; int nest; c = nextc(); switch (c) { case '$' : case '@' : case '{' : break; default : tokadd('#'); pushback(c); return list; } ss = RubyString.newString(ruby, tok(), toklen()); if (list == null) { list = nf.newDStr(ss); } else if (toklen() > 0) { ph.list_append(list, nf.newStr(ss)); } newtok(); fetch_id : for (;;) { switch (c) { case '$' : tokadd('$'); c = nextc(); if (c == -1) { return Node.MINUS_ONE; } switch (c) { case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } pushback(c); break fetch_id; case '&' : case '+' : case '_' : case '~' : case '*' : case '$' : case '?' : case '!' : case '@' : case ',' : case '.' : case '=' : case ':' : case '<' : case '>' : case '\\' : //refetch: tokadd(c); break fetch_id; default : if (c == term) { ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#$"))); pushback(c); newtok(); return list; } switch (c) { case '\"' : case '/' : case '\'' : case '`' : //goto refetch; tokadd(c); break fetch_id; } if (!is_identchar(c)) { yyerror("bad global variable in string"); newtok(); return list; } } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '@' : tokadd(c); c = nextc(); if (c == '@') { tokadd(c); c = nextc(); } while (is_identchar(c)) { tokadd(c); c = nextc(); } pushback(c); break; case '{' : if (c == '{') { brace = '}'; } nest = 0; do { loop_again : for (;;) { c = nextc(); switch (c) { case -1 : if (nest > 0) { yyerror("bad substitution in string"); newtok(); return list; } return Node.MINUS_ONE; case '}' : if (c == brace) { if (nest == 0) { break; } nest--; } tokadd(c); continue loop_again; case '\\' : c = nextc(); if (c == -1) { return Node.MINUS_ONE; } if (c == term) { tokadd(c); } else { tokadd('\\'); tokadd(c); } break; case '{' : if (brace != -1) { nest++; } case '\"' : case '/' : case '`' : if (c == term) { pushback(c); ph.list_append(list, nf.newStr(RubyString.newString(ruby, "#"))); ph.rb_warning("bad substitution in string"); tokfix(); ph.list_append(list, nf.newStr(RubyString.newString(ruby, tok(), toklen()))); newtok(); return list; } default : tokadd(c); break; } break loop_again; } } while (c != brace); } break; } //fetch_id: tokfix(); node = nf.newEVStr(tok(), toklen()); ph.list_append(list, node); newtok(); return list; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
int[] numlen = new int[1]; scan_hex(lex_curline, lex_p, 2, numlen); while (numlen[0]-- != 0) { tokadd(nextc()); | String hex = support.readHex(2); for (int i = 0; i < hex.length(); i++) { tokadd(hex.charAt(i)); | private int tokadd_escape(int term) { /* * FIX 1.6.5 */ int c; switch (c = nextc()) { case '\n' : return 0; /* * just ignore */ case '0' : case '1' : case '2' : case '3' : /* * octal constant */ case '4' : case '5' : case '6' : case '7' : { int i; tokadd('\\'); tokadd(c); for (i = 0; i < 2; i++) { c = nextc(); if (c == -1) { // goto eof; yyerror("Invalid escape character syntax"); return -1; // goto eof; end } if (c < '0' || '7' < c) { pushback(c); break; } tokadd(c); } } return 0; case 'x' : // hex constant { tokadd('\\'); tokadd(c); int[] numlen = new int[1]; scan_hex(lex_curline, lex_p, 2, numlen); while (numlen[0]-- != 0) { tokadd(nextc()); } } return 0; case 'M' : if ((c = nextc()) != '-') { yyerror("Invalid escape character syntax"); pushback(c); return 0; } tokadd('\\'); tokadd('M'); tokadd('-'); //goto escaped; if ((c = nextc()) == '\\') { return tokadd_escape(term); /* * FIX 1.6.5 */ } else if (c == -1) { // goto eof; yyerror("Invalid escape character syntax"); return -1; // goto eof; end } tokadd(c); return 0; case 'C' : if ((c = nextc()) != '-') { yyerror("Invalid escape character syntax"); pushback(c); return 0; } tokadd('\\'); tokadd('C'); tokadd('-'); //goto escaped; if ((c = nextc()) == '\\') { return tokadd_escape(term); /* * FIX 1.6.5 */ } else if (c == -1) { // goto eof; yyerror("Invalid escape character syntax"); return -1; // goto eof; end } tokadd(c); return 0; case 'c' : tokadd('\\'); tokadd('c'); //escaped: if ((c = nextc()) == '\\') { return tokadd_escape(term); /* * FIX 1.6.5 */ } else if (c == -1) { // goto eof; yyerror("Invalid escape character syntax"); return -1; // goto eof; end } tokadd(c); return 0; case -1 : // eof: yyerror("Invalid escape character syntax"); return -1; default : if (c != term) { /* * FIX 1.6.5 */ tokadd('\\'); } /* * FIX 1.6.5 */ tokadd(c); } return 0; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
private void yyerror(String msg) { System.err.println(msg); | private final void yyerror(String msg) { ph.rb_errmess(msg); | private void yyerror(String msg) { System.err.println(msg); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
kwtable kw; | Keyword kw; | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { | if (isArgState() && space_seen != 0 && !isSpace(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (lex_p == 1) { | if (source.getColumn() == 1) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { | if (support.isNext("begin") && Character.isWhitespace(support.getCharAt(5))) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
lex_p = lex_pend; | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
} if (c != '=') { | } else if (c != '=') { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
} if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { | } else if (source.getColumn() == 1 && support.isNext("end") && Character.isWhitespace(support.getCharAt(3))) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
lex_p = lex_pend; | support.readLine(); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
&& (!IS_ARG() || space_seen != 0)) { | && (!isArgState() || space_seen != 0)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
int indent = 0; | boolean indent = false; | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
indent = 1; | indent = true; | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); | if (!isSpace(c2) && ("\"'`".indexOf(c2) != -1 || isIdentifierChar(c2))) { return parseHereDocument(c2, indent); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (IS_ARG() && ISSPACE(c)) { | if (isArgState() && isSpace(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { | if (isArgState() && space_seen != 0 && !isSpace(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { | if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (isArgState() && space_seen != 0 && !isSpace(c))) { if (isArgState()) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { | if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (isArgState() && space_seen != 0 && !isSpace(c))) { if (isArgState()) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { | if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (isArgState() && space_seen != 0)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { | if (ph.getLexState() == LexState.EXPR_END || isSpace(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { | if (isArgState() && space_seen != 0) { if (!isSpace(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
} else if (IS_ARG() && space_seen != 0) { | } else if (isArgState() && space_seen != 0) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
quotation : for (;;) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } | return parseQuotation(nextc()); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } | if (isArgState() && space_seen != 0 && !isSpace(c)) { return parseQuotation(c); } | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (is_identchar(c)) { | if (isIdentifierChar(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); yyVal = tok(); | yyVal = tok(); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); yyVal = tok(); | yyVal = tok(); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (is_identchar(c)) { | if (isIdentifierChar(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
if (!is_identchar(c)) { | if (!isIdentifierChar(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (!is_identchar(c)) { | if (!isIdentifierChar(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (!is_identchar(c) || Character.isDigit((char) c)) { | if (!isIdentifierChar(c) || Character.isDigit((char) c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
while (is_identchar(c)) { | while (isIdentifierChar(c)) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { | if ((c == '!' || c == '?') && isIdentifierChar(tok().charAt(0)) && !peek('=')) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
|
kw = rb_reserved_word(tok(), toklen()); | kw = getKeyword(tok(), toklen()); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { | if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || support.getCharAt(1) == '>')) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { | if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
tokfix(); yyVal = tok(); | yyVal = tok(); | private int yylex() { int c; int space_seen = 0; kwtable kw; retry : for (;;) { switch (c = nextc()) { case '\0' : // NUL case '\004' : // ^D case '\032' : // ^Z case -1 : //end of script. return 0; // white spaces case ' ' : case '\t' : case '\f' : case '\r' : case '\013' : // '\v' space_seen++; continue retry; case '#' : // it's a comment while ((c = nextc()) != '\n') { if (c == -1) { return 0; } } // fall through case '\n' : switch (ph.getLexState()) { case LexState.EXPR_BEG : case LexState.EXPR_FNAME : case LexState.EXPR_DOT : continue retry; default : break; } ph.setLexState(LexState.EXPR_BEG); return '\n'; case '*' : if ((c = nextc()) == '*') { ph.setLexState(LexState.EXPR_BEG); if (nextc() == '=') { yyVal = "**"; // ph.newId(Token.tPOW); return Token.tOP_ASGN; } pushback(c); return Token.tPOW; } if (c == '=') { yyVal = "*"; // ph.newId('*'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("'*' interpreted as argument prefix"); c = Token.tSTAR; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tSTAR; } else { c = '*'; } ph.setLexState(LexState.EXPR_BEG); return c; case '!' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tNEQ; } if (c == '~') { return Token.tNMATCH; } pushback(c); return '!'; case '=' : if (lex_p == 1) { // skip embedded rd document if (lex_curline.startsWith("=begin") && (lex_pend == 6 || ISSPACE(lex_curline.charAt(6)))) { for (;;) { lex_p = lex_pend; c = nextc(); if (c == -1) { ph.rb_compile_error("embedded document meets end of file"); return 0; } if (c != '=') { continue; } if (lex_curline.substring(lex_p, lex_p + 3).equals("end") && (lex_p + 3 == lex_pend || ISSPACE(lex_curline.charAt(lex_p + 3)))) { break; } } lex_p = lex_pend; continue retry; } } ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { if ((c = nextc()) == '=') { return Token.tEQQ; } pushback(c); return Token.tEQ; } if (c == '~') { return Token.tMATCH; } else if (c == '>') { return Token.tASSOC; } pushback(c); return '='; case '<' : c = nextc(); if (c == '<' && ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG && ph.getLexState() != LexState.EXPR_CLASS && (!IS_ARG() || space_seen != 0)) { int c2 = nextc(); int indent = 0; if (c2 == '-') { indent = 1; c2 = nextc(); } if (!ISSPACE(c2) && ("\"'`".indexOf(c2) != -1 || is_identchar(c2))) { return here_document(c2, indent); } pushback(c2); } ph.setLexState(LexState.EXPR_BEG); if (c == '=') { if ((c = nextc()) == '>') { return Token.tCMP; } pushback(c); return Token.tLEQ; } if (c == '<') { if (nextc() == '=') { yyVal = "<<"; // ph.newId(Token.tLSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tLSHFT; } pushback(c); return '<'; case '>' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { return Token.tGEQ; } if (c == '>') { if ((c = nextc()) == '=') { yyVal = ">>"; //ph.newId(Token.tRSHFT); return Token.tOP_ASGN; } pushback(c); return Token.tRSHFT; } pushback(c); return '>'; case '"' : return parse_string(c, c, c); case '`' : if (ph.getLexState() == LexState.EXPR_FNAME) { return c; } if (ph.getLexState() == LexState.EXPR_DOT) { return c; } return parse_string(c, c, c); case '\'' : return parse_qstring(c, 0); case '?' : if (ph.getLexState() == LexState.EXPR_END) { ph.setLexState(LexState.EXPR_BEG); return '?'; } c = nextc(); if (c == -1) { /* FIX 1.6.5 */ ph.rb_compile_error("incomplete character syntax"); return 0; } if (IS_ARG() && ISSPACE(c)) { pushback(c); ph.setLexState(LexState.EXPR_BEG); return '?'; } if (c == '\\') { c = read_escape(); } c &= 0xff; yyVal = RubyFixnum.newFixnum(ruby, c); ph.setLexState(LexState.EXPR_END); return Token.tINTEGER; case '&' : if ((c = nextc()) == '&') { ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "&&"; // ph.newId(Token.tANDOP); return Token.tOP_ASGN; } pushback(c); return Token.tANDOP; } else if (c == '=') { yyVal = "&"; //ph.newId('&'); ph.setLexState(LexState.EXPR_BEG); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { ph.rb_warning("`&' interpeted as argument prefix"); c = Token.tAMPER; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tAMPER; } else { c = '&'; } ph.setLexState(LexState.EXPR_BEG); return c; case '|' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '|') { if ((c = nextc()) == '=') { yyVal = "||"; // ph.newId(Token.tOROP); return Token.tOP_ASGN; } pushback(c); return Token.tOROP; } else if (c == '=') { yyVal = "|"; //ph.newId('|'); return Token.tOP_ASGN; } pushback(c); return '|'; case '+' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUPLUS; } pushback(c); return '+'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "+"; //ph.newId('+'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '+'; return start_num(c); } return Token.tUPLUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '+'; case '-' : c = nextc(); if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if (c == '@') { return Token.tUMINUS; } pushback(c); return '-'; } if (c == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "-"; // ph.newId('-'); return Token.tOP_ASGN; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0 && !ISSPACE(c))) { if (IS_ARG()) { arg_ambiguous(); } ph.setLexState(LexState.EXPR_BEG); pushback(c); if (Character.isDigit((char) c)) { c = '-'; return start_num(c); } return Token.tUMINUS; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '-'; case '.' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '.') { if ((c = nextc()) == '.') { return Token.tDOT3; } pushback(c); return Token.tDOT2; } pushback(c); if (!Character.isDigit((char) c)) { ph.setLexState(LexState.EXPR_DOT); return '.'; } c = '.'; // fall through //start_num: case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : return start_num(c); case ']' : case '}' : ph.setLexState(LexState.EXPR_END); return c; case ')' : if (cond_nest > 0) { cond_stack >>= 1; } ph.setLexState(LexState.EXPR_END); return c; case ':' : c = nextc(); if (c == ':') { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID || (IS_ARG() && space_seen != 0)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) { ph.setLexState(LexState.EXPR_BEG); return ':'; } ph.setLexState(LexState.EXPR_FNAME); return Token.tSYMBEG; case '/' : if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { return parse_regx('/', '/'); } if ((c = nextc()) == '=') { ph.setLexState(LexState.EXPR_BEG); yyVal = "/"; // ph.newId('/'); return Token.tOP_ASGN; } pushback(c); if (IS_ARG() && space_seen != 0) { if (!ISSPACE(c)) { arg_ambiguous(); return parse_regx('/', '/'); } } ph.setLexState(LexState.EXPR_BEG); return '/'; case '^' : ph.setLexState(LexState.EXPR_BEG); if ((c = nextc()) == '=') { yyVal = "^"; //ph.newId('^'); return Token.tOP_ASGN; } pushback(c); return '^'; case ',' : case ';' : ph.setLexState(LexState.EXPR_BEG); return c; case '~' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) != '@') { pushback(c); } } ph.setLexState(LexState.EXPR_BEG); return '~'; case '(' : if (cond_nest > 0) { cond_stack = (cond_stack << 1) | 0; } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call"); } ph.setLexState(LexState.EXPR_BEG); return c; case '[' : if (ph.getLexState() == LexState.EXPR_FNAME || ph.getLexState() == LexState.EXPR_DOT) { if ((c = nextc()) == ']') { if ((c = nextc()) == '=') { return Token.tASET; } pushback(c); return Token.tAREF; } pushback(c); return '['; } else if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLBRACK; } else if (IS_ARG() && space_seen != 0) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{' : if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE; } ph.setLexState(LexState.EXPR_BEG); return c; case '\\' : c = nextc(); if (c == '\n') { space_seen = 1; continue retry; // skip \\n } pushback(c); return '\\'; case '%' : quotation : for (;;) { if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { int term; int paren; c = nextc(); if (!Character.isLetterOrDigit((char) c)) { term = c; c = 'Q'; } else { term = nextc(); } if (c == -1 || term == -1) { ph.rb_compile_error("unterminated quoted string meets end of file"); return 0; } paren = term; if (term == '(') { term = ')'; } else if (term == '[') { term = ']'; } else if (term == '{') { term = '}'; } else if (term == '<') { term = '>'; } else { paren = 0; } switch (c) { case 'Q' : return parse_string('"', term, paren); case 'q' : return parse_qstring(term, paren); case 'w' : return parse_quotedwords(term, paren); case 'x' : return parse_string('`', term, paren); case 'r' : return parse_regx(term, paren); default : yyerror("unknown type of %string"); return 0; } } if ((c = nextc()) == '=') { yyVal = "%"; //ph.newId('%'); return Token.tOP_ASGN; } if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) { pushback(c); continue quotation; } break quotation; } ph.setLexState(LexState.EXPR_BEG); pushback(c); return '%'; case '$' : ph.setLexState(LexState.EXPR_END); newtok(); c = nextc(); switch (c) { case '_' : // $_: last read line string c = nextc(); if (is_identchar(c)) { tokadd('$'); tokadd('_'); break; } pushback(c); c = '_'; // fall through case '~' : // $~: match-data ph.getLocalIndex(String.valueOf(c)); // fall through case '*' : // $*: argv case '$' : // $$: pid case '?' : // $?: last status case '!' : // $!: error string case '@' : // $@: error position case '/' : // $/: input record separator case '\\' : // $\: output record separator case ';' : // $;: field separator case ',' : // $,: output field separator case '.' : // $.: last read line number case '=' : // $=: ignorecase case ':' : // $:: load path case '<' : // $<: reading filename case '>' : // $>: default output handle case '\"' : // $": already loaded files tokadd('$'); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); return Token.tGVAR; case '-' : tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = tok(); // ruby.intern(tok()); /* xxx shouldn't check if valid option variable */ return Token.tGVAR; case '&' : // $&: last match case '`' : // $`: string before last match case '\'' : // $': string after last match case '+' : // $+: string matches last paren. yyVal = nf.newBackRef(c); return Token.tBACK_REF; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : tokadd('$'); while (Character.isDigit((char) c)) { tokadd(c); c = nextc(); } if (is_identchar(c)) { break; } pushback(c); tokfix(); yyVal = nf.newNthRef(Integer.parseInt(tok().substring(1))); return Token.tNTH_REF; default : if (!is_identchar(c)) { pushback(c); return '$'; } case '0' : tokadd('$'); } break; case '@' : c = nextc(); newtok(); tokadd('@'); if (c == '@') { tokadd('@'); c = nextc(); } if (Character.isDigit((char) c)) { ph.rb_compile_error("`@" + c + "' is not a valid instance variable name"); } if (!is_identchar(c)) { pushback(c); return '@'; } break; default : if (!is_identchar(c) || Character.isDigit((char) c)) { ph.rb_compile_error("Invalid char `\\" + c + "' in expression"); continue retry; } newtok(); break; } break retry; } while (is_identchar(c)) { tokadd(c); c = nextc(); } if ((c == '!' || c == '?') && is_identchar(tok().charAt(0)) && !peek('=')) { tokadd(c); } else { pushback(c); } tokfix(); { int result = 0; switch (tok().charAt(0)) { case '$' : ph.setLexState(LexState.EXPR_END); result = Token.tGVAR; break; case '@' : ph.setLexState(LexState.EXPR_END); if (tok().charAt(1) == '@') { result = Token.tCVAR; } else { result = Token.tIVAR; } break; default : if (ph.getLexState() != LexState.EXPR_DOT) { // See if it is a reserved word. kw = rb_reserved_word(tok(), toklen()); if (kw != null) { // enum lex_state int state = ph.getLexState(); ph.setLexState(kw.state); if (state == LexState.EXPR_FNAME) { yyVal = kw.name; // ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P()) { return Token.kDO_BLOCK; } return Token.kDO; } if (state == LexState.EXPR_BEG) { return kw.id0; } else { if (kw.id0 != kw.id1) { ph.setLexState(LexState.EXPR_BEG); } return kw.id1; } } } if (toklast() == '!' || toklast() == '?') { result = Token.tFID; } else { if (ph.getLexState() == LexState.EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && (!peek('=') || lex_p + 1 < lex_pend && lex_curline.charAt(lex_p + 1) == '>')) { result = Token.tIDENTIFIER; tokadd(c); } else { pushback(c); } } if (result == 0 && Character.isUpperCase(tok().charAt(0))) { result = Token.tCONSTANT; } else { result = Token.tIDENTIFIER; } } if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_DOT || ph.getLexState() == LexState.EXPR_ARG) { ph.setLexState(LexState.EXPR_ARG); } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = tok(); // ruby.intern(tok()); return result; } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d31a76ee29d5978a9bec41e3ac9134cee024bcab/DefaultRubyScanner.java/buggy/org/jruby/parser/DefaultRubyScanner.java |
setToolTipText(((SemanticTypeTree.TreeNode)value).getFQName()); | public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree,value,sel,expanded, leaf,row,hasFocus); int nodeType = getNodeType(value); if(nodeType == STRING_NODE) { setIcon(stringIcon); } else if(nodeType == NUMERIC_NODE) { setIcon(numericIcon); } else if(nodeType == ATTRIBUTE_NODE) { setIcon(typeIcon); } else if(nodeType == BOOLEAN_NODE) { setIcon(booleanIcon); } return this; } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/4eb7129fd009b6f34f1eda2cdfe74bc4a184ee93/HeatMapTreeRenderer.java/clean/SRC/org/openmicroscopy/shoola/agents/browser/heatmap/HeatMapTreeRenderer.java |
|
return (IRubyObject) getMethod().invoke( isStaticMethod ? null : recv, reflectionArguments); | return (IRubyObject) getMethod().invoke(isStaticMethod ? null : recv, reflectionArguments); | protected IRubyObject invokeMethod(IRubyObject recv, Object[] methodArgs) { Object[] reflectionArguments = packageArgumentsForReflection(methodArgs, recv); try { return (IRubyObject) getMethod().invoke( isStaticMethod ? null : recv, reflectionArguments); } catch (InvocationTargetException itExcptn) { if (itExcptn.getTargetException() instanceof RaiseException) { throw (RaiseException) itExcptn.getTargetException(); } else if (itExcptn.getTargetException() instanceof JumpException) { throw (JumpException) itExcptn.getTargetException(); } else { recv.getRuntime().getJavaSupport().handleNativeException( (Exception) itExcptn.getTargetException()); return recv.getRuntime().getNil(); } } catch (IllegalAccessException iaExcptn) { StringBuffer message = new StringBuffer(); message.append(iaExcptn.getMessage()); message.append(':'); message.append(" methodName=").append(methodName); message.append(" recv=").append(recv.toString()); message.append(" klass=").append(klass.getName()); message.append(" methodArgs=["); for (int i = 0; i < methodArgs.length; i++) { message.append(methodArgs[i]); message.append(' '); } message.append(']'); Asserts.assertNotReached(message.toString()); } catch (final IllegalArgumentException iaExcptn) { throw new RaiseException(recv.getRuntime(), "TypeError", iaExcptn.getMessage()); } throw new AssertError("[BUG] Run again with Asserts.ENABLE_ASSERT=true"); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/3acff782b00a5f6892fe6bd44e0665cc6194f9aa/ReflectionCallbackMethod.java/clean/org/jruby/runtime/ReflectionCallbackMethod.java |
recv.getRuntime().getJavaSupport().handleNativeException( (Exception) itExcptn.getTargetException()); | recv.getRuntime().getJavaSupport().handleNativeException((Exception) itExcptn.getTargetException()); | protected IRubyObject invokeMethod(IRubyObject recv, Object[] methodArgs) { Object[] reflectionArguments = packageArgumentsForReflection(methodArgs, recv); try { return (IRubyObject) getMethod().invoke( isStaticMethod ? null : recv, reflectionArguments); } catch (InvocationTargetException itExcptn) { if (itExcptn.getTargetException() instanceof RaiseException) { throw (RaiseException) itExcptn.getTargetException(); } else if (itExcptn.getTargetException() instanceof JumpException) { throw (JumpException) itExcptn.getTargetException(); } else { recv.getRuntime().getJavaSupport().handleNativeException( (Exception) itExcptn.getTargetException()); return recv.getRuntime().getNil(); } } catch (IllegalAccessException iaExcptn) { StringBuffer message = new StringBuffer(); message.append(iaExcptn.getMessage()); message.append(':'); message.append(" methodName=").append(methodName); message.append(" recv=").append(recv.toString()); message.append(" klass=").append(klass.getName()); message.append(" methodArgs=["); for (int i = 0; i < methodArgs.length; i++) { message.append(methodArgs[i]); message.append(' '); } message.append(']'); Asserts.assertNotReached(message.toString()); } catch (final IllegalArgumentException iaExcptn) { throw new RaiseException(recv.getRuntime(), "TypeError", iaExcptn.getMessage()); } throw new AssertError("[BUG] Run again with Asserts.ENABLE_ASSERT=true"); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/3acff782b00a5f6892fe6bd44e0665cc6194f9aa/ReflectionCallbackMethod.java/clean/org/jruby/runtime/ReflectionCallbackMethod.java |
System.arraycopy( originalArgs, args.length - 1, restArray, 0, originalArgs.length - (args.length - 1)); | System.arraycopy(originalArgs, args.length - 1, restArray, 0, originalArgs.length - (args.length - 1)); | private final Object[] packageRestArgumentsForReflection(final Object[] originalArgs) { IRubyObject[] restArray = new IRubyObject[originalArgs.length - (args.length - 1)]; Object[] result = new Object[args.length]; try { System.arraycopy( originalArgs, args.length - 1, restArray, 0, originalArgs.length - (args.length - 1)); } catch (ArrayIndexOutOfBoundsException aioobExcptn) { throw new RuntimeException( "Cannot call \"" + methodName + "\" in class \"" + klass.getName() + "\". " + getExpectedArgsString((IRubyObject[]) originalArgs)); } System.arraycopy(originalArgs, 0, result, 0, args.length - 1); result[args.length - 1] = restArray; return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/3acff782b00a5f6892fe6bd44e0665cc6194f9aa/ReflectionCallbackMethod.java/clean/org/jruby/runtime/ReflectionCallbackMethod.java |
private Object[] packageStaticArgumentsForReflection( Object[] arguments, Ruby ruby, IRubyObject rubyClass) { Object[] result = new Object[arguments.length + 2]; result[0] = ruby; result[1] = rubyClass; System.arraycopy(arguments, 0, result, 2, arguments.length); | private Object[] packageStaticArgumentsForReflection(Object[] arguments, Ruby ruby, IRubyObject rubyClass) { Object[] result = new Object[arguments.length + 1]; result[0] = rubyClass; System.arraycopy(arguments, 0, result, 1, arguments.length); | private Object[] packageStaticArgumentsForReflection( Object[] arguments, Ruby ruby, IRubyObject rubyClass) { Object[] result = new Object[arguments.length + 2]; result[0] = ruby; result[1] = rubyClass; System.arraycopy(arguments, 0, result, 2, arguments.length); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/3acff782b00a5f6892fe6bd44e0665cc6194f9aa/ReflectionCallbackMethod.java/clean/org/jruby/runtime/ReflectionCallbackMethod.java |
continue; | break; | public void run() { int period = now(); while( !isInterrupted()) { try { sleep(_duration); } catch (InterruptedException e) { continue; } int newPeriod = now(); while (period != newPeriod) { if (++period >= _periods) period = 0; synchronized(_locks[period]) { Runnable tasks[] = _tasks[period]; boolean repeats[] = _repeats[period]; for (int i = 0; i < tasks.length; i++) { if (tasks[i] != null) { try { tasks[i].run(); } catch (Exception e) { _syslog.warning(this + ": task " + tasks[i] + " threw an exception", e); } finally { if (!repeats[i]) { tasks[i] = null; } } } } } } } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/65c210c2e5230f99b78b769799e9e54e3fcce30a/TimeLoop.java/clean/webmacro/src/org/webmacro/util/TimeLoop.java |
return (modes & RDWR) != 0 || (modes & WRONLY) != 0 || (modes & CREAT) != 0; | return isWritable(); | public boolean isWriteable() { return (modes & RDWR) != 0 || (modes & WRONLY) != 0 || (modes & CREAT) != 0; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/54e6b8da799629e0b7db879c45149399878f5f84/IOModes.java/buggy/src/org/jruby/util/IOModes.java |
public RGBPane() { manager = new RGBPaneManager(this); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/8a4d5e12d87798c81c0e8de88f3ca3fd97e8a6cc/RGBPane.java/buggy/SRC/org/openmicroscopy/shoola/agents/rnd/model/RGBPane.java |
||
private void buildBody() { contents = new JPanel(); contents.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); GridBagLayout gridbag = new GridBagLayout(); contents.setLayout(gridbag); GridBagConstraints cst = new GridBagConstraints(); cst.ipadx = RenderingAgtUIF.H_SPACE; cst.weightx = 0.5; cst.fill = GridBagConstraints.HORIZONTAL; cst.anchor = GridBagConstraints.EAST; ChannelData[] channelData = eventManager.getChannelData(); Color color; int[] rgba; boolean active; for (int i = 0; i < channelData.length; i++) { rgba = eventManager.getRGBA(i); active = eventManager.isActive(i); color = new Color(rgba[0], rgba[1], rgba[2], rgba[3]); addRow(gridbag, cst, i, channelData[i], color, active); } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/8a4d5e12d87798c81c0e8de88f3ca3fd97e8a6cc/RGBPane.java/buggy/SRC/org/openmicroscopy/shoola/agents/rnd/model/RGBPane.java |
||
removeAll(); | private void buildGUI() { buildBody(); setLayout(new FlowLayout(FlowLayout.LEFT)); setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); add(contents); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/8a4d5e12d87798c81c0e8de88f3ca3fd97e8a6cc/RGBPane.java/buggy/SRC/org/openmicroscopy/shoola/agents/rnd/model/RGBPane.java |
|
DOEditor editor = EditorFactory.getEditor(); | EditorUI editor = EditorFactory.getEditor(); | public void setAnnotations(Map map) { if (model.getState() != LOADING_ANNOTATION) throw new IllegalStateException("This method can only be invoked" + " in the LOADING_ANNOTATION state."); if (map == null) throw new IllegalArgumentException("No annotations."); DOEditor editor = EditorFactory.getEditor(); if (editor == null) return; editor.setAnnotations(map); view.getLoadingWindow().setVisible(false); if (editor.hasThumbnail()) model.fireThumbnailLoading(); else model.setState(READY); fireStateChange(); view.addComponent(editor); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/87529caa0141a437103c7c854aeb743ee032cbac/TreeViewerComponent.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
DOEditor editor = EditorFactory.getEditor(); | EditorUI editor = EditorFactory.getEditor(); | public void setDataObjectThumbnail(BufferedImage thumbnail) { if (model.getState() != LOADING_THUMBNAIL) throw new IllegalStateException("This method can only be invoked" + " in the LOADING_THUMBNAIL state."); if (thumbnail == null) throw new IllegalArgumentException("No thumbnail."); if (model.getEditorType() == CLASSIFIER_EDITOR) { Classifier classifier = ClassifierFactory.getClassifier(); if (classifier == null) return; classifier.setThumbnail(thumbnail); } else { DOEditor editor = EditorFactory.getEditor(); if (editor == null) return; editor.setThumbnail(thumbnail); } model.setState(READY); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/87529caa0141a437103c7c854aeb743ee032cbac/TreeViewerComponent.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
DOEditor editor = EditorFactory.getEditor(); | EditorUI editor = EditorFactory.getEditor(); | public void setRetrievedClassification(Set paths) { if (model.getState() != LOADING_CLASSIFICATION) throw new IllegalStateException("This method should only be " + "invoked in the LOADING_CLASSIFICATION state."); if (paths == null) throw new IllegalArgumentException("No paths to set."); DOEditor editor = EditorFactory.getEditor(); if (editor == null) return; Set set = TreeViewerTranslator.transformHierarchy(paths); editor.setClassifiedNodes(set); model.setState(READY); view.getLoadingWindow().setVisible(false); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/87529caa0141a437103c7c854aeb743ee032cbac/TreeViewerComponent.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
DOEditor panel = EditorFactory.getEditor(this, object, editorType); panel.addPropertyChangeListener(DOEditor.CANCEL_EDITION_PROPERTY, | EditorUI panel = EditorFactory.getEditor(this, object, editorType); panel.addPropertyChangeListener(EditorUI.CANCEL_EDITION_PROPERTY, | public void showProperties(DataObject object, int editorType) { if (editorType == PROPERTIES_EDITOR || editorType == CREATE_EDITOR) model.setEditorType(editorType); else return; model.setDataObject(object); DOEditor panel = EditorFactory.getEditor(this, object, editorType); panel.addPropertyChangeListener(DOEditor.CANCEL_EDITION_PROPERTY, controller); if ((object instanceof ImageData) || (object instanceof DatasetData)) { model.fireAnnotationLoading(object); fireStateChange(); UIUtilities.centerAndShow(view.getLoadingWindow()); } else view.addComponent(panel); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/87529caa0141a437103c7c854aeb743ee032cbac/TreeViewerComponent.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
if(getInstanceVariables().size() > 0) { StringBuffer part = new StringBuffer(); String cname = getMetaClass().getRealClass().getName(); part.append("#<").append(cname).append(":0x"); part.append(Integer.toHexString(System.identityHashCode(this))); part.append(" "); if(!getRuntime().registerInspecting(this)) { /* 6:tags 16:addr 1:eos */ part.append("...>"); return getRuntime().newString(part.toString()); } try { String sep = ""; for (Iterator iter = instanceVariableNames(); iter.hasNext();) { String name = (String) iter.next(); part.append(sep); part.append(name); part.append("="); part.append(getInstanceVariable(name).callMethod("inspect")); sep = ", "; } part.append(">"); return getRuntime().newString(part.toString()); } finally { getRuntime().unregisterInspecting(this); } } | public IRubyObject inspect() { // TODO Review this and either remove the comment, or do it // if (TYPE(obj) == T_OBJECT // && ROBJECT(obj)->iv_tbl // && ROBJECT(obj)->iv_tbl->num_entries > 0) { // VALUE str; // char *c; // // c = rb_class2name(CLASS_OF(obj)); // /*if (rb_inspecting_p(obj)) { // str = rb_str_new(0, strlen(c)+10+16+1); /* 10:tags 16:addr 1:eos */ // sprintf(RSTRING(str)->ptr, "#<%s:0x%lx ...>", c, obj); // RSTRING(str)->len = strlen(RSTRING(str)->ptr); // return str; // }*/ // str = rb_str_new(0, strlen(c)+6+16+1); /* 6:tags 16:addr 1:eos */ // sprintf(RSTRING(str)->ptr, "-<%s:0x%lx ", c, obj); // RSTRING(str)->len = strlen(RSTRING(str)->ptr); // return rb_protect_inspect(inspect_obj, obj, str); // } // return rb_funcall(obj, rb_intern("to_s"), 0, 0); // } return callMethod("to_s"); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/adc018ace5f125349d8d0975b3035f19b603568c/RubyObject.java/buggy/src/org/jruby/RubyObject.java |
|
File sourceDirectory) throws IOException | FileFinder finder) throws IOException | public XMLReport(ProjectData projectData, File destinationDir, File sourceDirectory) throws IOException { this.sourceDirectory = sourceDirectory; pw = new PrintWriter(new FileWriter(new File(destinationDir, "coverage.xml"))); try { println("<?xml version=\"1.0\"?>"); println("<!DOCTYPE coverage SYSTEM \"http://cobertura.sourceforge.net/xml/" + coverageDTD + "\">"); println(""); // TODO: Set a schema? //println("<coverage " + sourceDirectories.toString() + " xmlns=\"http://cobertura.sourceforge.net\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://cobertura.sourceforge.net/xml/coverage.xsd\">"); println("<coverage line-rate=\"" + projectData.getLineCoverageRate() + "\" branch-rate=\"" + projectData.getBranchCoverageRate() + "\" version=\"" + Header.version() + "\" timestamp=\"" + new Date().getTime() + "\">"); increaseIndentation(); dumpSources(sourceDirectory); dumpPackages(projectData); decreaseIndentation(); println("</coverage>"); } finally { pw.close(); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
this.sourceDirectory = sourceDirectory; | this.finder = finder; | public XMLReport(ProjectData projectData, File destinationDir, File sourceDirectory) throws IOException { this.sourceDirectory = sourceDirectory; pw = new PrintWriter(new FileWriter(new File(destinationDir, "coverage.xml"))); try { println("<?xml version=\"1.0\"?>"); println("<!DOCTYPE coverage SYSTEM \"http://cobertura.sourceforge.net/xml/" + coverageDTD + "\">"); println(""); // TODO: Set a schema? //println("<coverage " + sourceDirectories.toString() + " xmlns=\"http://cobertura.sourceforge.net\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://cobertura.sourceforge.net/xml/coverage.xsd\">"); println("<coverage line-rate=\"" + projectData.getLineCoverageRate() + "\" branch-rate=\"" + projectData.getBranchCoverageRate() + "\" version=\"" + Header.version() + "\" timestamp=\"" + new Date().getTime() + "\">"); increaseIndentation(); dumpSources(sourceDirectory); dumpPackages(projectData); decreaseIndentation(); println("</coverage>"); } finally { pw.close(); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
dumpSources(sourceDirectory); | dumpSources(); | public XMLReport(ProjectData projectData, File destinationDir, File sourceDirectory) throws IOException { this.sourceDirectory = sourceDirectory; pw = new PrintWriter(new FileWriter(new File(destinationDir, "coverage.xml"))); try { println("<?xml version=\"1.0\"?>"); println("<!DOCTYPE coverage SYSTEM \"http://cobertura.sourceforge.net/xml/" + coverageDTD + "\">"); println(""); // TODO: Set a schema? //println("<coverage " + sourceDirectories.toString() + " xmlns=\"http://cobertura.sourceforge.net\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://cobertura.sourceforge.net/xml/coverage.xsd\">"); println("<coverage line-rate=\"" + projectData.getLineCoverageRate() + "\" branch-rate=\"" + projectData.getBranchCoverageRate() + "\" version=\"" + Header.version() + "\" timestamp=\"" + new Date().getTime() + "\">"); increaseIndentation(); dumpSources(sourceDirectory); dumpPackages(projectData); decreaseIndentation(); println("</coverage>"); } finally { pw.close(); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
double ccn = Util.getCCN(new File(sourceDirectory, classData | double ccn = Util.getCCN(finder.findFile(classData | private void dumpClass(ClassData classData) { logger.debug("Dumping class " + classData.getName()); double ccn = Util.getCCN(new File(sourceDirectory, classData .getSourceFileName()), false); println("<class name=\"" + classData.getName() + "\" filename=\"" + classData.getSourceFileName() + "\" line-rate=\"" + classData.getLineCoverageRate() + "\" branch-rate=\"" + classData.getBranchCoverageRate() + "\" complexity=\"" + ccn + "\"" + ">"); increaseIndentation(); dumpMethods(classData); dumpLines(classData); decreaseIndentation(); println("</class>"); } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
double ccn = Util.getCCN(new File(sourceDirectory, packageData .getSourceFileName()), false); | double ccn = Util.getCCN(finder.findFile(packageData.getSourceFileName()), false); | private void dumpPackage(PackageData packageData) { logger.debug("Dumping package " + packageData.getName()); double ccn = Util.getCCN(new File(sourceDirectory, packageData .getSourceFileName()), false); println("<package name=\"" + packageData.getName() + "\" line-rate=\"" + packageData.getLineCoverageRate() + "\" branch-rate=\"" + packageData.getBranchCoverageRate() + "\" complexity=\"" + ccn + "\"" + ">"); increaseIndentation(); dumpSourceFiles(packageData); decreaseIndentation(); println("</package>"); } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
private void dumpSources(File sourceDirectory) | private void dumpSources() | private void dumpSources(File sourceDirectory) { if (sourceDirectory == null) return; println("<sources>"); increaseIndentation(); dumpSource(sourceDirectory); decreaseIndentation(); println("</sources>"); } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
if (sourceDirectory == null) return; | private void dumpSources(File sourceDirectory) { if (sourceDirectory == null) return; println("<sources>"); increaseIndentation(); dumpSource(sourceDirectory); decreaseIndentation(); println("</sources>"); } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
|
dumpSource(sourceDirectory); | for (Iterator it = finder.getBaseDirectories().iterator(); it.hasNext(); ) { File dir = (File) it.next(); dumpSource(dir); } | private void dumpSources(File sourceDirectory) { if (sourceDirectory == null) return; println("<sources>"); increaseIndentation(); dumpSource(sourceDirectory); decreaseIndentation(); println("</sources>"); } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/XMLReport.java/clean/cobertura/src/net/sourceforge/cobertura/reporting/xml/XMLReport.java |
FastWriter fw = new FastWriter(os, "UTF8"); | FastWriter fw = new FastWriter(os, context.getEncoding()); | public Object evaluate(Context context) throws ContextException { try { ByteArrayOutputStream os = new ByteArrayOutputStream(256); FastWriter fw = new FastWriter(os, "UTF8"); write(fw,context); fw.flush(); return os.toString("UTF8"); } catch (IOException e) { Engine.log.exception(e); Engine.log.error("evaluate got IO exception on write to StringWriter"); return ""; } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/9dc4324fb914abcbf2ec188e4eb77b1bf503f330/ForeachDirective.java/clean/webmacro/src/org/webmacro/engine/ForeachDirective.java |
return os.toString("UTF8"); | return os.toString(context.getEncoding()); | public Object evaluate(Context context) throws ContextException { try { ByteArrayOutputStream os = new ByteArrayOutputStream(256); FastWriter fw = new FastWriter(os, "UTF8"); write(fw,context); fw.flush(); return os.toString("UTF8"); } catch (IOException e) { Engine.log.exception(e); Engine.log.error("evaluate got IO exception on write to StringWriter"); return ""; } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/9dc4324fb914abcbf2ec188e4eb77b1bf503f330/ForeachDirective.java/clean/webmacro/src/org/webmacro/engine/ForeachDirective.java |
annotatedObjectID = -1; annotatedObjectIndex = -1; annotationStatus = INITIAL; | init(); | ClipBoardModel(HiViewer parentModel) { if (parentModel == null) throw new NullPointerException("No parent model."); this.parentModel = parentModel; annotatedObjectID = -1; annotatedObjectIndex = -1; annotationStatus = INITIAL; } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/b4992016524102ee0a5c7465d4cc7a94e9ffce2d/ClipBoardModel.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/clipboard/ClipBoardModel.java |
sortedAnnotations.put(ownerID, CollectionSorter.sortAnnotationDataByDate( (List) sortedAnnotations.get(ownerID))); | annotations = (List) sortedAnnotations.get(ownerID); k = annotations.iterator(); m = new HashMap(annotations.size()); timestamps = new ArrayList(annotations.size()); while (k.hasNext()) { data = (AnnotationData) k.next(); m.put(data.getLastModified(), data); timestamps.add(data.getLastModified()); } results = sorter.sort(timestamps); l = results.iterator(); list = new ArrayList(results.size()); while (l.hasNext()) list.add(m.get(l.next())); sortedAnnotations.put(ownerID, list); | void setAnnotations(Map map) { if (map == null) throw new NullPointerException("No annotations"); HashMap sortedAnnotations = new HashMap(); Set set; Integer index; Iterator i = map.keySet().iterator(); Iterator j; AnnotationData annotation; Integer ownerID; List userAnnos; while (i.hasNext()) { index = (Integer) i.next(); set = (Set) map.get(index); j = set.iterator(); while (j.hasNext()) { annotation = (AnnotationData) j.next();; ownerID = new Integer(annotation.getOwner().getId()); userAnnos = (List) sortedAnnotations.get(ownerID); if (userAnnos == null) { userAnnos = new ArrayList(); sortedAnnotations.put(ownerID, userAnnos); } userAnnos.add(annotation); } } i = sortedAnnotations.keySet().iterator(); while (i.hasNext()) { ownerID = (Integer) i.next(); sortedAnnotations.put(ownerID, CollectionSorter.sortAnnotationDataByDate( (List) sortedAnnotations.get(ownerID))); } this.annotations = sortedAnnotations; state = ClipBoard.ANNOTATIONS_READY; } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/b4992016524102ee0a5c7465d4cc7a94e9ffce2d/ClipBoardModel.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/clipboard/ClipBoardModel.java |
area.setEnabled(false); | private JPanel buildContentPanel(Map details) { JPanel content = new JPanel(); content.setLayout(new GridBagLayout()); content.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 3, 3, 3); Iterator i = details.keySet().iterator(); JLabel label; JTextField area; String key, value; fields = new HashMap(details.size()); while (i.hasNext()) { ++c.gridy; c.gridx = 0; key = (String) i.next(); value = (String) details.get(key); label = UIUtilities.setTextFont(key); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; //reset to default c.weightx = 0.0; content.add(label, c); area = new JTextField(value); area.setEditable(false); label.setLabelFor(area); fields.put(key, area); c.gridx = 1; c.gridwidth = GridBagConstraints.REMAINDER; //end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(area, c); } return content; } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/38a31e9c570bc8c0bbfb871c8b12b0e52420f22c/InfoPaneUI.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/clipboard/info/InfoPaneUI.java |
|
public void onDataObjectSave(DataObject data, int operation) { int state = model.getState(); if (operation == REMOVE_OBJECT && state != SAVE) throw new IllegalStateException("This method cannot be " + "invoked in the SAVE state"); switch (state) { case DISCARDED: throw new IllegalStateException("This method cannot be " + "invoked in the DISCARDED state"); } if (data == null) throw new IllegalArgumentException("No data object. "); switch (operation) { case Editor.CREATE_OBJECT: case Editor.UPDATE_OBJECT: case REMOVE_OBJECT: break; default: throw new IllegalArgumentException("Save operation not " + "supported."); } int editor = model.getEditorType(); removeEditor(); //remove the currently selected editor. Browser browser = model.getSelectedBrowser(); browser.refreshEdition(data, operation); if (operation == Editor.UPDATE_OBJECT) { Map browsers = model.getBrowsers(); Iterator i = browsers.keySet().iterator(); while (i.hasNext()) { browser = (Browser) browsers.get(i.next()); if (!(browser.equals(model.getSelectedBrowser()))) browser.refreshEdition(data, operation); } } if (editor == TreeViewer.CREATE_EDITOR) { PropertiesCmd cmd = new PropertiesCmd(this); cmd.execute(); } if (operation == REMOVE_OBJECT) { model.setState(READY); fireStateChange(); } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/fc0b268aabfe722365161921f8c052bd9642f3b6/TreeViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
||
int state = model.getState(); if (state != NEW && state != READY) throw new IllegalStateException("This method should only be " + "invoked in the NEW or READY state."); | switch (model.getState()) { case READY: case NEW: break; default: throw new IllegalStateException("This method should only be " + "invoked in the READY or NEW state."); } | public void removeObject(DataObject object) { int state = model.getState(); if (state != NEW && state != READY) throw new IllegalStateException("This method should only be " + "invoked in the NEW or READY state."); model.fireDataObjectDeletion(object); fireStateChange(); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/fc0b268aabfe722365161921f8c052bd9642f3b6/TreeViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
if (model.getState() != READY) throw new IllegalStateException("This method should only be " + "invoked in the READY state."); | switch (model.getState()) { case READY: case NEW: break; default: throw new IllegalStateException("This method should only be " + "invoked in the READY or NEW state."); } | public void showClassifier(ImageData object, int mode) { if (model.getState() != READY) throw new IllegalStateException("This method should only be " + "invoked in the READY state."); if (object == null) throw new IllegalArgumentException("Object cannot be null."); removeEditor(); model.setEditorType(CLASSIFIER_EDITOR); Classifier classifier = ClassifierFactory.getClassifier(this, mode, object); classifier.addPropertyChangeListener(controller); classifier.activate(); view.addComponent(classifier.getUI()); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/fc0b268aabfe722365161921f8c052bd9642f3b6/TreeViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
case DISCARDED: case SAVE: throw new IllegalStateException( "This method cannot be invoked in the DISCARDED or SAVE " + "state."); | case READY: case NEW: break; default: throw new IllegalStateException("This method should only be " + "invoked in the READY or NEW state."); | public void showFinder(boolean b) { switch (model.getState()) { case DISCARDED: case SAVE: throw new IllegalStateException( "This method cannot be invoked in the DISCARDED or SAVE " + "state."); } if (model.getSelectedBrowser() == null) return; Finder finder = model.getFinder(); if (b == finder.isDisplay()) return; Boolean oldValue = finder.isDisplay() ? Boolean.TRUE : Boolean.FALSE, newValue = b ? Boolean.TRUE : Boolean.FALSE; view.showFinder(b); firePropertyChange(FINDER_VISIBLE_PROPERTY, oldValue, newValue); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/fc0b268aabfe722365161921f8c052bd9642f3b6/TreeViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/treeviewer/view/TreeViewerComponent.java |
return new RubyArray(ruby, list); | return RubyArray.newArray(ruby, list); | public static RubyArray list(Ruby ruby, RubyObject recv) { ArrayList list = new ArrayList(); Iterator iter = ruby.objectSpace.iterator(ruby.getClasses().getThreadClass()); while (iter.hasNext()) { list.add(iter.next()); } return new RubyArray(ruby, list); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/62333c275b1a643f18c9a79af5bbb2f0027f4392/RubyThread.java/clean/org/jruby/RubyThread.java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.