public ISourcePosition getPosition(ISourcePosition startPosition) { if (startPosition != null) return startPosition; if (tokline != null && ruby_sourceline == tokline.getLine()) return tokline; return new SimpleSourcePosition(getFile(), ruby_sourceline); }
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { lexer.setState(LexState.EXPR_END); yyVal = ((Token)yyVals[0+yyTop]); ((ISourcePositionHolder)yyVal).setPosition(((Token)yyVals[-1+yyTop]).getPosition()); return yyVal; } };
private int rightCurly() { conditionState.restart(); cmdArgumentState.restart(); setState(isOneEight ? LexState.EXPR_END : LexState.EXPR_ENDARG); yaccValue = new Token("}",getPosition()); return Tokens.tRCURLY; }
private int caret() throws IOException { int c = src.read(); if (c == '=') { setState(LexState.EXPR_BEG); yaccValue = new Token("^", getPosition()); return Tokens.tOP_ASGN; } determineExpressionState(); src.unread(c); yaccValue = new Token("^", getPosition()); return Tokens.tCARET; }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = lexer.getStrTerm(); lexer.setStrTerm(null); lexer.getConditionState().stop(); return yyVal; } };
public ISourcePosition getPosition() { if (lastPosition.getStartLine() == source.getVirtualLine()) return lastPosition; lastPosition = new SimpleSourcePosition(source.getFilename(), source.getVirtualLine()); return lastPosition; } }
private int addNonAsciiToBuffer(int c, LexerSource src, Encoding encoding, RubyYaccLexer lexer, ByteList buffer) throws SyntaxException, IOException { c = src.readCodepoint(c, encoding); if (c == -2) { // FIXME: Hack throw new SyntaxException(PID.INVALID_MULTIBYTE_CHAR, lexer.getPosition(), null, "invalid multibyte char (" + encoding + ")"); } // FIXME: We basically go from bytes to codepoint back to bytes to append them...fix this return lexer.tokenAddMBC(c, buffer); } }
private int singleQuote() throws IOException { lex_strterm = new StringTerm(str_squote, '\0', '\''); yaccValue = new Token("'", getPosition()); return Tokens.tSTRING_BEG; }
private int singleQuote(boolean commandState) throws IOException { int label = isLabelPossible(commandState) ? str_label : 0; lex_strterm = new StringTerm(str_squote|label, '\0', '\'', ruby_sourceline); yaccValue = Q; return RubyParser.tSTRING_BEG; }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { lexer.getConditionState().begin(); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = ((ArgsNode)yyVals[-1+yyTop]); ((ISourcePositionHolder)yyVal).setPosition(((Token)yyVals[-2+yyTop]).getPosition()); lexer.setState(LexState.EXPR_BEG); lexer.commandStart = true; return yyVal; } };
private int rightBracket() { parenNest--; conditionState.restart(); cmdArgumentState.restart(); setState(isOneEight ? LexState.EXPR_END : LexState.EXPR_ENDARG); yaccValue = new Token("]", getPosition()); return Tokens.tRBRACK; }
private int tilde() throws IOException { int c; if (lex_state == LexState.EXPR_FNAME || lex_state == LexState.EXPR_DOT) { if ((c = src.read()) != '@') src.unread(c); setState(LexState.EXPR_ARG); } else { setState(LexState.EXPR_BEG); } yaccValue = new Token("~", getPosition()); return Tokens.tTILDE; }
public ISourcePosition getPosition(ISourcePosition startPosition) { if (startPosition != null) return startPosition; if (tokline != null && ruby_sourceline == tokline.getLine()) return tokline; return new SimpleSourcePosition(getFile(), ruby_sourceline); }
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = ((ArgsNode)yyVals[-1+yyTop]); ((ISourcePositionHolder)yyVal).setPosition(((Token)yyVals[-2+yyTop]).getPosition()); lexer.setState(LexState.EXPR_BEG); lexer.commandStart = true; return yyVal; } };
private int rightParen() { parenNest--; conditionState.restart(); cmdArgumentState.restart(); setState(isOneEight ? LexState.EXPR_END : LexState.EXPR_ENDFN); yaccValue = new Token(")", getPosition()); return Tokens.tRPAREN; }
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { lexer.setState(LexState.EXPR_END); yyVal = ((Token)yyVals[0+yyTop]); ((ISourcePositionHolder)yyVal).setPosition(((Token)yyVals[-1+yyTop]).getPosition()); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = ((ArgsNode)yyVals[-1+yyTop]); ((ISourcePositionHolder)yyVal).setPosition(((Token)yyVals[-2+yyTop]).getPosition()); lexer.setState(LexState.EXPR_BEG); lexer.commandStart = true; return yyVal; } };
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { lexer.setState(LexState.EXPR_END); yyVal = ((Token)yyVals[0+yyTop]); ((ISourcePositionHolder)yyVal).setPosition(((Token)yyVals[-1+yyTop]).getPosition()); return yyVal; } };