Package org.jvnet.sorcerer.util

Examples of org.jvnet.sorcerer.util.CharSequenceReader


     */
    protected void configure(final CompilationUnitTree cu, final AstGenerator gen) throws IOException {
        final LineMap lineMap = cu.getLineMap();

        // add lexical markers
        JavaLexer lexer = new JavaLexer(new CharSequenceReader(gen.sourceFile));
        lexer.setTabSize(tabWidth);
        try {
            Stack<Long> openBraces = new Stack<Long>();

            while(true) {
View Full Code Here


    /**
     * Organizes {@link #tags} to the tree structure.
     */
    public Tag.Root buildTree() throws IOException {
        Reader in = new CharSequenceReader(sourceFile);
        long curPos = 0;    // chars from input that are written so far
        StringBuilder sb = new StringBuilder();
        char[] buf = new char[256];

        Collections.sort(tags);

        TagStack opened = new TagStack();
        // start with the root tag
        Root root = new Root(sourceFile.length());
        opened.push(root);

        TagScanner upcoming = new TagScanner(tags);

        OUTER:
        while(true) {
            // determine the next marker position
            TagStack.Adder lhs = opened.peek();
            Tag rhs = upcoming.peek();

            long nextPos = Math.min(
                lhs==null ? Long.MAX_VALUE : lhs.endPos(),
                rhs==null ? Long.MAX_VALUE : rhs.sp );

            // read until nextPos
            sb.setLength(0);
            while(curPos<nextPos) {
                int sz = in.read(buf,0, (int)Math.min(nextPos-curPos,buf.length));
                if(sz<0)    break OUTER; // all streams read
                sb.append(buf,0,sz);
                curPos += sz;
            }

View Full Code Here

            pos = pss.getSourcePositions().getEndPosition(compUnit, t);
        else
            pos = pss.getSourcePositions().getStartPosition(compUnit, t);

        if(pos<0)   return null;
        JavaLexer lexer = new JavaLexer(new CharSequenceReader(sourceFile.subSequence((int)pos, sourceFile.length())));
        lexer.setTabSize(pss.getTabWidth());
        try {
            while(true) {
                Token token = lexer.nextToken();
                int type = token.getType();
View Full Code Here

TOP

Related Classes of org.jvnet.sorcerer.util.CharSequenceReader

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.