rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
meta
stringlengths
141
403
current.setMarkerData(markerData);
private static void positionVertically( LayoutContext c, Box container, LineBox current, MarkerData markerData) { if (current.getChildCount() == 0) { current.height = 0; } else { LineMetrics strutLM = container.getStyle().getLineMetrics(c); VerticalAlignContext vaContext = new VerticalAlignContext(); InlineBoxMeasurements measurements = getInitialMeasurements(c, container, strutLM); vaContext.pushMeasurements(measurements); TextDecoration lBDecoration = calculateTextDecoration( container, measurements.getBaseline(), strutLM); if (lBDecoration != null) { current.setTextDecoration(lBDecoration); } for (int i = 0; i < current.getChildCount(); i++) { Box child = current.getChild(i); positionInlineContentVertically(c, vaContext, child); } vaContext.alignChildren(); current.setHeight(vaContext.getLineBoxHeight()); int paintingTop = vaContext.getPaintingTop(); int paintingBottom = vaContext.getPaintingBottom(); if (vaContext.getInlineTop() < 0) { moveLineContents(current, -vaContext.getInlineTop()); if (lBDecoration != null) { lBDecoration.setOffset(lBDecoration.getOffset() - vaContext.getInlineTop()); } paintingTop -= vaContext.getInlineTop(); paintingBottom -= vaContext.getInlineTop(); } if (markerData != null) { StrutMetrics strutMetrics = markerData.getStructMetrics(); strutMetrics.setBaseline(measurements.getBaseline() - vaContext.getInlineTop()); markerData.setReferenceLine(current); } current.setPaintingTop(paintingTop); current.setPaintingHeight(paintingBottom - paintingTop); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/e8201cacc8af3fd808d6f2e488d68abbbd79a0b0/InlineBoxing.java/clean/src/java/org/xhtmlrenderer/layout/InlineBoxing.java
current.addNonFlowContent(abs);
if (abs != null) { current.addNonFlowContent(abs); }
private static int processOutOfFlowContent(LayoutContext c, Content content, LineBox current, int available, List pendingFloats) { int result = 0; c.pushStyle(content.getStyle()); if (content instanceof AbsolutelyPositionedContent) { BlockBox abs = LayoutUtil.generateAbsolute(c, content, current); current.addNonFlowContent(abs); } else if (content instanceof FloatedBlockContent) { FloatedBlockBox floater = LayoutUtil.generateFloated( c, (FloatedBlockContent)content, available, current, pendingFloats); if (!floater.isPending()) { result = floater.getWidth(); } current.addNonFlowContent(floater); } c.popStyle(); return result; }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/e8201cacc8af3fd808d6f2e488d68abbbd79a0b0/InlineBoxing.java/clean/src/java/org/xhtmlrenderer/layout/InlineBoxing.java
addTest(new JFacePerformanceSuite());
public UIPerformanceTestSuite() { addTest(new ActivitiesPerformanceSuite()); addTest(new PresentationPerformanceTestSuite()); addTest(new WorkbenchPerformanceSuite()); addTest(new ViewPerformanceSuite()); addTest(new EditorPerformanceSuite()); addTest(new TestSuite(CommandsPerformanceTest.class)); addTest(new JFacePerformanceSuite()); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/2d68822a79e6e20d403c2debfba4b04bdf2e5057/UIPerformanceTestSuite.java/buggy/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/performance/UIPerformanceTestSuite.java
public void handleChange(IObservable source) {
public void handleChange(ChangeEvent event) {
public void testScenario14() { Text t1 = new Text(getComposite(), SWT.BORDER); Text t2 = new Text(getComposite(), SWT.BORDER); getDbc().bindValue(SWTObservables.observeText(t1, SWT.Modify), BeansObservables.observeValue(adventure, "name"), null); getDbc().bindValue(SWTObservables.observeText(t2, SWT.Modify), BeansObservables.observeValue(adventure, "name"), null); final int[] counter = { 0 }; IObservableValue uv = BeansObservables.observeValue(adventure, "name"); uv.addChangeListener(new IChangeListener() { public void handleChange(IObservable source) { // Count how many times adventure has changed counter[0]++; } }); String name = adventure.getName() + "Foo"; enterText(t1, name); assertEquals(name, adventure.getName()); assertEquals(name, t2.getText()); assertTrue(counter[0] == 1); name = name + "Bar"; uv.setValue(name); assertEquals(t1.getText(), adventure.getName()); assertEquals(2, counter[0]); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/PropertyScenarios.java/buggy/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java
public void handleChange(IObservable source) {
public void handleChange(ChangeEvent event) {
public void handleChange(IObservable source) { // Count how many times adventure has changed counter[0]++; }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/PropertyScenarios.java/buggy/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java
log().warn(
log().info(
private boolean processBroadcast(DatagramPacket packet) { if (packet == null) { throw new NullPointerException("Packet is null"); } if (packet.getData() == null) { throw new NullPointerException("Packet data is null"); } byte[] content = new byte[packet.getLength()]; System.arraycopy(packet.getData(), 0, content, 0, content.length); String message = new String(content); if (logVerbose) { log().verbose( "Received broadcast: " + message + ", " + packet.getAddress()); } int port; String id; int bS = message.indexOf('['); int bE = message.indexOf(']'); if (bS > 0 && bE > 0) { String portStr = message.substring(bS + 1, bE); try { port = Integer.parseInt(portStr); } catch (NumberFormatException e) { log().verbose("Unable to parse port from broadcast message"); return false; } } else { return false; } bS = message.indexOf('[', bE + 1); bE = message.indexOf(']', bE + 1); if (bS > 0 && bE > 0) { id = message.substring(bS + 1, bE); } else { return false; } InetSocketAddress address = new InetSocketAddress(packet.getAddress(), port); // Add to list of recently received broadcasts // log().warn("Address is on LAN: " + // address.getAddress().getHostAddress()); recentBroadcastAddresses.add(address.getAddress().getHostAddress()); Member node = getController().getNodeManager().getNode(id); if (node == null || (!node.isMySelf() && !node.isConnected())) { log().warn( "Found user on local network: " + address + ((node != null) ? ", " + node : "")); try { if (getController().isStarted()) { // found another new node!!! getController().connect(address); return true; } } catch (ConnectionException e) { log().error("Unable to connect to node on subnet: " + address, e); } } else { if (logVerbose) { log().verbose("Node already known: ID: " + id + ", " + node); } // Node must be on lan node.setOnLAN(true); } return false; }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/3088012a817f09615cb41d472a74fce5ebca6029/BroadcastMananger.java/clean/src/main/de/dal33t/powerfolder/net/BroadcastMananger.java
String plid = ParamUtil.getString(request, "p_l_id");
String plid = _getPlid(request.getPathInfo(), ParamUtil.getString(request, "p_l_id"));
public void doFilter( ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (USE_LAYOUT_CACHE_FILTER) { _log.debug("Layout Cache is enabled"); } else { _log.debug("Layout Cache is disabled"); } HttpServletRequest request = (HttpServletRequest)req; HttpServletResponse response = (HttpServletResponse)res; String companyId = PortalUtil.getCompanyId(request); String plid = ParamUtil.getString(request, "p_l_id"); String portletId = ParamUtil.getString(request, "p_p_id"); String languageId = LanguageUtil.getLanguageId(request); if (Validator.isNull(portletId) && Validator.isNotNull(plid)) { if (USE_LAYOUT_CACHE_FILTER && !_isAlreadyFiltered(request) && !_isSignedIn(request) && !_isInclude(request) && _isCacheable(companyId, plid)) { request.setAttribute(_ALREADY_FILTERED, Boolean.TRUE); byte[] byteArray = null; if (!LayoutCacheUtil.isCached(companyId, plid, languageId)) { _log.info("Caching layout " + plid); LayoutCacheResponse layoutCacheResponse = new LayoutCacheResponse(response); chain.doFilter(req, layoutCacheResponse); byteArray = layoutCacheResponse.getData(); LayoutCacheUtil.putLayout( companyId, plid, languageId, byteArray); } else { _log.info("Getting cached layout " + plid); byteArray = LayoutCacheUtil.getLayout( companyId, plid, languageId); } res.setContentLength(byteArray.length); ServletOutputStream out = response.getOutputStream(); out.write(byteArray, 0, byteArray.length); out.flush(); out.close(); } else { _log.debug("Not checking cached layout " + plid); chain.doFilter(req, res); } } else { _log.debug("Did not request a layout"); chain.doFilter(req, res); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/8311ae9570b25acf1411b7be0c2156fbdfc27de9/LayoutCacheFilter.java/buggy/portal-ejb/src/com/liferay/portal/servlet/filters/layoutcache/LayoutCacheFilter.java
synchronized (FriendlyURLServlet.class) { ServletContext ctx = filterConfig.getServletContext(); _companyId = ctx.getInitParameter("company_id"); _friendly = GetterUtil.getBoolean(filterConfig.getInitParameter( "friendly")); }
public void init(FilterConfig filterConfig) { }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/8311ae9570b25acf1411b7be0c2156fbdfc27de9/LayoutCacheFilter.java/buggy/portal-ejb/src/com/liferay/portal/servlet/filters/layoutcache/LayoutCacheFilter.java
nilClass.defineMethod("type", getMethodType()); nilClass.defineMethod("to_i", getMethodToI()); nilClass.defineMethod("to_s", getMethodToS()); nilClass.defineMethod("to_a", getMethodToA()); nilClass.defineMethod("inspect", getMethodInspect());
nilClass.defineMethod("type", getMethod("m_type")); nilClass.defineMethod("to_i", getMethod("m_to_")); nilClass.defineMethod("to_s", getMethod("m_to_s")); nilClass.defineMethod("to_a", getMethod("m_to_a")); nilClass.defineMethod("inspect", getMethod("m_inspect"));
public static RubyClass createNilClass(Ruby ruby) { RubyClass nilClass = ruby.defineClass("NilClass", ruby.getObjectClass()); nilClass.defineMethod("type", getMethodType()); nilClass.defineMethod("to_i", getMethodToI()); nilClass.defineMethod("to_s", getMethodToS()); nilClass.defineMethod("to_a", getMethodToA()); nilClass.defineMethod("inspect", getMethodInspect()); nilClass.defineMethod("&", getMethodAnd()); nilClass.defineMethod("|", getMethodOr()); nilClass.defineMethod("^", getMethodXor()); nilClass.defineMethod("nil?", DefaultCallbackMethods.getMethodTrue()); nilClass.getRubyClass().undefMethod("new"); ruby.defineGlobalConstant("NIL", ruby.getNil()); return nilClass; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/60d09f0d06e157ff7d9bb828d89273706e4e2798/RbNilClass.java/buggy/org/jruby/core/RbNilClass.java
nilClass.defineMethod("&", getMethodAnd()); nilClass.defineMethod("|", getMethodOr()); nilClass.defineMethod("^", getMethodXor());
nilClass.defineMethod("&", getMethod("op_and", RubyObject.class)); nilClass.defineMethod("|", getMethod("op_or", RubyObject.class)); nilClass.defineMethod("^", getMethod("op_xor", RubyObject.class));
public static RubyClass createNilClass(Ruby ruby) { RubyClass nilClass = ruby.defineClass("NilClass", ruby.getObjectClass()); nilClass.defineMethod("type", getMethodType()); nilClass.defineMethod("to_i", getMethodToI()); nilClass.defineMethod("to_s", getMethodToS()); nilClass.defineMethod("to_a", getMethodToA()); nilClass.defineMethod("inspect", getMethodInspect()); nilClass.defineMethod("&", getMethodAnd()); nilClass.defineMethod("|", getMethodOr()); nilClass.defineMethod("^", getMethodXor()); nilClass.defineMethod("nil?", DefaultCallbackMethods.getMethodTrue()); nilClass.getRubyClass().undefMethod("new"); ruby.defineGlobalConstant("NIL", ruby.getNil()); return nilClass; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/60d09f0d06e157ff7d9bb828d89273706e4e2798/RbNilClass.java/buggy/org/jruby/core/RbNilClass.java
/*
public static void layoutContent(LayoutContext c, Box box, List contentList, Box block) { // prepare for the list items int old_counter = c.getListCounter(); c.setListCounter(0); Iterator contentIterator = contentList.iterator(); while (contentIterator.hasNext()) { Object o = contentIterator.next(); if (o instanceof FirstLineStyle) {//can actually only be the first object in list block.firstLineStyle = ((FirstLineStyle) o).getStyle(); //put it into the Context so it gets used on the first line c.addFirstLineStyle(block.firstLineStyle); continue; } if (o instanceof FirstLetterStyle) {//can actually only be the first or second object in list block.firstLetterStyle = ((FirstLetterStyle) o).getStyle(); continue; } Content currentContent = (Content) o; Box child_box = null; //TODO:handle run-ins. For now, treat them as blocks // update the counter for printing OL list items //TODO:handle counters correctly c.setListCounter(c.getListCounter() + 1); // execute the layout and get the return bounds //c.parent_box = box; //c.placement_point = new Point(0, box.height); c.translate(0, box.height); //child_box = Boxing.layout(c, currentContent); child_box = Boxing.preLayout(c, currentContent); //Uu.p("did pre layout on : " + child_box); //Uu.p("adding the child: " + child_box); child_box.list_count = c.getListCounter(); // set the child_box location child_box.x = 0; double initialY = box.height; child_box.y = (int) initialY; //Uu.p("set child box y to: " + child_box); box.addChild(child_box); Boxing.realLayout(c, child_box, currentContent); box.propagateChildProperties(child_box); c.translate(0, -box.height); //JMM. new code to handle the 'clear' property // if clear set /* if (child_box.getStyle().isCleared()) {//Uu.p("doing a clear on: " + child_box); // get the distance we have to move it down int down = 0; //Uu.p("down = " + down); if (child_box.getStyle().isClearLeft()) { //Uu.p("left clear"); //Uu.p("left down = " + c.getPersistentBFC().getLeftDownDistance(child_box)); down = Math.max(down, c.getBlockFormattingContext().getLeftDownDistance(child_box)); } //Uu.p("down = " + down); if (child_box.getStyle().isClearRight()) { //Uu.p("right clear"); //Uu.p("right down = " + c.getPersistentBFC().getRightDownDistance(child_box)); down = Math.max(down, c.getBlockFormattingContext().getRightDownDistance(child_box)); } //Uu.p("down = " + down); int diff = down - child_box.y; //Uu.p("child box.y = " + child_box.y); //Uu.p("diff = " + diff); if (diff > 0) { // move child box down child_box.y = down; // adjust parent box box.height += diff; } } */ //joshy fix the 'fixed' stuff later // if fixed or abs then don't modify the final layout bounds // because fixed elements are removed from normal flow if (child_box.getStyle().isFixed()) { // put fixed positioning in later Fixed.positionFixedChild(c, child_box); } if (child_box.getStyle().isAbsolute()) { Absolute.positionAbsoluteChild(c, child_box); } // skip adjusting the parent box if the child // doesn't affect flow layout if (child_box.getStyle().isOutsideNormalFlow()) { continue; } // increase the final layout width if the child was greater box.adjustWidthForChild(child_box.getWidth()); c.addMaxWidth(box.getWidth()); // increase the final layout height by the height of the child box.height += (child_box.y - initialY) + child_box.height; c.addMaxHeight(box.height + box.y + (int) c.getOriginOffset().getY()); if (c.shouldStop()) { break; } //Uu.p("alerting that there is a box available"); Dimension max_size = new Dimension(c.getMaxWidth(), c.getMaxHeight()); if (c.isInteractive() && !c.isPrint()) { if (Configuration.isTrue("xr.incremental.enabled", false) && c.isRenderQueueAvailable()) { c.getRenderQueue().dispatchRepaintEvent(new ReflowEvent(ReflowEvent.MORE_BOXES_AVAILABLE, box, max_size)); } int delay = Configuration.valueAsInt("xr.incremental.debug.layoutdelay", 0); if (delay > 0) { //Uu.p("sleeping for: " + delay); try { Uu.sleep(delay); } catch (Exception ex) { Uu.p("sleep was interrupted in BlockBoxing.layoutContent()!"); } } } } c.addMaxWidth(box.getWidth()); c.setListCounter(old_counter); if (block.firstLineStyle != null) { //pop it in case it wasn't used c.popFirstLineStyle(); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/e4a850d2659ab4206b49796821938803b48f1797/BlockBoxing.java/buggy/src/java/org/xhtmlrenderer/layout/BlockBoxing.java
int down = 0; if (child_box.getStyle().isClearLeft()) { down = Math.max(down, c.getBlockFormattingContext().getLeftDownDistance(child_box)); } if (child_box.getStyle().isClearRight()) { down = Math.max(down, c.getBlockFormattingContext().getRightDownDistance(child_box)); } int diff = down - child_box.y; if (diff > 0) { child_box.y = down; box.height += diff; }
int currentX = child_box.x; c.getBlockFormattingContext().clear(c, child_box); box.height += child_box.x - currentX;
public static void layoutContent(LayoutContext c, Box box, List contentList, Box block) { // prepare for the list items int old_counter = c.getListCounter(); c.setListCounter(0); Iterator contentIterator = contentList.iterator(); while (contentIterator.hasNext()) { Object o = contentIterator.next(); if (o instanceof FirstLineStyle) {//can actually only be the first object in list block.firstLineStyle = ((FirstLineStyle) o).getStyle(); //put it into the Context so it gets used on the first line c.addFirstLineStyle(block.firstLineStyle); continue; } if (o instanceof FirstLetterStyle) {//can actually only be the first or second object in list block.firstLetterStyle = ((FirstLetterStyle) o).getStyle(); continue; } Content currentContent = (Content) o; Box child_box = null; //TODO:handle run-ins. For now, treat them as blocks // update the counter for printing OL list items //TODO:handle counters correctly c.setListCounter(c.getListCounter() + 1); // execute the layout and get the return bounds //c.parent_box = box; //c.placement_point = new Point(0, box.height); c.translate(0, box.height); //child_box = Boxing.layout(c, currentContent); child_box = Boxing.preLayout(c, currentContent); //Uu.p("did pre layout on : " + child_box); //Uu.p("adding the child: " + child_box); child_box.list_count = c.getListCounter(); // set the child_box location child_box.x = 0; double initialY = box.height; child_box.y = (int) initialY; //Uu.p("set child box y to: " + child_box); box.addChild(child_box); Boxing.realLayout(c, child_box, currentContent); box.propagateChildProperties(child_box); c.translate(0, -box.height); //JMM. new code to handle the 'clear' property // if clear set /* if (child_box.getStyle().isCleared()) {//Uu.p("doing a clear on: " + child_box); // get the distance we have to move it down int down = 0; //Uu.p("down = " + down); if (child_box.getStyle().isClearLeft()) { //Uu.p("left clear"); //Uu.p("left down = " + c.getPersistentBFC().getLeftDownDistance(child_box)); down = Math.max(down, c.getBlockFormattingContext().getLeftDownDistance(child_box)); } //Uu.p("down = " + down); if (child_box.getStyle().isClearRight()) { //Uu.p("right clear"); //Uu.p("right down = " + c.getPersistentBFC().getRightDownDistance(child_box)); down = Math.max(down, c.getBlockFormattingContext().getRightDownDistance(child_box)); } //Uu.p("down = " + down); int diff = down - child_box.y; //Uu.p("child box.y = " + child_box.y); //Uu.p("diff = " + diff); if (diff > 0) { // move child box down child_box.y = down; // adjust parent box box.height += diff; } } */ //joshy fix the 'fixed' stuff later // if fixed or abs then don't modify the final layout bounds // because fixed elements are removed from normal flow if (child_box.getStyle().isFixed()) { // put fixed positioning in later Fixed.positionFixedChild(c, child_box); } if (child_box.getStyle().isAbsolute()) { Absolute.positionAbsoluteChild(c, child_box); } // skip adjusting the parent box if the child // doesn't affect flow layout if (child_box.getStyle().isOutsideNormalFlow()) { continue; } // increase the final layout width if the child was greater box.adjustWidthForChild(child_box.getWidth()); c.addMaxWidth(box.getWidth()); // increase the final layout height by the height of the child box.height += (child_box.y - initialY) + child_box.height; c.addMaxHeight(box.height + box.y + (int) c.getOriginOffset().getY()); if (c.shouldStop()) { break; } //Uu.p("alerting that there is a box available"); Dimension max_size = new Dimension(c.getMaxWidth(), c.getMaxHeight()); if (c.isInteractive() && !c.isPrint()) { if (Configuration.isTrue("xr.incremental.enabled", false) && c.isRenderQueueAvailable()) { c.getRenderQueue().dispatchRepaintEvent(new ReflowEvent(ReflowEvent.MORE_BOXES_AVAILABLE, box, max_size)); } int delay = Configuration.valueAsInt("xr.incremental.debug.layoutdelay", 0); if (delay > 0) { //Uu.p("sleeping for: " + delay); try { Uu.sleep(delay); } catch (Exception ex) { Uu.p("sleep was interrupted in BlockBoxing.layoutContent()!"); } } } } c.addMaxWidth(box.getWidth()); c.setListCounter(old_counter); if (block.firstLineStyle != null) { //pop it in case it wasn't used c.popFirstLineStyle(); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/e4a850d2659ab4206b49796821938803b48f1797/BlockBoxing.java/buggy/src/java/org/xhtmlrenderer/layout/BlockBoxing.java
*/
public static void layoutContent(LayoutContext c, Box box, List contentList, Box block) { // prepare for the list items int old_counter = c.getListCounter(); c.setListCounter(0); Iterator contentIterator = contentList.iterator(); while (contentIterator.hasNext()) { Object o = contentIterator.next(); if (o instanceof FirstLineStyle) {//can actually only be the first object in list block.firstLineStyle = ((FirstLineStyle) o).getStyle(); //put it into the Context so it gets used on the first line c.addFirstLineStyle(block.firstLineStyle); continue; } if (o instanceof FirstLetterStyle) {//can actually only be the first or second object in list block.firstLetterStyle = ((FirstLetterStyle) o).getStyle(); continue; } Content currentContent = (Content) o; Box child_box = null; //TODO:handle run-ins. For now, treat them as blocks // update the counter for printing OL list items //TODO:handle counters correctly c.setListCounter(c.getListCounter() + 1); // execute the layout and get the return bounds //c.parent_box = box; //c.placement_point = new Point(0, box.height); c.translate(0, box.height); //child_box = Boxing.layout(c, currentContent); child_box = Boxing.preLayout(c, currentContent); //Uu.p("did pre layout on : " + child_box); //Uu.p("adding the child: " + child_box); child_box.list_count = c.getListCounter(); // set the child_box location child_box.x = 0; double initialY = box.height; child_box.y = (int) initialY; //Uu.p("set child box y to: " + child_box); box.addChild(child_box); Boxing.realLayout(c, child_box, currentContent); box.propagateChildProperties(child_box); c.translate(0, -box.height); //JMM. new code to handle the 'clear' property // if clear set /* if (child_box.getStyle().isCleared()) {//Uu.p("doing a clear on: " + child_box); // get the distance we have to move it down int down = 0; //Uu.p("down = " + down); if (child_box.getStyle().isClearLeft()) { //Uu.p("left clear"); //Uu.p("left down = " + c.getPersistentBFC().getLeftDownDistance(child_box)); down = Math.max(down, c.getBlockFormattingContext().getLeftDownDistance(child_box)); } //Uu.p("down = " + down); if (child_box.getStyle().isClearRight()) { //Uu.p("right clear"); //Uu.p("right down = " + c.getPersistentBFC().getRightDownDistance(child_box)); down = Math.max(down, c.getBlockFormattingContext().getRightDownDistance(child_box)); } //Uu.p("down = " + down); int diff = down - child_box.y; //Uu.p("child box.y = " + child_box.y); //Uu.p("diff = " + diff); if (diff > 0) { // move child box down child_box.y = down; // adjust parent box box.height += diff; } } */ //joshy fix the 'fixed' stuff later // if fixed or abs then don't modify the final layout bounds // because fixed elements are removed from normal flow if (child_box.getStyle().isFixed()) { // put fixed positioning in later Fixed.positionFixedChild(c, child_box); } if (child_box.getStyle().isAbsolute()) { Absolute.positionAbsoluteChild(c, child_box); } // skip adjusting the parent box if the child // doesn't affect flow layout if (child_box.getStyle().isOutsideNormalFlow()) { continue; } // increase the final layout width if the child was greater box.adjustWidthForChild(child_box.getWidth()); c.addMaxWidth(box.getWidth()); // increase the final layout height by the height of the child box.height += (child_box.y - initialY) + child_box.height; c.addMaxHeight(box.height + box.y + (int) c.getOriginOffset().getY()); if (c.shouldStop()) { break; } //Uu.p("alerting that there is a box available"); Dimension max_size = new Dimension(c.getMaxWidth(), c.getMaxHeight()); if (c.isInteractive() && !c.isPrint()) { if (Configuration.isTrue("xr.incremental.enabled", false) && c.isRenderQueueAvailable()) { c.getRenderQueue().dispatchRepaintEvent(new ReflowEvent(ReflowEvent.MORE_BOXES_AVAILABLE, box, max_size)); } int delay = Configuration.valueAsInt("xr.incremental.debug.layoutdelay", 0); if (delay > 0) { //Uu.p("sleeping for: " + delay); try { Uu.sleep(delay); } catch (Exception ex) { Uu.p("sleep was interrupted in BlockBoxing.layoutContent()!"); } } } } c.addMaxWidth(box.getWidth()); c.setListCounter(old_counter); if (block.firstLineStyle != null) { //pop it in case it wasn't used c.popFirstLineStyle(); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/e4a850d2659ab4206b49796821938803b48f1797/BlockBoxing.java/buggy/src/java/org/xhtmlrenderer/layout/BlockBoxing.java
if (input == null) return null;
protected IEditorPart getEditorPart() { return page.findEditor(input); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9def7f1877569634a15129fdfdba108be21ce3b0/NavigationLocation.java/clean/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/NavigationLocation.java
configHash.aset(RubyString.newString(runtime, key), RubyString.newString(runtime, value));
configHash.aset(runtime.newString(key), runtime.newString(value));
private void setConfig(String key, String value) { Ruby runtime = configHash.getRuntime(); configHash.aset(RubyString.newString(runtime, key), RubyString.newString(runtime, value)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/RbConfig.java/clean/src/org/jruby/libraries/RbConfig.java
LogFactoryUtil.setLogFactory(new LogFactoryImpl());
LogFactoryUtil.setLogFactory(new CommonsLogFactoryImpl());
public void run(String[] ids) throws ActionException { // Set default locale String userLanguage = SystemProperties.get("user.language"); String userCountry = SystemProperties.get("user.country"); String userVariant = SystemProperties.get("user.variant"); if (Validator.isNull(userVariant)) { Locale.setDefault(new Locale(userLanguage, userCountry)); } else { Locale.setDefault( new Locale(userLanguage, userCountry, userVariant)); } // Set default time zone TimeZone.setDefault( TimeZone.getTimeZone(SystemProperties.get("user.timezone"))); // Shared class loader try { PortalClassLoaderUtil.setClassLoader( Thread.currentThread().getContextClassLoader()); } catch (Exception e) { e.printStackTrace(); } // Shared log try { LogFactoryUtil.setLogFactory(new LogFactoryImpl()); } catch (Exception e) { e.printStackTrace(); } // Log4J if (GetterUtil.getBoolean(SystemProperties.get( "log4j.configure.on.startup"), true) && !ServerDetector.isSun()) { ClassLoader classLoader = getClass().getClassLoader(); configureLog4J( classLoader.getResource("META-INF/portal-log4j.xml")); configureLog4J( classLoader.getResource("META-INF/portal-log4j-ext.xml")); } // JAAS if ((GetterUtil.getBoolean(PropsUtil.get( PropsUtil.PORTAL_CONFIGURATION))) && (ServerDetector.isJBoss() || ServerDetector.isPramati() || ServerDetector.isSun() || ServerDetector.isWebLogic())) { PortalConfiguration portalConfig = new PortalConfiguration( Configuration.getConfiguration()); Configuration.setConfiguration(portalConfig); } // JCR try { File repistoryRoot = new File(JCRFactoryImpl.REPOSITORY_ROOT); if (!repistoryRoot.exists()) { repistoryRoot.mkdirs(); File tempFile = new File( SystemProperties.get(SystemProperties.TMP_DIR) + File.separator + Time.getTimestamp()); String content = StringUtil.read( getClass().getClassLoader(), "com/liferay/portal/jcr/jackrabbit/dependencies/" + "repository.xml"); FileUtil.write(tempFile, content); FileUtil.copyFile( tempFile, new File(JCRFactoryImpl.CONFIG_FILE_PATH)); tempFile.delete(); } } catch (Exception e) { e.printStackTrace(); } // JMS SpringBrokerContainerFactory factory = new SpringBrokerContainerFactory(); factory.setResource(new ClassPathResource("META-INF/activemq.xml")); BrokerContainer container = factory.createBrokerContainer( "DefaultBroker", BrokerContext.getInstance()); try { container.start(); } catch (Exception e) { e.printStackTrace(); } // Velocity MultipleResourceLoader.setListeners(SystemProperties.getArray( VelocityResourceListener.class.getName())); ExtendedProperties props = new ExtendedProperties(); props.setProperty(RuntimeConstants.RESOURCE_LOADER, "servlet"); props.setProperty( "servlet." + RuntimeConstants.RESOURCE_LOADER + ".class", MultipleResourceLoader.class.getName()); props.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.SimpleLog4JLogSystem"); props.setProperty( "runtime.log.logsystem.log4j.category", "org.apache.velocity"); Velocity.setExtendedProperties(props); try { Velocity.init(); } catch (Exception e) { e.printStackTrace(); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/c26c278b568cc398e3f9799f5354d071a7fcb4ef/InitAction.java/clean/portal-ejb/src/com/liferay/portal/events/InitAction.java
IRubyObject topSelf = new RubyObject(runtime, runtime.getClasses().getObjectClass());
IRubyObject topSelf = new RubyObject(runtime, runtime.getObject());
public static IRubyObject createTopSelf(final Ruby runtime) { IRubyObject topSelf = new RubyObject(runtime, runtime.getClasses().getObjectClass()); topSelf.defineSingletonMethod("to_s", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.newString("main"); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.noArguments(); } }); topSelf.defineSingletonMethod("include", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { runtime.secure(4); return runtime.getClasses().getObjectClass().include(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("public", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPublic(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("private", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPrivate(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); return topSelf; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/TopSelfFactory.java/buggy/src/org/jruby/TopSelfFactory.java
return runtime.getClasses().getObjectClass().include(args);
return runtime.getObject().include(args);
public static IRubyObject createTopSelf(final Ruby runtime) { IRubyObject topSelf = new RubyObject(runtime, runtime.getClasses().getObjectClass()); topSelf.defineSingletonMethod("to_s", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.newString("main"); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.noArguments(); } }); topSelf.defineSingletonMethod("include", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { runtime.secure(4); return runtime.getClasses().getObjectClass().include(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("public", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPublic(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("private", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPrivate(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); return topSelf; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/TopSelfFactory.java/buggy/src/org/jruby/TopSelfFactory.java
return runtime.getClasses().getObjectClass().rbPublic(args);
return runtime.getObject().rbPublic(args);
public static IRubyObject createTopSelf(final Ruby runtime) { IRubyObject topSelf = new RubyObject(runtime, runtime.getClasses().getObjectClass()); topSelf.defineSingletonMethod("to_s", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.newString("main"); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.noArguments(); } }); topSelf.defineSingletonMethod("include", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { runtime.secure(4); return runtime.getClasses().getObjectClass().include(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("public", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPublic(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("private", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPrivate(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); return topSelf; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/TopSelfFactory.java/buggy/src/org/jruby/TopSelfFactory.java
return runtime.getClasses().getObjectClass().rbPrivate(args);
return runtime.getObject().rbPrivate(args);
public static IRubyObject createTopSelf(final Ruby runtime) { IRubyObject topSelf = new RubyObject(runtime, runtime.getClasses().getObjectClass()); topSelf.defineSingletonMethod("to_s", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.newString("main"); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.noArguments(); } }); topSelf.defineSingletonMethod("include", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { runtime.secure(4); return runtime.getClasses().getObjectClass().include(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("public", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPublic(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); topSelf.defineSingletonMethod("private", new Callback() { /** * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) */ public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPrivate(args); } /** * @see org.jruby.runtime.callback.Callback#getArity() */ public Arity getArity() { return Arity.optional(); } }); return topSelf; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/TopSelfFactory.java/buggy/src/org/jruby/TopSelfFactory.java
return runtime.getClasses().getObjectClass().include(args);
return runtime.getObject().include(args);
public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { runtime.secure(4); return runtime.getClasses().getObjectClass().include(args); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/TopSelfFactory.java/buggy/src/org/jruby/TopSelfFactory.java
return runtime.getClasses().getObjectClass().rbPublic(args);
return runtime.getObject().rbPublic(args);
public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPublic(args); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/TopSelfFactory.java/buggy/src/org/jruby/TopSelfFactory.java
return runtime.getClasses().getObjectClass().rbPrivate(args);
return runtime.getObject().rbPrivate(args);
public IRubyObject execute(IRubyObject recv, IRubyObject[] args) { return runtime.getClasses().getObjectClass().rbPrivate(args); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/TopSelfFactory.java/buggy/src/org/jruby/TopSelfFactory.java
u.p("really starting new thread"); u.p("threaded = " + threaded);
public synchronized void startLayout(Graphics g) { if(isLayoutDone()) { u.p("really starting new thread"); u.p("threaded = " + threaded); done = false; graphics = g; if(threaded) { new Thread(this).start(); } else { run(); } } else { //u.p("layout already in progress. skipping layout"); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/3c2f0ef16203d2439d43879f53050721938d14f5/LayoutThread.java/clean/src/java/org/xhtmlrenderer/swing/LayoutThread.java
public synchronized void startRender(Graphics g) { g.setColor(Color.black); if(this.isLayoutDone()) { if(panel.body_box != null) { //u.p("really painting: " + panel.body_box); try { panel.doRender(); } catch (Throwable thr) { u.p("current thread = " + Thread.currentThread()); u.p(thr); thr.printStackTrace(); } } else { g.drawString("body box is null", 50,50); u.p("body box is null"); } } else { g.drawString("still doing layout", 50,50); //u.p("still doing layout"); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/3c2f0ef16203d2439d43879f53050721938d14f5/LayoutThread.java/clean/src/java/org/xhtmlrenderer/swing/LayoutThread.java
protected void startLayout(Graphics g) {
public void startLayout(Graphics g) {
protected void startLayout(Graphics g) { this.removeAll(); if ( g == null ) { return; } if ( doc == null ) { return; } Element html = (Element)doc.getDocumentElement(); //Element body = x.child( html, "body" ); //body = html; // set up CSS newContext( g ); getContext().setMaxWidth( 0 ); //long start_time = new java.util.Date().getTime(); //u.p("layout = " + layout); body_box = layout.layout( getContext(), html ); //u.p("is a fixed child: " + body_box.isChildrenExceedBounds()); // if there is a fixed child then we need to set opaque to false // so that the entire viewport will be repainted. this is slower // but that's the hit you get from using fixed layout if(body_box.isChildrenExceedBounds()) { setOpaque(false); } getRenderingContext().root_box = body_box; //u.p("after layout: " + body_box); //long end_time = new java.util.Date().getTime(); if ( enclosingScrollPane != null ) { if ( this.body_box != null ) { this.enclosingScrollPane.getViewport().setBackground( body_box.background_color ); } } intrinsic_size = new Dimension( getContext().getMaxWidth(), layout.contents_height ); if(enclosingScrollPane != null) { //u.p("enclosing scroll pane = " + this.enclosingScrollPane); int view_height = this.enclosingScrollPane.getViewport().getHeight(); // resize the outter most box incase it is too small for the viewport if(intrinsic_size.getHeight() < view_height) { if(body_box != null) { body_box.height = view_height; } } } if ( !intrinsic_size.equals( this.getSize() ) ) { this.setPreferredSize( intrinsic_size ); this.revalidate(); } this.fireDocumentLoaded(); }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/040a341c611461667189a970db0e981b4033ce96/HTMLPanel.java/buggy/src/java/org/xhtmlrenderer/swing/HTMLPanel.java
public void doRender() {
protected void doRender() {
public void doRender() { layout.getRenderer().paint( getRenderingContext().getContext(), body_box ); }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/040a341c611461667189a970db0e981b4033ce96/HTMLPanel.java/buggy/src/java/org/xhtmlrenderer/swing/HTMLPanel.java
info.setInlineBox(currentIB);
private static InlineBox addNestedInlineBoxes(LayoutContext c, LineBox line, List elementStack, int cbWidth) { InlineBox currentIB = null; InlineBox previousIB = null; boolean first = true; for (Iterator i = elementStack.iterator(); i.hasNext();) { InlineBoxInfo info = (InlineBoxInfo) i.next(); currentIB = info.getInlineBox().copyOf(); // :first-line transition if (info.getCalculatedStyle() != null) { currentIB.setStyle(new Style(info.getCalculatedStyle(), cbWidth)); currentIB.calculateHeight(c); info.setCalculatedStyle(null); } if (first) { line.addChild(c, currentIB); first = false; } else { previousIB.addInlineChild(c, currentIB, false); } previousIB = currentIB; } return currentIB; }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/896815046512a694d058c8675cf95500abc248aa/InlineBoxing.java/clean/src/java/org/xhtmlrenderer/layout/InlineBoxing.java
if (currentLine.isFirstLine() && hasFirstLinePCs) { lbContext.setMaster(TextUtil.transformText( text.getText(), c.getCurrentStyle())); }
public static void layoutContent(LayoutContext c, Box box, List contentList) { int maxAvailableWidth = c.getExtents().width; int remainingWidth = maxAvailableWidth; int minimumLineHeight = (int) c.getCurrentStyle().getLineHeight(c); LineBox currentLine = newLine(c, null, box); LineBox previousLine = null; InlineBox currentIB = null; InlineBox previousIB = null; List elementStack = new ArrayList(); if (box instanceof AnonymousBlockBox) { List pending = ((BlockBox) box.getParent()).getPendingInlineElements(); if (pending != null) { currentIB = addNestedInlineBoxes(c, currentLine, pending, maxAvailableWidth); elementStack = pending; } } CalculatedStyle parentStyle = c.getCurrentStyle(); int indent = (int) parentStyle.getFloatPropertyProportionalWidth(CSSName.TEXT_INDENT, maxAvailableWidth, c); remainingWidth -= indent; currentLine.x = indent; if (!box.getStyle().isCleared()) { remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth); } List pendingFloats = new ArrayList(); int pendingLeftMBP = 0; int pendingRightMBP = 0; boolean hasFirstLinePCs = false; if (c.getFirstLinesTracker().hasStyles()) { c.getFirstLinesTracker().pushStyles(c); hasFirstLinePCs = true; } boolean needFirstLetter = c.getFirstLettersTracker().hasStyles(); for (int i = 0; i < contentList.size(); i++) { Object o = contentList.get(i); if (o instanceof FirstLineStyle || o instanceof FirstLetterStyle) { continue; } if (o instanceof StylePush) { StylePush sp = (StylePush) o; CascadedStyle cascaded = sp.getStyle(c); c.pushStyle(cascaded); CalculatedStyle style = c.getCurrentStyle(); previousIB = currentIB; currentIB = new InlineBox(sp.getElement(), style, maxAvailableWidth); currentIB.calculateHeight(c); elementStack.add(new InlineBoxInfo(cascaded, currentIB)); if (previousIB == null) { currentLine.addChild(c, currentIB); } else { previousIB.addInlineChild(c, currentIB); } //To break the line well, assume we don't just want to paint padding on next line pendingLeftMBP += style.getLeftMarginBorderPadding(c, maxAvailableWidth); pendingRightMBP += style.getRightMarginBorderPadding(c, maxAvailableWidth); continue; } if (o instanceof StylePop) { CalculatedStyle style = c.getCurrentStyle(); int rightMBP = style.getRightMarginBorderPadding(c, maxAvailableWidth); pendingRightMBP -= rightMBP; remainingWidth -= rightMBP; elementStack.remove(elementStack.size() - 1); currentIB.setEndsHere(true); if (currentIB.getStyle().requiresLayer()) { if (currentIB.element == null || currentIB.element != c.getLayer().getMaster().element) { throw new RuntimeException("Check this..."); } c.getLayer().setEnd(currentIB); c.popLayer(); } previousIB = currentIB; currentIB = currentIB.getParent() instanceof LineBox ? null : (InlineBox) currentIB.getParent(); c.popStyle(); continue; } Content content = (Content) o; if (mustBeTakenOutOfFlow(content)) { processOutOfFlowContent(c, content, currentLine, remainingWidth, pendingFloats); } else if (isInlineBlock(content)) { Box inlineBlock = layoutInlineBlock(c, box, content); if (inlineBlock.getWidth() > remainingWidth && currentLine.isContainsContent()) { saveLine(currentLine, previousLine, c, box, minimumLineHeight, maxAvailableWidth, elementStack, pendingFloats, hasFirstLinePCs); previousLine = currentLine; currentLine = newLine(c, previousLine, box); currentIB = addNestedInlineBoxes(c, currentLine, elementStack, maxAvailableWidth); previousIB = currentIB == null || currentIB.getParent() instanceof LineBox ? null : (InlineBox) currentIB.getParent(); remainingWidth = maxAvailableWidth; if (!box.getStyle().isCleared()) { remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth); } if (inlineBlock.getLayer() != null) { inlineBlock.getLayer().detach(); } inlineBlock = layoutInlineBlock(c, box, content); } if (currentIB == null) { currentLine.addChild(c, inlineBlock); } else { currentIB.addInlineChild(c, inlineBlock); } currentLine.setContainsContent(true); currentLine.setContainsBlockLevelContent(true); remainingWidth -= inlineBlock.getWidth(); needFirstLetter = false; } else { TextContent text = (TextContent) content; LineBreakContext lbContext = new LineBreakContext(); lbContext.setMaster(TextUtil.transformText(text.getText(), c.getCurrentStyle())); do { lbContext.reset(); int fit = 0; if (lbContext.getStart() == 0) { fit += pendingLeftMBP; } if (hasTrimmableLeadingSpace(currentLine, c.getCurrentStyle(), lbContext)) { lbContext.setStart(lbContext.getStart() + 1); } if (needFirstLetter && !lbContext.isFinished()) { InlineBox firstLetter = addFirstLetterBox(c, currentLine, currentIB, lbContext, maxAvailableWidth, remainingWidth); remainingWidth -= firstLetter.getInlineWidth(); needFirstLetter = false; } else { lbContext.saveEnd(); InlineText inlineText = layoutText( c, remainingWidth - fit, lbContext, false); if (!lbContext.isUnbreakable() || (lbContext.isUnbreakable() && ! currentLine.isContainsContent())) { currentIB.addInlineChild(c, inlineText); currentLine.setContainsContent(true); lbContext.setStart(lbContext.getEnd()); remainingWidth -= inlineText.getWidth(); } else { lbContext.resetEnd(); } } if (lbContext.isNeedsNewLine()) { saveLine(currentLine, previousLine, c, box, minimumLineHeight, maxAvailableWidth, elementStack, pendingFloats, hasFirstLinePCs); previousLine = currentLine; currentLine = newLine(c, previousLine, box); currentIB = addNestedInlineBoxes(c, currentLine, elementStack, maxAvailableWidth); previousIB = currentIB.getParent() instanceof LineBox ? null : (InlineBox) currentIB.getParent(); remainingWidth = maxAvailableWidth; if (!box.getStyle().isCleared()) { remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth); } } } while (!lbContext.isFinished()); } } saveLine(currentLine, previousLine, c, box, minimumLineHeight, maxAvailableWidth, elementStack, pendingFloats, hasFirstLinePCs); if (box instanceof AnonymousBlockBox) { ((BlockBox) box.getParent()).setPendingInlineElements(elementStack.size() == 0 ? null : elementStack); } if (!c.shrinkWrap()) box.contentWidth = maxAvailableWidth; box.setHeight(currentLine.y + currentLine.getHeight()); }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/896815046512a694d058c8675cf95500abc248aa/InlineBoxing.java/clean/src/java/org/xhtmlrenderer/layout/InlineBoxing.java
System.out.println(""+isChecked());
view.setShowHeartbeats(isChecked());
public void run() { System.out.println(""+isChecked()); }
52787 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52787/baf951cf5ccda70586b4d9ffdcb6835d0bcfe319/ShowHeartbeatsAction.java/clean/source/trunk/plugins/org.marketcetera.photon/src/main/java/org/marketcetera/photon/actions/ShowHeartbeatsAction.java
needsRestart |= !Util.equals(locale.getLanguage(), Translation .getActiveLocale().getLanguage());
needsRestart |= !Util.equals(locale, Translation.getActiveLocale());
public void save() { // Write properties into core writeTrigger.triggerCommit(); // Set locale if (languageChooser.getSelectedItem() instanceof Locale) { Locale locale = (Locale) languageChooser.getSelectedItem(); // Check if we need to restart needsRestart |= !Util.equals(locale.getLanguage(), Translation .getActiveLocale().getLanguage()); // Save settings Translation.saveLocalSetting(locale); } else { // Remove setting Translation.saveLocalSetting(null); } // Set folder base String folderbase = (String) localBaseHolder.getValue(); ConfigurationEntry.FOLDER_BASEDIR.setValue(getController(), folderbase); // Store ui theme if (UIManager.getLookAndFeel() instanceof PlasticXPLookAndFeel) { PlasticTheme theme = PlasticXPLookAndFeel.getPlasticTheme(); PreferencesEntry.UI_COLOUR_THEME.setValue(getController(), theme.getClass().getName()); if (!Util.equals(theme, oldTheme)) { // FIXME: Themechange does not repaint SimpleInternalFrames. // thus restart required needsRestart = true; } } // Nickname if (!StringUtils.isBlank(nickField.getText())) { getController().changeNick(nickField.getText(), false); } // setAdvanced PreferencesEntry.SHOW_ADVANCED_SETTINGS.setValue(getController(), showAdvancedSettingsBox.isSelected()); }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/77b577b2e8f30cae24327d6a2981376708ffddb6/GeneralSettingsTab.java/buggy/src/main/de/dal33t/powerfolder/ui/preferences/GeneralSettingsTab.java
getQuoteJmsTemplate().convertAndSend(quoteMessage);
getQuoteJmsOperations().convertAndSend(quoteMessage);
public void simulateQuote(MSymbol symbol) { MarketDataSnapshotFullRefresh quoteMessage = new MarketDataSnapshotFullRefresh(); quoteMessage.setField(new Symbol(symbol.getBaseSymbol())); //agl not setting any other fields as only care about the symbol for mocking getQuoteJmsTemplate().convertAndSend(quoteMessage); }
52787 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52787/ba5aa8e52b830c2120eb01f3cd9004890ae578e2/MockQuoteFeed.java/buggy/source/trunk/plugins/org.marketcetera.photon.tests/src/test/java/org/marketcetera/photon/scripting/MockQuoteFeed.java
MessageHolder latestMessage = null; for (MessageHolder holder : messages) { Message message = holder.getMessage(); if (filter(holder)) {
MessageHolder latestMessageHolder = null; for (MessageHolder loopMessageHolder : messages) { if (filter(loopMessageHolder)) {
public MessageHolder evaluate(List<MessageHolder> messages) { MessageHolder latestMessage = null; for (MessageHolder holder : messages) { Message message = holder.getMessage(); if (filter(holder)) { try { if (latestMessage == null){ latestMessage = holder; } else { Date newTime = message.getUtcTimeStamp(TransactTime.FIELD); Date existingTime = latestMessage.getMessage().getUtcTimeStamp(TransactTime.FIELD); int compareVal = newTime.compareTo(existingTime); if (compareVal > 0 || (compareVal == 0 && holder.getMessageReference() > latestMessage.getMessageReference())) { latestMessage = holder; } } } catch (FieldNotFound fnf){ // do nothing } } } return latestMessage; }
52787 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52787/48153406f5051ec752935487d4f294d7298761d8/LatestMessageFunction.java/buggy/source/trunk/src/main/java/org/marketcetera/photon/editors/LatestMessageFunction.java
if (latestMessage == null){ latestMessage = holder;
if (latestMessageHolder == null){ latestMessageHolder = loopMessageHolder;
public MessageHolder evaluate(List<MessageHolder> messages) { MessageHolder latestMessage = null; for (MessageHolder holder : messages) { Message message = holder.getMessage(); if (filter(holder)) { try { if (latestMessage == null){ latestMessage = holder; } else { Date newTime = message.getUtcTimeStamp(TransactTime.FIELD); Date existingTime = latestMessage.getMessage().getUtcTimeStamp(TransactTime.FIELD); int compareVal = newTime.compareTo(existingTime); if (compareVal > 0 || (compareVal == 0 && holder.getMessageReference() > latestMessage.getMessageReference())) { latestMessage = holder; } } } catch (FieldNotFound fnf){ // do nothing } } } return latestMessage; }
52787 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52787/48153406f5051ec752935487d4f294d7298761d8/LatestMessageFunction.java/buggy/source/trunk/src/main/java/org/marketcetera/photon/editors/LatestMessageFunction.java
Date newTime = message.getUtcTimeStamp(TransactTime.FIELD); Date existingTime = latestMessage.getMessage().getUtcTimeStamp(TransactTime.FIELD); int compareVal = newTime.compareTo(existingTime); if (compareVal > 0 || (compareVal == 0 && holder.getMessageReference() > latestMessage.getMessageReference())) { latestMessage = holder;
if (isLater(loopMessageHolder, latestMessageHolder)){ latestMessageHolder = loopMessageHolder;
public MessageHolder evaluate(List<MessageHolder> messages) { MessageHolder latestMessage = null; for (MessageHolder holder : messages) { Message message = holder.getMessage(); if (filter(holder)) { try { if (latestMessage == null){ latestMessage = holder; } else { Date newTime = message.getUtcTimeStamp(TransactTime.FIELD); Date existingTime = latestMessage.getMessage().getUtcTimeStamp(TransactTime.FIELD); int compareVal = newTime.compareTo(existingTime); if (compareVal > 0 || (compareVal == 0 && holder.getMessageReference() > latestMessage.getMessageReference())) { latestMessage = holder; } } } catch (FieldNotFound fnf){ // do nothing } } } return latestMessage; }
52787 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52787/48153406f5051ec752935487d4f294d7298761d8/LatestMessageFunction.java/buggy/source/trunk/src/main/java/org/marketcetera/photon/editors/LatestMessageFunction.java
return latestMessage;
return latestMessageHolder;
public MessageHolder evaluate(List<MessageHolder> messages) { MessageHolder latestMessage = null; for (MessageHolder holder : messages) { Message message = holder.getMessage(); if (filter(holder)) { try { if (latestMessage == null){ latestMessage = holder; } else { Date newTime = message.getUtcTimeStamp(TransactTime.FIELD); Date existingTime = latestMessage.getMessage().getUtcTimeStamp(TransactTime.FIELD); int compareVal = newTime.compareTo(existingTime); if (compareVal > 0 || (compareVal == 0 && holder.getMessageReference() > latestMessage.getMessageReference())) { latestMessage = holder; } } } catch (FieldNotFound fnf){ // do nothing } } } return latestMessage; }
52787 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52787/48153406f5051ec752935487d4f294d7298761d8/LatestMessageFunction.java/buggy/source/trunk/src/main/java/org/marketcetera/photon/editors/LatestMessageFunction.java
ib.setParent(this);
public void addInlineChild(Context c, InlineBox ib) { if (ib == null) { throw new NullPointerException("trying to add null child"); } if (getChildCount() == 0 && ib instanceof InlineTextBox) {//first box on line InlineTextBox child = (InlineTextBox) ib; if (child.getSubstring().equals("")) { child.contentWidth = 0; child.height = 0; } } ib.setParent(this); addChild(ib); if (ib.isChildrenExceedBounds()) { setChildrenExceedBounds(true); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/2486e0a7d32e8bf7a5ba0aa3c3626b52ad12da3c/LineBox.java/buggy/src/java/org/xhtmlrenderer/render/LineBox.java
if (ib.isChildrenExceedBounds()) { setChildrenExceedBounds(true); }
Boxing.checkExceeds(ib); propagateChildProperties(ib);
public void addInlineChild(Context c, InlineBox ib) { if (ib == null) { throw new NullPointerException("trying to add null child"); } if (getChildCount() == 0 && ib instanceof InlineTextBox) {//first box on line InlineTextBox child = (InlineTextBox) ib; if (child.getSubstring().equals("")) { child.contentWidth = 0; child.height = 0; } } ib.setParent(this); addChild(ib); if (ib.isChildrenExceedBounds()) { setChildrenExceedBounds(true); } }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/2486e0a7d32e8bf7a5ba0aa3c3626b52ad12da3c/LineBox.java/buggy/src/java/org/xhtmlrenderer/render/LineBox.java
super(runtime, (RubyClass) runtime.getClasses().getClassFromPath("Java::JavaClass"), javaClass);
super(runtime, (RubyClass) runtime.getModule("Java").getClass("JavaClass"), javaClass);
private JavaClass(Ruby runtime, Class javaClass) { super(runtime, (RubyClass) runtime.getClasses().getClassFromPath("Java::JavaClass"), javaClass); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/JavaClass.java/clean/src/org/jruby/javasupport/JavaClass.java
RubyClass result = javaModule.defineClassUnder("JavaClass", runtime.getClasses().getJavaObjectClass());
RubyClass result = javaModule.defineClassUnder("JavaClass", runtime.getClass("JavaObject"));
public static RubyClass createJavaClassClass(Ruby runtime, RubyModule javaModule) { RubyClass result = javaModule.defineClassUnder("JavaClass", runtime.getClasses().getJavaObjectClass()); CallbackFactory callbackFactory = runtime.callbackFactory(JavaClass.class); result.includeModule(runtime.getClasses().getComparableModule()); JavaObject.registerRubyMethods(runtime, result); result.defineSingletonMethod("for_name", callbackFactory.getSingletonMethod("for_name", IRubyObject.class)); result.defineMethod("public?", callbackFactory.getMethod("public_p")); result.defineMethod("protected?", callbackFactory.getMethod("protected_p")); result.defineMethod("private?", callbackFactory.getMethod("private_p")); result.defineMethod("final?", callbackFactory.getMethod("final_p")); result.defineMethod("interface?", callbackFactory.getMethod("interface_p")); result.defineMethod("array?", callbackFactory.getMethod("array_p")); result.defineMethod("name", callbackFactory.getMethod("name")); result.defineMethod("to_s", callbackFactory.getMethod("name")); result.defineMethod("superclass", callbackFactory.getMethod("superclass")); result.defineMethod("<=>", callbackFactory.getMethod("op_cmp", IRubyObject.class)); result.defineMethod("java_instance_methods", callbackFactory.getMethod("java_instance_methods")); result.defineMethod("java_class_methods", callbackFactory.getMethod("java_class_methods")); result.defineMethod("java_method", callbackFactory.getOptMethod("java_method")); result.defineMethod("constructors", callbackFactory.getMethod("constructors")); result.defineMethod("constructor", callbackFactory.getOptMethod("constructor")); result.defineMethod("array_class", callbackFactory.getMethod("array_class")); result.defineMethod("new_array", callbackFactory.getMethod("new_array", IRubyObject.class)); result.defineMethod("fields", callbackFactory.getMethod("fields")); result.defineMethod("field", callbackFactory.getMethod("field", IRubyObject.class)); result.defineMethod("interfaces", callbackFactory.getMethod("interfaces")); result.defineMethod("primitive?", callbackFactory.getMethod("primitive_p")); result.defineMethod("assignable_from?", callbackFactory.getMethod("assignable_from_p", IRubyObject.class)); result.defineMethod("component_type", callbackFactory.getMethod("component_type")); result.defineMethod("declared_instance_methods", callbackFactory.getMethod("declared_instance_methods")); result.defineMethod("declared_class_methods", callbackFactory.getMethod("declared_class_methods")); result.defineMethod("declared_fields", callbackFactory.getMethod("declared_fields")); result.defineMethod("declared_field", callbackFactory.getMethod("declared_field", IRubyObject.class)); result.defineMethod("declared_constructors", callbackFactory.getMethod("declared_constructors")); result.defineMethod("declared_constructor", callbackFactory.getOptMethod("declared_constructor")); result.defineMethod("declared_method", callbackFactory.getOptMethod("declared_method")); result.getMetaClass().undefineMethod("new"); return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/JavaClass.java/clean/src/org/jruby/javasupport/JavaClass.java
result.includeModule(runtime.getClasses().getComparableModule());
result.includeModule(runtime.getModule("Comparable"));
public static RubyClass createJavaClassClass(Ruby runtime, RubyModule javaModule) { RubyClass result = javaModule.defineClassUnder("JavaClass", runtime.getClasses().getJavaObjectClass()); CallbackFactory callbackFactory = runtime.callbackFactory(JavaClass.class); result.includeModule(runtime.getClasses().getComparableModule()); JavaObject.registerRubyMethods(runtime, result); result.defineSingletonMethod("for_name", callbackFactory.getSingletonMethod("for_name", IRubyObject.class)); result.defineMethod("public?", callbackFactory.getMethod("public_p")); result.defineMethod("protected?", callbackFactory.getMethod("protected_p")); result.defineMethod("private?", callbackFactory.getMethod("private_p")); result.defineMethod("final?", callbackFactory.getMethod("final_p")); result.defineMethod("interface?", callbackFactory.getMethod("interface_p")); result.defineMethod("array?", callbackFactory.getMethod("array_p")); result.defineMethod("name", callbackFactory.getMethod("name")); result.defineMethod("to_s", callbackFactory.getMethod("name")); result.defineMethod("superclass", callbackFactory.getMethod("superclass")); result.defineMethod("<=>", callbackFactory.getMethod("op_cmp", IRubyObject.class)); result.defineMethod("java_instance_methods", callbackFactory.getMethod("java_instance_methods")); result.defineMethod("java_class_methods", callbackFactory.getMethod("java_class_methods")); result.defineMethod("java_method", callbackFactory.getOptMethod("java_method")); result.defineMethod("constructors", callbackFactory.getMethod("constructors")); result.defineMethod("constructor", callbackFactory.getOptMethod("constructor")); result.defineMethod("array_class", callbackFactory.getMethod("array_class")); result.defineMethod("new_array", callbackFactory.getMethod("new_array", IRubyObject.class)); result.defineMethod("fields", callbackFactory.getMethod("fields")); result.defineMethod("field", callbackFactory.getMethod("field", IRubyObject.class)); result.defineMethod("interfaces", callbackFactory.getMethod("interfaces")); result.defineMethod("primitive?", callbackFactory.getMethod("primitive_p")); result.defineMethod("assignable_from?", callbackFactory.getMethod("assignable_from_p", IRubyObject.class)); result.defineMethod("component_type", callbackFactory.getMethod("component_type")); result.defineMethod("declared_instance_methods", callbackFactory.getMethod("declared_instance_methods")); result.defineMethod("declared_class_methods", callbackFactory.getMethod("declared_class_methods")); result.defineMethod("declared_fields", callbackFactory.getMethod("declared_fields")); result.defineMethod("declared_field", callbackFactory.getMethod("declared_field", IRubyObject.class)); result.defineMethod("declared_constructors", callbackFactory.getMethod("declared_constructors")); result.defineMethod("declared_constructor", callbackFactory.getOptMethod("declared_constructor")); result.defineMethod("declared_method", callbackFactory.getOptMethod("declared_method")); result.getMetaClass().undefineMethod("new"); return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/JavaClass.java/clean/src/org/jruby/javasupport/JavaClass.java
throw getRuntime().newTypeError(lengthArgument, getRuntime().getClasses().getIntegerClass());
throw getRuntime().newTypeError(lengthArgument, getRuntime().getClass("Integer"));
public JavaObject new_array(IRubyObject lengthArgument) { if (! (lengthArgument instanceof RubyInteger)) { throw getRuntime().newTypeError(lengthArgument, getRuntime().getClasses().getIntegerClass()); } int length = (int) ((RubyInteger) lengthArgument).getLongValue(); return new JavaArray(getRuntime(), Array.newInstance(javaClass(), length)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/JavaClass.java/clean/src/org/jruby/javasupport/JavaClass.java
return ph.getLexState() == LexState.EXPR_ARG || ph.getLexState() == LexState.EXPR_CMDARG;
return ph.getLexState() == LexState.EXPR_ARG;
private boolean IS_ARG() { return ph.getLexState() == LexState.EXPR_ARG || ph.getLexState() == LexState.EXPR_CMDARG; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
ph.setCommandStart(true);
public NODE yycompile(String f, int line) { RubyId sl_id = ruby.intern("SCRIPT_LINES__"); if (!ph.isCompileForEval() && ruby.getSecurityLevel() == 0 && ruby.getClasses().getObjectClass().isConstantDefined(sl_id)) { RubyHash hash = (RubyHash)ruby.getClasses().getObjectClass().getConstant(sl_id); RubyString fName = RubyString.m_newString(ruby, f); // XXX +++ RubyObject debugLines = ruby.getNil(); // = rb_hash_aref(hash, fName); // XXX --- if (debugLines.isNil()) { ph.setRubyDebugLines(RubyArray.m_newArray(ruby)); hash.m_aset(fName, ph.getRubyDebugLines()); } else { ph.setRubyDebugLines((RubyArray)debugLines); } if (line > 1) { RubyString str = RubyString.m_newString(ruby, null); while (line > 1) { ph.getRubyDebugLines().m_push(str); line--; } } } ph.setRubyEndSeen(false); // is there an __end__{} statement? ph.setEvalTree(null); // parser stores NODEs here ph.setHeredocEnd(0); ruby.setSourceFile(f); // source file name ph.setRubyInCompile(true); try { yyparse(new yyInput() { public boolean advance() throws IOException { return DefaultRubyParser.this.advance(); } public int token() { return DefaultRubyParser.this.token(); } public Object value() { return DefaultRubyParser.this.value(); } }, null); } catch (Exception e) { e.printStackTrace(); } ph.setRubyDebugLines(null); // remove debug info ph.setCompileForEval(0); ph.setRubyInCompile(false); cond_stack = 0; // reset stuff for next compile cmdarg_stack = 0; // reset stuff for next compile ph.setCommandStart(true); // reset stuff for next compile ph.setClassNest(0); ph.setInSingle(0); ph.setInDef(0); ph.setCurMid(null); return ph.getEvalTree(); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
boolean space_seen = false; boolean cmd_state;
int space_seen = 0;
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
cmd_state = ph.isCommandStart(); ph.setCommandStart(false);
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
space_seen = true;
space_seen++;
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
ph.setCommandStart(true);
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (IS_ARG() && space_seen && !ISSPACE(c)) {
if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
(!IS_ARG() || space_seen)) {
(!IS_ARG() || space_seen != 0)) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG) {
if (ph.getLexState() == LexState.EXPR_END) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (IS_ARG() && space_seen && !ISSPACE(c)) {
if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
(IS_ARG() && space_seen && !ISSPACE(c))) {
(IS_ARG() && space_seen != 0 && !ISSPACE(c))) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
(IS_ARG() && space_seen && !ISSPACE(c))) {
(IS_ARG() && space_seen != 0 && !ISSPACE(c))) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
(IS_ARG() && space_seen)) {
(IS_ARG() && space_seen != 0)) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || ISSPACE(c)) {
if (ph.getLexState() == LexState.EXPR_END || ISSPACE(c)) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (IS_ARG() && space_seen) {
if (IS_ARG() && space_seen != 0) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
} else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; }
} else if (ph.getLexState() == LexState.EXPR_ARG && space_seen != 0) { ph.rb_warning(tok() + " (...) interpreted as method call");
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
} else if (IS_ARG() && space_seen) {
} else if (IS_ARG() && space_seen != 0) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; }
if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ARG) { c = Token.tLBRACE;
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
space_seen = true; continue retry;
space_seen = 1; continue retry;
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (IS_ARG() && space_seen && !ISSPACE(c)) {
if (IS_ARG() && space_seen != 0 && !ISSPACE(c)) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
/* * xxx shouldn't check if valid option variable */
/* xxx shouldn't check if valid option variable */
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
case '&': case '`': case '\'': case '+':
case '&': case '`': case '\'': case '+':
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
if (CMDARG_P() && state != LexState.EXPR_CMDARG) {
if (CMDARG_P()) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
ph.getLexState() == LexState.EXPR_ARG || ph.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else {
ph.getLexState() == LexState.EXPR_ARG) {
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
}
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
yyVal = /* last_id = */ ruby.intern(tok());
yyVal = ruby.intern(tok());
private int yylex() { int c; boolean space_seen = false; boolean cmd_state; kwtable kw; cmd_state = ph.isCommandStart(); ph.setCommandStart(false); 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 = true; 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.setCommandStart(true); 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 && !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)) { 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.getLexState() == LexState.EXPR_ENDARG) { 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.m_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 && !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 && !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 && !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)) { ph.setLexState(LexState.EXPR_BEG); return Token.tCOLON3; } ph.setLexState(LexState.EXPR_DOT); return Token.tCOLON2; } pushback(c); if (ph.getLexState() == LexState.EXPR_END || ph.getLexState() == LexState.EXPR_ENDARG || 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) { 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.setCommandStart(true); 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; } // ph.setCommandStart(true); if (ph.getLexState() == LexState.EXPR_BEG || ph.getLexState() == LexState.EXPR_MID) { c = Token.tLPAREN; } else if (space_seen) { if (ph.getLexState() == LexState.EXPR_CMDARG) { c = Token.tLPAREN_ARG; } else if (ph.getLexState() == LexState.EXPR_ARG) { ph.rb_warning(tok() + " (...) interpreted as method call"); c = Token.tLPAREN_ARG; } } 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) { c = Token.tLBRACK; } ph.setLexState(LexState.EXPR_BEG); return c; case '{': if (!IS_ARG()) { if (space_seen && ph.getLexState() == LexState.EXPR_ENDARG) { c = Token.tLBRACE_ARG; } if (ph.getLexState() != LexState.EXPR_END && ph.getLexState() != LexState.EXPR_ENDARG) { c = Token.tLBRACE; } } ph.setLexState(LexState.EXPR_BEG); return c; case '\\': c = nextc(); if (c == '\n') { space_seen = true; 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 && !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.local_cnt(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 = ruby.intern(tok()); return Token.tGVAR; case '-': tokadd('$'); tokadd(c); c = nextc(); tokadd(c); tokfix(); yyVal = 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); /* * if (ismbchar(c)) { * int i, len = mbclen(c)-1; * for (i = 0; i < len; i++) { * c = nextc(); * 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 = ruby.intern(kw.name); } if (kw.id0 == Token.kDO) { if (COND_P()) { return Token.kDO_COND; } if (CMDARG_P() && state != LexState.EXPR_CMDARG) { 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.getLexState() == LexState.EXPR_CMDARG) { if (cmd_state) { ph.setLexState(LexState.EXPR_CMDARG); } else { ph.setLexState(LexState.EXPR_ARG); } } else { ph.setLexState(LexState.EXPR_END); } } tokfix(); yyVal = /* last_id = */ ruby.intern(tok()); //XXX really overwrite last_id? return result; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/75e51682c6dfb1ff67ffb81cea2dfd23c3e3a9f4/DefaultRubyParser.java/buggy/org/jruby/parser/DefaultRubyParser.java
IMarker[] markers = getSelectedMarkers(selection); for (int i = 0; i < markers.length; i++) { if (IDE.getMarkerHelpRegistry().hasResolutions(markers[i])) {
if(Util.isSingleConcreteSelection(selection)){ if(IDE.getMarkerHelpRegistry().hasResolutions(getSelectedMarker())){
public void selectionChanged(IStructuredSelection selection) { IMarker[] markers = getSelectedMarkers(selection); for (int i = 0; i < markers.length; i++) { if (IDE.getMarkerHelpRegistry().hasResolutions(markers[i])) { setEnabled(true); return; } } setEnabled(false); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/7dbbcd197c4d9896669ffabd778f42aee079a909/ActionResolveMarker.java/buggy/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ActionResolveMarker.java
public void selectionChanged(IStructuredSelection selection) { IMarker[] markers = getSelectedMarkers(selection); for (int i = 0; i < markers.length; i++) { if (IDE.getMarkerHelpRegistry().hasResolutions(markers[i])) { setEnabled(true); return; } } setEnabled(false); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/7dbbcd197c4d9896669ffabd778f42aee079a909/ActionResolveMarker.java/buggy/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ActionResolveMarker.java
buildPreference = new Button(parent, SWT.CHECK); buildPreference.setText("Restore 2.1 rebuild actions for this session"); buildPreference.setSelection(WorkbenchActionBuilder.INCLUDE_REBUILD_ACTIONS); buildPreference.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { WorkbenchActionBuilder.setIncludeRebuildActions(buildPreference.getSelection()); } }); }
buildPreference = new Button(parent, SWT.CHECK | SWT.TOP); buildPreference.setText("Restore 2.1 rebuild actions for this session"); buildPreference .setSelection(WorkbenchActionBuilder.INCLUDE_REBUILD_ACTIONS); buildPreference.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { WorkbenchActionBuilder.setIncludeRebuildActions(buildPreference .getSelection()); } }); }
private void createBuildControls(Composite parent) { buildPreference = new Button(parent, SWT.CHECK); buildPreference.setText("Restore 2.1 rebuild actions for this session"); //$NON-NLS-1$ buildPreference.setSelection(WorkbenchActionBuilder.INCLUDE_REBUILD_ACTIONS); buildPreference.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { WorkbenchActionBuilder.setIncludeRebuildActions(buildPreference.getSelection()); } }); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
WorkbenchActionBuilder.setIncludeRebuildActions(buildPreference.getSelection()); }
WorkbenchActionBuilder.setIncludeRebuildActions(buildPreference .getSelection()); }
public void widgetSelected(SelectionEvent e) { WorkbenchActionBuilder.setIncludeRebuildActions(buildPreference.getSelection()); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
createBuildControls(parent); createRefreshControls(parent); return parent; }
Composite spacer = new Composite(parent,SWT.NONE); createBuildControls(spacer); GridData spacerData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); spacer.setLayoutData(spacerData); spacer.setLayout(new GridLayout()); return spacer; }
protected Control createContents(Composite parent) { createBuildControls(parent); createRefreshControls(parent); return parent; }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
}
}
public void init(IWorkbench workbench) { //Nothing to do here }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
slider.setSelection(FAST); setLabelText(FAST); boolean autoRefresh = ResourcesPlugin.getPlugin().getPluginPreferences().getDefaultBoolean( ResourcesPlugin.PREF_AUTO_REFRESH); autoRefreshButton.setSelection(autoRefresh); pollingRefreshText.setEnabled(autoRefresh); pollingRefreshText.setText( ResourcesPlugin.getPlugin().getPluginPreferences().getDefaultString( ResourcesPlugin.PREF_REFRESH_POLLING_DELAY)); }
setLabelText(FAST); }
protected void performDefaults() { slider.setSelection(FAST); setLabelText(FAST); boolean autoRefresh = ResourcesPlugin.getPlugin().getPluginPreferences().getDefaultBoolean( ResourcesPlugin.PREF_AUTO_REFRESH); autoRefreshButton.setSelection(autoRefresh); pollingRefreshText.setEnabled(autoRefresh); pollingRefreshText.setText( ResourcesPlugin.getPlugin().getPluginPreferences().getDefaultString( ResourcesPlugin.PREF_REFRESH_POLLING_DELAY)); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
Platform.getPlugin(Platform.PI_RUNTIME).getPluginPreferences().setValue( Platform.PREF_PLATFORM_PERFORMANCE, slider.getSelection()); Platform.getPlugin(Platform.PI_RUNTIME).savePluginPreferences();
Platform.getPlugin(Platform.PI_RUNTIME).savePluginPreferences();
public boolean performOk() { Platform.getPlugin(Platform.PI_RUNTIME).getPluginPreferences().setValue( Platform.PREF_PLATFORM_PERFORMANCE, slider.getSelection()); Platform.getPlugin(Platform.PI_RUNTIME).savePluginPreferences(); Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); boolean autoRefresh = autoRefreshButton.getSelection(); preferences.setValue(ResourcesPlugin.PREF_AUTO_REFRESH, autoRefresh); if (autoRefresh) { preferences.setValue( ResourcesPlugin.PREF_REFRESH_POLLING_DELAY, pollingRefreshText.getText()); } return super.performOk(); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); boolean autoRefresh = autoRefreshButton.getSelection(); preferences.setValue(ResourcesPlugin.PREF_AUTO_REFRESH, autoRefresh); if (autoRefresh) { preferences.setValue( ResourcesPlugin.PREF_REFRESH_POLLING_DELAY, pollingRefreshText.getText()); } return super.performOk(); }
return super.performOk(); }
public boolean performOk() { Platform.getPlugin(Platform.PI_RUNTIME).getPluginPreferences().setValue( Platform.PREF_PLATFORM_PERFORMANCE, slider.getSelection()); Platform.getPlugin(Platform.PI_RUNTIME).savePluginPreferences(); Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); boolean autoRefresh = autoRefreshButton.getSelection(); preferences.setValue(ResourcesPlugin.PREF_AUTO_REFRESH, autoRefresh); if (autoRefresh) { preferences.setValue( ResourcesPlugin.PREF_REFRESH_POLLING_DELAY, pollingRefreshText.getText()); } return super.performOk(); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
String string; switch (value) { case SLOW : string = WorkInProgressMessages.getString("WorkInProgressPreferencePage.SlowTitle"); break; case FAST : string = WorkInProgressMessages.getString("WorkInProgressPreferencePage.FastTitle"); break; default : string = WorkInProgressMessages.getString("WorkInProgressPreferencePage.MediumTitle"); } displayLabel.setText(string); displayLabel.redraw(); }
String string; switch (value) { case SLOW: string = WorkInProgressMessages .getString("WorkInProgressPreferencePage.SlowTitle"); break; case FAST: string = WorkInProgressMessages .getString("WorkInProgressPreferencePage.FastTitle"); break; default: string = WorkInProgressMessages .getString("WorkInProgressPreferencePage.MediumTitle"); } displayLabel.setText(string); displayLabel.redraw(); }
protected void setLabelText(int value) { String string; switch (value) { case SLOW : string = WorkInProgressMessages.getString("WorkInProgressPreferencePage.SlowTitle"); //$NON-NLS-1$ break; case FAST : string = WorkInProgressMessages.getString("WorkInProgressPreferencePage.FastTitle"); //$NON-NLS-1$ break; default : string = WorkInProgressMessages.getString("WorkInProgressPreferencePage.MediumTitle"); //$NON-NLS-1$ } displayLabel.setText(string); displayLabel.redraw(); }
57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/d9f077f11edb05a527f887adc8741e37bc3a1982/WorkInProgressPreferencePage.java/clean/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/WorkInProgressPreferencePage.java
getExtents().width - (margin.left + border.left + padding.left) - (margin.right + border.right + padding.right), getExtents().height - (margin.top + border.top + padding.top) - (margin.bottom + border.bottom + padding.bottom));
getExtents().width - block.totalHorizontalPadding(), getExtents().height - block.totalVerticalPadding() );
public void shrinkExtents(Box block) { extents_stack.push(getExtents()); Border border = block.border; Border padding = block.padding; Border margin = block.margin; Rectangle rect = new Rectangle(0, 0, getExtents().width - (margin.left + border.left + padding.left) - (margin.right + border.right + padding.right), getExtents().height - (margin.top + border.top + padding.top) - (margin.bottom + border.bottom + padding.bottom)); setExtents(rect); }
57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/4ec75287ffc45886f71dceab6cc12aeaa9033bd5/Context.java/buggy/src/java/org/xhtmlrenderer/layout/Context.java
setModified(true);
public void setCategoryId(String categoryId) { if (((categoryId == null) && (_categoryId != null)) || ((categoryId != null) && (_categoryId == null)) || ((categoryId != null) && (_categoryId != null) && !categoryId.equals(_categoryId))) { if (!XSS_ALLOW_CATEGORYID) { categoryId = XSSUtil.strip(categoryId); } _categoryId = categoryId; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setCompanyId(String companyId) { if (((companyId == null) && (_companyId != null)) || ((companyId != null) && (_companyId == null)) || ((companyId != null) && (_companyId != null) && !companyId.equals(_companyId))) { if (!XSS_ALLOW_COMPANYID) { companyId = XSSUtil.strip(companyId); } _companyId = companyId; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setCreateDate(Date createDate) { if (((createDate == null) && (_createDate != null)) || ((createDate != null) && (_createDate == null)) || ((createDate != null) && (_createDate != null) && !createDate.equals(_createDate))) { _createDate = createDate; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setDescription(String description) { if (((description == null) && (_description != null)) || ((description != null) && (_description == null)) || ((description != null) && (_description != null) && !description.equals(_description))) { if (!XSS_ALLOW_DESCRIPTION) { description = XSSUtil.strip(description); } _description = description; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setGroupId(String groupId) { if (((groupId == null) && (_groupId != null)) || ((groupId != null) && (_groupId == null)) || ((groupId != null) && (_groupId != null) && !groupId.equals(_groupId))) { if (!XSS_ALLOW_GROUPID) { groupId = XSSUtil.strip(groupId); } _groupId = groupId; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setLastPostDate(Date lastPostDate) { if (((lastPostDate == null) && (_lastPostDate != null)) || ((lastPostDate != null) && (_lastPostDate == null)) || ((lastPostDate != null) && (_lastPostDate != null) && !lastPostDate.equals(_lastPostDate))) { _lastPostDate = lastPostDate; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setModifiedDate(Date modifiedDate) { if (((modifiedDate == null) && (_modifiedDate != null)) || ((modifiedDate != null) && (_modifiedDate == null)) || ((modifiedDate != null) && (_modifiedDate != null) && !modifiedDate.equals(_modifiedDate))) { _modifiedDate = modifiedDate; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setName(String name) { if (((name == null) && (_name != null)) || ((name != null) && (_name == null)) || ((name != null) && (_name != null) && !name.equals(_name))) { if (!XSS_ALLOW_NAME) { name = XSSUtil.strip(name); } _name = name; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setParentCategoryId(String parentCategoryId) { if (((parentCategoryId == null) && (_parentCategoryId != null)) || ((parentCategoryId != null) && (_parentCategoryId == null)) || ((parentCategoryId != null) && (_parentCategoryId != null) && !parentCategoryId.equals(_parentCategoryId))) { if (!XSS_ALLOW_PARENTCATEGORYID) { parentCategoryId = XSSUtil.strip(parentCategoryId); } _parentCategoryId = parentCategoryId; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setUserId(String userId) { if (((userId == null) && (_userId != null)) || ((userId != null) && (_userId == null)) || ((userId != null) && (_userId != null) && !userId.equals(_userId))) { if (!XSS_ALLOW_USERID) { userId = XSSUtil.strip(userId); } _userId = userId; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
setModified(true);
public void setUserName(String userName) { if (((userName == null) && (_userName != null)) || ((userName != null) && (_userName == null)) || ((userName != null) && (_userName != null) && !userName.equals(_userName))) { if (!XSS_ALLOW_USERNAME) { userName = XSSUtil.strip(userName); } _userName = userName; setModified(true); } }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/MBCategoryModel.java/buggy/portal-ejb/src/com/liferay/portlet/messageboards/model/MBCategoryModel.java
value = getCreateDate().compareTo(mbMessage.getCreateDate());
value = DateUtil.compareTo(getCreateDate(), mbMessage.getCreateDate());
public int compareTo(Object obj) { if (obj == null) { return -1; } MBMessage mbMessage = (MBMessage)obj; int value = 0; value = getCreateDate().compareTo(mbMessage.getCreateDate()); if (value != 0) { return value; } value = getMessageId().compareTo(mbMessage.getMessageId()); if (value != 0) { return value; } return 0; }
57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/0f4675cccf5487b482133977e732e847e320f104/MBMessageModel.java/clean/portal-ejb/src/com/liferay/portlet/messageboards/model/MBMessageModel.java
super("File", RubyFile.class, runtime.getClasses().getIoClass());
super("File", RubyFile.class, runtime.getClass("IO"));
public FileMetaClass(Ruby runtime) { super("File", RubyFile.class, runtime.getClasses().getIoClass()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/FileMetaClass.java/clean/src/org/jruby/runtime/builtin/meta/FileMetaClass.java
extendObject(runtime.getClasses().getFileTestModule());
extendObject(runtime.getModule("FileTest"));
protected void initializeClass() { Ruby runtime = getRuntime(); RubyString separator = runtime.newString(File.separator); separator.freeze(); defineConstant("SEPARATOR", separator); defineConstant("Separator", separator); RubyString altSeparator = runtime.newString(File.separatorChar == '/' ? "\\" : "/"); altSeparator.freeze(); defineConstant("ALT_SEPARATOR", altSeparator); RubyString pathSeparator = runtime.newString(File.pathSeparator); pathSeparator.freeze(); defineConstant("PATH_SEPARATOR", pathSeparator); // Create constants for open flags setConstant("RDONLY", runtime.newFixnum(IOModes.RDONLY)); setConstant("WRONLY", runtime.newFixnum(IOModes.WRONLY)); setConstant("RDWR", runtime.newFixnum(IOModes.RDWR)); setConstant("CREAT", runtime.newFixnum(IOModes.CREAT)); setConstant("EXCL", runtime.newFixnum(IOModes.EXCL)); setConstant("NOCTTY", runtime.newFixnum(IOModes.NOCTTY)); setConstant("TRUNC", runtime.newFixnum(IOModes.TRUNC)); setConstant("APPEND", runtime.newFixnum(IOModes.APPEND)); setConstant("NONBLOCK", runtime.newFixnum(IOModes.NONBLOCK)); // Create constants for flock setConstant("LOCK_SH", runtime.newFixnum(RubyFile.LOCK_SH)); setConstant("LOCK_EX", runtime.newFixnum(RubyFile.LOCK_EX)); setConstant("LOCK_NB", runtime.newFixnum(RubyFile.LOCK_NB)); setConstant("LOCK_UN", runtime.newFixnum(RubyFile.LOCK_UN)); // TODO Singleton methods: atime, blockdev?, chardev?, chown, ctime, directory? // TODO Singleton methods: executable?, executable_real?, extname, fnmatch, fnmatch? // TODO Singleton methods: ftype, grpowned?, lchmod, lchown, link, mtime, owned? // TODO Singleton methods: pipe?, readlink, setgid?, setuid?, size?, socket?, // TODO Singleton methods: stat, sticky?, symlink, symlink?, umask, utime extendObject(runtime.getClasses().getFileTestModule()); defineSingletonMethod("basename", Arity.optional()); defineSingletonMethod("chmod", Arity.twoArguments()); defineSingletonMethod("delete", Arity.optional(), "unlink"); defineSingletonMethod("dirname", Arity.singleArgument()); defineSingletonMethod("expand_path", Arity.optional()); defineSingletonMethod("join", Arity.optional()); defineSingletonMethod("lstat", Arity.singleArgument()); defineSingletonMethod("open", Arity.optional()); defineSingletonMethod("rename", Arity.twoArguments()); defineSingletonMethod("split", Arity.singleArgument()); defineSingletonMethod("stat", Arity.singleArgument(), "lstat"); defineSingletonMethod("symlink?", Arity.singleArgument(), "symlink_p"); defineSingletonMethod("truncate", Arity.twoArguments()); defineSingletonMethod("unlink", Arity.optional()); // TODO: Define instance methods: atime, chmod, chown, ctime, lchmod, lchown, lstat, mtime //defineMethod("flock", Arity.singleArgument()); defineMethod("initialize", Arity.optional()); defineMethod("path", Arity.noArguments()); defineMethod("truncate", Arity.singleArgument()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/FileMetaClass.java/clean/src/org/jruby/runtime/builtin/meta/FileMetaClass.java
RubyFileStat.createFileStatClass(runtime);
protected void initializeClass() { Ruby runtime = getRuntime(); RubyString separator = runtime.newString(File.separator); separator.freeze(); defineConstant("SEPARATOR", separator); defineConstant("Separator", separator); RubyString altSeparator = runtime.newString(File.separatorChar == '/' ? "\\" : "/"); altSeparator.freeze(); defineConstant("ALT_SEPARATOR", altSeparator); RubyString pathSeparator = runtime.newString(File.pathSeparator); pathSeparator.freeze(); defineConstant("PATH_SEPARATOR", pathSeparator); // Create constants for open flags setConstant("RDONLY", runtime.newFixnum(IOModes.RDONLY)); setConstant("WRONLY", runtime.newFixnum(IOModes.WRONLY)); setConstant("RDWR", runtime.newFixnum(IOModes.RDWR)); setConstant("CREAT", runtime.newFixnum(IOModes.CREAT)); setConstant("EXCL", runtime.newFixnum(IOModes.EXCL)); setConstant("NOCTTY", runtime.newFixnum(IOModes.NOCTTY)); setConstant("TRUNC", runtime.newFixnum(IOModes.TRUNC)); setConstant("APPEND", runtime.newFixnum(IOModes.APPEND)); setConstant("NONBLOCK", runtime.newFixnum(IOModes.NONBLOCK)); // Create constants for flock setConstant("LOCK_SH", runtime.newFixnum(RubyFile.LOCK_SH)); setConstant("LOCK_EX", runtime.newFixnum(RubyFile.LOCK_EX)); setConstant("LOCK_NB", runtime.newFixnum(RubyFile.LOCK_NB)); setConstant("LOCK_UN", runtime.newFixnum(RubyFile.LOCK_UN)); // TODO Singleton methods: atime, blockdev?, chardev?, chown, ctime, directory? // TODO Singleton methods: executable?, executable_real?, extname, fnmatch, fnmatch? // TODO Singleton methods: ftype, grpowned?, lchmod, lchown, link, mtime, owned? // TODO Singleton methods: pipe?, readlink, setgid?, setuid?, size?, socket?, // TODO Singleton methods: stat, sticky?, symlink, symlink?, umask, utime extendObject(runtime.getClasses().getFileTestModule()); defineSingletonMethod("basename", Arity.optional()); defineSingletonMethod("chmod", Arity.twoArguments()); defineSingletonMethod("delete", Arity.optional(), "unlink"); defineSingletonMethod("dirname", Arity.singleArgument()); defineSingletonMethod("expand_path", Arity.optional()); defineSingletonMethod("join", Arity.optional()); defineSingletonMethod("lstat", Arity.singleArgument()); defineSingletonMethod("open", Arity.optional()); defineSingletonMethod("rename", Arity.twoArguments()); defineSingletonMethod("split", Arity.singleArgument()); defineSingletonMethod("stat", Arity.singleArgument(), "lstat"); defineSingletonMethod("symlink?", Arity.singleArgument(), "symlink_p"); defineSingletonMethod("truncate", Arity.twoArguments()); defineSingletonMethod("unlink", Arity.optional()); // TODO: Define instance methods: atime, chmod, chown, ctime, lchmod, lchown, lstat, mtime //defineMethod("flock", Arity.singleArgument()); defineMethod("initialize", Arity.optional()); defineMethod("path", Arity.noArguments()); defineMethod("truncate", Arity.singleArgument()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/FileMetaClass.java/clean/src/org/jruby/runtime/builtin/meta/FileMetaClass.java
for (int i = 0; i < completedDls.length; i++) {
for (int i = 0; i < completedDls.length; i++) {
public void clearCompletedDownloads() { Download[] completedDls = getCompletedDownloads(); completedDownloads.clear(); for (int i = 0; i < completedDls.length; i++) { listenerSupport.completedDownloadRemoved(new TransferManagerEvent( this, completedDls[i])); } }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/652e070779285a419392fff7d375d332ec5d1c17/TransferManager.java/buggy/src/main/de/dal33t/powerfolder/transfer/TransferManager.java
transferFound = downloads.remove(transfer.getFile()) != null;
transferFound = downloads.containsKey(transfer.getFile());
void setCompleted(Transfer transfer) { boolean transferFound = false; if (transfer instanceof Download) { Download download = (Download) transfer; transferFound = downloads.remove(transfer.getFile()) != null; if (transferFound) { // Add to list of completed downloads completedDownloads.add((Download) transfer); FileInfo fInfo = transfer.getFile(); // Inform other folder member of added file Folder folder = fInfo.getFolder(getController() .getFolderRepository()); if (folder != null) { folder.broadcastMessage(new FolderFilesChanged( (Download) transfer)); // scan in new downloaded file folder.scanDownloadFile(fInfo, download.getTempFile()); } // Fire event listenerSupport.downloadCompleted(new TransferManagerEvent( this, (Download) transfer)); // Trigger filerequestor getController().getFolderRepository().getFileRequestor() .triggerFileRequesting(); // Autostart torrents File diskFile = fInfo.getDiskFile(getController() .getFolderRepository()); boolean isLeechFile = diskFile != null && fInfo.getFilenameOnly().endsWith(".torrent"); // Autostart bittorento! if (folder.getSyncProfile().isAutostartLeechPrograms() && isLeechFile) { log().warn("Auto starting: " + diskFile.getAbsolutePath()); try { Util.executeFile(diskFile); } catch (IOException e) { log().error(e); // unableToStart(fInfo, ex); } } } } else if (transfer instanceof Upload) { transferFound = queuedUploads.remove(transfer); transferFound = activeUploads.remove(transfer) || transferFound; if (transferFound) { // Fire event listenerSupport.uploadCompleted(new TransferManagerEvent(this, (Upload) transfer)); } } log().debug("Transfer completed: " + transfer); if (transfer instanceof Upload) { // Now trigger, to start next upload triggerTransfersCheck(); } }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/652e070779285a419392fff7d375d332ec5d1c17/TransferManager.java/buggy/src/main/de/dal33t/powerfolder/transfer/TransferManager.java
if (transferFound) { completedDownloads.add((Download) transfer);
if (!transferFound) { return; }
void setCompleted(Transfer transfer) { boolean transferFound = false; if (transfer instanceof Download) { Download download = (Download) transfer; transferFound = downloads.remove(transfer.getFile()) != null; if (transferFound) { // Add to list of completed downloads completedDownloads.add((Download) transfer); FileInfo fInfo = transfer.getFile(); // Inform other folder member of added file Folder folder = fInfo.getFolder(getController() .getFolderRepository()); if (folder != null) { folder.broadcastMessage(new FolderFilesChanged( (Download) transfer)); // scan in new downloaded file folder.scanDownloadFile(fInfo, download.getTempFile()); } // Fire event listenerSupport.downloadCompleted(new TransferManagerEvent( this, (Download) transfer)); // Trigger filerequestor getController().getFolderRepository().getFileRequestor() .triggerFileRequesting(); // Autostart torrents File diskFile = fInfo.getDiskFile(getController() .getFolderRepository()); boolean isLeechFile = diskFile != null && fInfo.getFilenameOnly().endsWith(".torrent"); // Autostart bittorento! if (folder.getSyncProfile().isAutostartLeechPrograms() && isLeechFile) { log().warn("Auto starting: " + diskFile.getAbsolutePath()); try { Util.executeFile(diskFile); } catch (IOException e) { log().error(e); // unableToStart(fInfo, ex); } } } } else if (transfer instanceof Upload) { transferFound = queuedUploads.remove(transfer); transferFound = activeUploads.remove(transfer) || transferFound; if (transferFound) { // Fire event listenerSupport.uploadCompleted(new TransferManagerEvent(this, (Upload) transfer)); } } log().debug("Transfer completed: " + transfer); if (transfer instanceof Upload) { // Now trigger, to start next upload triggerTransfersCheck(); } }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/652e070779285a419392fff7d375d332ec5d1c17/TransferManager.java/buggy/src/main/de/dal33t/powerfolder/transfer/TransferManager.java
FileInfo fInfo = transfer.getFile();
FileInfo fInfo = transfer.getFile(); Folder folder = fInfo.getFolder(getController() .getFolderRepository()); if (folder != null) { folder.scanDownloadFile(fInfo, download.getTempFile());
void setCompleted(Transfer transfer) { boolean transferFound = false; if (transfer instanceof Download) { Download download = (Download) transfer; transferFound = downloads.remove(transfer.getFile()) != null; if (transferFound) { // Add to list of completed downloads completedDownloads.add((Download) transfer); FileInfo fInfo = transfer.getFile(); // Inform other folder member of added file Folder folder = fInfo.getFolder(getController() .getFolderRepository()); if (folder != null) { folder.broadcastMessage(new FolderFilesChanged( (Download) transfer)); // scan in new downloaded file folder.scanDownloadFile(fInfo, download.getTempFile()); } // Fire event listenerSupport.downloadCompleted(new TransferManagerEvent( this, (Download) transfer)); // Trigger filerequestor getController().getFolderRepository().getFileRequestor() .triggerFileRequesting(); // Autostart torrents File diskFile = fInfo.getDiskFile(getController() .getFolderRepository()); boolean isLeechFile = diskFile != null && fInfo.getFilenameOnly().endsWith(".torrent"); // Autostart bittorento! if (folder.getSyncProfile().isAutostartLeechPrograms() && isLeechFile) { log().warn("Auto starting: " + diskFile.getAbsolutePath()); try { Util.executeFile(diskFile); } catch (IOException e) { log().error(e); // unableToStart(fInfo, ex); } } } } else if (transfer instanceof Upload) { transferFound = queuedUploads.remove(transfer); transferFound = activeUploads.remove(transfer) || transferFound; if (transferFound) { // Fire event listenerSupport.uploadCompleted(new TransferManagerEvent(this, (Upload) transfer)); } } log().debug("Transfer completed: " + transfer); if (transfer instanceof Upload) { // Now trigger, to start next upload triggerTransfersCheck(); } }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/652e070779285a419392fff7d375d332ec5d1c17/TransferManager.java/buggy/src/main/de/dal33t/powerfolder/transfer/TransferManager.java
Folder folder = fInfo.getFolder(getController() .getFolderRepository()); if (folder != null) { folder.broadcastMessage(new FolderFilesChanged( (Download) transfer));
folder.broadcastMessage(new FolderFilesChanged( (Download) transfer)); }
void setCompleted(Transfer transfer) { boolean transferFound = false; if (transfer instanceof Download) { Download download = (Download) transfer; transferFound = downloads.remove(transfer.getFile()) != null; if (transferFound) { // Add to list of completed downloads completedDownloads.add((Download) transfer); FileInfo fInfo = transfer.getFile(); // Inform other folder member of added file Folder folder = fInfo.getFolder(getController() .getFolderRepository()); if (folder != null) { folder.broadcastMessage(new FolderFilesChanged( (Download) transfer)); // scan in new downloaded file folder.scanDownloadFile(fInfo, download.getTempFile()); } // Fire event listenerSupport.downloadCompleted(new TransferManagerEvent( this, (Download) transfer)); // Trigger filerequestor getController().getFolderRepository().getFileRequestor() .triggerFileRequesting(); // Autostart torrents File diskFile = fInfo.getDiskFile(getController() .getFolderRepository()); boolean isLeechFile = diskFile != null && fInfo.getFilenameOnly().endsWith(".torrent"); // Autostart bittorento! if (folder.getSyncProfile().isAutostartLeechPrograms() && isLeechFile) { log().warn("Auto starting: " + diskFile.getAbsolutePath()); try { Util.executeFile(diskFile); } catch (IOException e) { log().error(e); // unableToStart(fInfo, ex); } } } } else if (transfer instanceof Upload) { transferFound = queuedUploads.remove(transfer); transferFound = activeUploads.remove(transfer) || transferFound; if (transferFound) { // Fire event listenerSupport.uploadCompleted(new TransferManagerEvent(this, (Upload) transfer)); } } log().debug("Transfer completed: " + transfer); if (transfer instanceof Upload) { // Now trigger, to start next upload triggerTransfersCheck(); } }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/652e070779285a419392fff7d375d332ec5d1c17/TransferManager.java/buggy/src/main/de/dal33t/powerfolder/transfer/TransferManager.java
folder.scanDownloadFile(fInfo, download.getTempFile()); }
downloads.remove(transfer.getFile()); completedDownloads.add((Download) transfer);
void setCompleted(Transfer transfer) { boolean transferFound = false; if (transfer instanceof Download) { Download download = (Download) transfer; transferFound = downloads.remove(transfer.getFile()) != null; if (transferFound) { // Add to list of completed downloads completedDownloads.add((Download) transfer); FileInfo fInfo = transfer.getFile(); // Inform other folder member of added file Folder folder = fInfo.getFolder(getController() .getFolderRepository()); if (folder != null) { folder.broadcastMessage(new FolderFilesChanged( (Download) transfer)); // scan in new downloaded file folder.scanDownloadFile(fInfo, download.getTempFile()); } // Fire event listenerSupport.downloadCompleted(new TransferManagerEvent( this, (Download) transfer)); // Trigger filerequestor getController().getFolderRepository().getFileRequestor() .triggerFileRequesting(); // Autostart torrents File diskFile = fInfo.getDiskFile(getController() .getFolderRepository()); boolean isLeechFile = diskFile != null && fInfo.getFilenameOnly().endsWith(".torrent"); // Autostart bittorento! if (folder.getSyncProfile().isAutostartLeechPrograms() && isLeechFile) { log().warn("Auto starting: " + diskFile.getAbsolutePath()); try { Util.executeFile(diskFile); } catch (IOException e) { log().error(e); // unableToStart(fInfo, ex); } } } } else if (transfer instanceof Upload) { transferFound = queuedUploads.remove(transfer); transferFound = activeUploads.remove(transfer) || transferFound; if (transferFound) { // Fire event listenerSupport.uploadCompleted(new TransferManagerEvent(this, (Upload) transfer)); } } log().debug("Transfer completed: " + transfer); if (transfer instanceof Upload) { // Now trigger, to start next upload triggerTransfersCheck(); } }
51438 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/51438/652e070779285a419392fff7d375d332ec5d1c17/TransferManager.java/buggy/src/main/de/dal33t/powerfolder/transfer/TransferManager.java