Examples of TextToken


Examples of com.nexirius.util.TextToken

    boolean parseClassHeader()
            throws Exception {
        try {
            // check whether the next token is a 'class'
            TextToken t = nextToken();

            if (!t.isIdentifier(CLASS)) {
                throw new SyntaxException(CLASS, t.debugString());
            }

            t = nextToken();

            if (!t.isIdentifier()) {
                throw new SyntaxException("class name", t.debugString());
            }
//System.out.println("parsing class " + t.getString());
            currentClass = new DataModelTypeClass(t.getString());

            t = nextToken();

            if (t.isString()) {
                currentClass.setImplementedBy(t.getString());
            } else {
                pushbackToken();
            }

        } catch (NoMoreTokensException ex) {
View Full Code Here

Examples of com.nexirius.util.TextToken

    }

    boolean parseClassBody()
            throws Exception {
        try {
            TextToken t = nextToken();

            if (!t.isChar(OCURLY)) {
                throw new SyntaxException(OCURLY, t.debugString());
            }

            while (true) {
                t = nextToken();

                if (t.isChar(CCURLY)) {
                    break;
                }

                pushbackToken();
View Full Code Here

Examples of com.nexirius.util.TextToken

    }

    void parseClassElement()
            throws Exception {
        // check whether the next token is a Identifier
        TextToken t = nextToken();

        if (!t.isIdentifier()) {
            throw new SyntaxException("type specifier", t.debugString());
        }

        String type = t.getString();

        t = nextToken();

        if (t.isIdentifier()) {
            // simple member of array member or method
            String memberName = t.getString();

            t = nextToken();

            if (t.isChar(OBRACKET)) {
                t = nextToken();

                if (!t.isChar(CBRACKET)) {
                    throw new SyntaxException(CBRACKET, t.debugString());
                }

                currentClass.append(new DataModelTypeArray(type, memberName));

            } else if (t.isChar(OBRACE)) {
                t = nextToken();

                if (!t.isChar(CBRACE)) {
                    throw new SyntaxException(CBRACE, t.debugString());
                }

                currentClass.append(new DataModelTypeMethod(type, memberName));

            } else if (t.isChar(SEMICOLON)) {
                currentClass.append(new DataModelTypeMember(type, memberName, null));
                pushbackToken();
            } else if (t.isChar(ASSIGN)) {
                t = nextToken();

                if (!t.isString()) {
                    throw new SyntaxException("string literal (init value)", t.debugString());
                }

                currentClass.append(new DataModelTypeMember(type, memberName, t.getString()));
            } else {
                throw new SyntaxException("( or [ or ; or =", t.debugString());
            }

            t = nextToken();

            if (!t.isChar(SEMICOLON)) {
                throw new SyntaxException(SEMICOLON, t.debugString());
            }
        } else {
            throw new SyntaxException("member name", t.debugString());
        }
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

     * @throws Exception when syntax of the function is not correct
     */
    public HTMLFunction parseFunction(HTMLSessionVariable sessionVariable, PushbackInputStream in)
            throws Exception {
        HTMLFunction ret = null;
        TextToken token = TextToken.nextToken(in);

        if (token == null) {
            throw new Exception("Expecting function name at end of stream");
        }

        if (token.isIdentifier()) {
            ret = resolver.getFunction(token.getString());
        } else {
            throw new Exception("Expecting function name but have " + token.debugString());
        }

        if (ret == null) {
            throw new Exception("Unknown function name " + token.debugString());
        }

        return ret;
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

        return ret;
    }

    public String[] parseFunctionArguments(HTMLSessionVariable sessionVariable, PushbackInputStream in) throws Exception {
        StringVector functionArgumentList = new StringVector();
        TextToken token;
        token = TextToken.nextToken(in);

        if (token == null) {
            throw new Exception("Expecting '(' after function name");
        }

        if (token.isChar('(')) {
            while (true) {
                token = TextToken.nextToken(in);

                if (token.isChar(')')) {

                    break;
                }

                if (token.isString()) {
                    String s = token.getString();
                    s = resolve(sessionVariable, s);
                    functionArgumentList.append(s);
                } else if (token.isInt()) {
                    functionArgumentList.append(Integer.toString(token.getInt()));
                } else if (token.isIdentifier(NULL)) {
                    functionArgumentList.append((String)null);
                } else if (token.isIdentifier()) {
                    functionArgumentList.append(token.getString());
                } else {
                    throw new Exception("Unexpected token in parameter list:" + token.debugString());
                }

                token = TextToken.nextToken(in);

                if (token.isChar(',')) {
                    // expected
                } else if (token.isChar(')')) {
                    break;
                } else {
                    throw new Exception("Unexpected token in parameter list:" + token.debugString());
                }
            }
        } else {
            throw new Exception("Expecting '(' but have " + token.debugString());
        }

        return functionArgumentList.getArray();
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

                default:
                    in.unread(c);
                    return;
            }

            TextToken token = TextToken.nextToken(in);

            if (token == null) {
                throw new Exception("Expecting ModelFlag identifier but have null");
            }
            if (!token.isString()) {
                throw new Exception("Expecting ModelFlag identifier but have: " + token);
            }

            model.setFlag(new ModelFlag(token.getString()), nextFlag);
        }
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

                out.write('+');
            } else {
                out.write('-');
            }

            TextToken flagName = new TextToken(c[i].getFlag().getName());

            flagName.writeTo(out);
        }
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

        if (dirList != null && out != null) {
            DataModelEnumeration e = dirList.getEnumeration();

            while (e.hasMore()) {
                DirectoryInfoModel subdir = (DirectoryInfoModel) e.next();
                TextToken t = new TextToken(subdir.getName(), TextToken.STRING);

                try {
                    t.writeTo(out);
                    out.write('\n');
                } catch (Exception e1) {
                    e1.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                }
            }
View Full Code Here

Examples of com.nexirius.util.TextToken

    public void readDirectoryFrom(String urlString) throws Exception {
        URL url = new URL(urlString + DIR_INFO_FILENAME);
        PushbackInputStream in = new PushbackInputStream(new BufferedInputStream(url.openStream()));
        readDataFrom(in);
        TextToken t = TextToken.nextToken(in);

        while (t != null && t.isString()) {
            DirectoryInfoModel dir = addDirectory(new DirectoryInfo(t.getString()));
            dir.setUrl(urlString + t.getString() + '/');
            t = TextToken.nextToken(in);
        }

        in.close();
    }
View Full Code Here

Examples of com.nexirius.util.TextToken

    }

    public void writeTo(OutputStream out) throws Exception {
        getIdentifier().writeTo(out);
        SPACE.writeTo(out);
        new TextToken(name).writeTo(out);
        SPACE.writeTo(out);
        new TextToken(size).writeTo(out);
        SPACE.writeTo(out);
        new TextToken(hash).writeTo(out);
        NEW_LINE.writeTo(out);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.