Package org.jruby.ast

Examples of org.jruby.ast.StrNode


        context.splatCurrentValue();
    }

    public void compileStr(Node node, BodyCompiler context) {
        StrNode strNode = (StrNode) node;

        if (strNode instanceof FileNode) {
            context.loadFilename();
        } else {
            context.createNewString(strNode.getValue());
        }
    }
View Full Code Here


            do {
                if ((c = new StringTerm(flags, '\0', '\n').parseStringIntoBuffer(lexer, src, str)) == RubyYaccLexer.EOF) {
                    syntaxError(src);
                }
                if (c != '\n') {
                    lexer.yaccValue = new StrNode(lexer.getPosition(), str);
                    return Tokens.tSTRING_CONTENT;
                }
                str.append(src.read());
               
                if (src.peek(RubyYaccLexer.EOF)) syntaxError(src);
                position = lexer.getPosition();
            } while (!src.matchMarker(marker, indent, true));
        }

        src.unreadMany(lastLine);
        lexer.setStrTerm(new StringTerm(-1, '\0', '\0'));
        lexer.yaccValue = new StrNode(position, str);
        return Tokens.tSTRING_CONTENT;
    }
View Full Code Here

            src.unread(c);
            if ((buffer = src.readUntil(end)) == null) {
                throw new SyntaxException(src.getPosition(), "unterminated string meets end of file");
            }
            */
            lexer.setValue(new StrNode(lexer.getPosition(), buffer));
            return Tokens.tSTRING_CONTENT;
        }
       
        ByteList buffer = new ByteList();

        if ((flags & RubyYaccLexer.STR_FUNC_EXPAND) != 0 && c == '#') {
            c = src.read();
            switch (c) {
            case '$':
            case '@':
                src.unread(c);
                lexer.setValue(new Token("#" + c, lexer.getPosition()));
                return Tokens.tSTRING_DVAR;
            case '{':
                lexer.setValue(new Token("#" + c, lexer.getPosition()));
                return Tokens.tSTRING_DBEG;
            }
            buffer.append((byte) '#');
        }
        src.unread(c);
       
        if (parseStringIntoBuffer(lexer, src, buffer) == RubyYaccLexer.EOF) {
            throw new SyntaxException(PID.STRING_HITS_EOF, src.getPosition(), "unterminated string meets end of file");
        }

        lexer.setValue(new StrNode(lexer.getPosition(), buffer));
        return Tokens.tSTRING_CONTENT;
    }
View Full Code Here

         }
  break;
case 388:
          // line 1462 "DefaultRubyParser.y"
  {
                   yyVal = new StrNode(((Token)yyVals[0+yyTop]).getPosition(), ByteList.create(""));
         }
  break;
case 389:
          // line 1465 "DefaultRubyParser.y"
  {
View Full Code Here

            head = new DStrNode(union(head.getPosition(), position)).add(head);
        }

        if (tail instanceof StrNode) {
            if (head instanceof StrNode) {
              return new StrNode(union(head, tail), (StrNode) head, (StrNode) tail);
            }
            head.setPosition(union(head, tail));
            return ((ListNode) head).add(tail);
         
        } else if (tail instanceof DStrNode) {
View Full Code Here

                    continue;
                } else {
                    return null;
                }
            } else if (whenNode.getExpressionNodes() instanceof StrNode) {
                StrNode strNode = (StrNode)whenNode.getExpressionNodes();
                if (strNode.getValue().length() == 1) {
                    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_STRING) return null;
                    if (foundType == null) foundType = FastSwitchType.SINGLE_CHAR_STRING;

                    continue;
                } else {
View Full Code Here

            return cases;
        } else if (whenNode.getExpressionNodes() instanceof FixnumNode) {
            FixnumNode fixnumNode = (FixnumNode)whenNode.getExpressionNodes();
            return new int[] {(int)fixnumNode.getValue()};
        } else if (whenNode.getExpressionNodes() instanceof StrNode) {
            StrNode strNode = (StrNode)whenNode.getExpressionNodes();
            if (strNode.getValue().length() == 1) {
                return new int[] {strNode.getValue().get(0)};
            } else {
                return new int[] {strNode.getValue().hashCode()};
            }
        } else if (whenNode.getExpressionNodes() instanceof SymbolNode) {
            SymbolNode symbolNode = (SymbolNode)whenNode.getExpressionNodes();
            if (symbolNode.getName().length() == 1) {
                return new int[] {symbolNode.getName().charAt(0)};
View Full Code Here

    protected void splatCurrentValue(BodyCompiler context) {
        context.splatCurrentValue("splatValue");
    }

    public void compileStr(Node node, BodyCompiler context, boolean expr) {
        StrNode strNode = (StrNode) node;

        if (expr) {
            if (strNode instanceof FileNode) {
                context.loadFilename();
            } else {
                context.createNewString(strNode.getValue(), strNode.getCodeRange());
            }
        }
    }
View Full Code Here

                    bufferEncoding != RubyYaccLexer.UTF8_ENCODING) {
                buffer.setEncoding(RubyYaccLexer.ASCII8BIT_ENCODING);
            }
        }

        return new StrNode(position, buffer, codeRange);
    }
View Full Code Here

            yaccValue = new FixnumNode(getPosition(), c);
        } else {
            // TODO: this isn't handling multibyte yet
            ByteList oneCharBL = new ByteList(1);
            oneCharBL.append(c);
            yaccValue = new StrNode(getPosition(), oneCharBL);
        }
        // TODO: This should be something else like a tCHAR
        return Tokens.tINTEGER;
    }
View Full Code Here

TOP

Related Classes of org.jruby.ast.StrNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.