Package org.yinwang.yin.ast

Examples of org.yinwang.yin.ast.Node


     * Helper for nextNode, which does the real work
     *
     * @return a Node or null if file ends
     */
    public Node nextNode1(int depth) throws ParserException {
        Node first = lexer.nextToken();

        // end of file
        if (first == null) {
            return null;
        }

        if (Delimeter.isOpen(first)) {   // try to get matched (...)
            List<Node> elements = new ArrayList<>();
            Node next;
            for (next = nextNode1(depth + 1);
                 !Delimeter.match(first, next);
                 next = nextNode1(depth + 1))
            {
                if (next == null) {
                    throw new ParserException("unclosed delimeter till end of file: " + first.toString(), first);
                } else if (Delimeter.isClose(next)) {
                    throw new ParserException("unmatched closing delimeter: " +
                            next.toString() + " does not close " + first.toString(), next);
                } else {
                    elements.add(next);
                }
            }
            return new Tuple(elements, first, next, first.file, first.start, next.end, first.line, first.col);
View Full Code Here


        this.file = file;
    }


    public Value interp(String file) {
        Node program;
        try {
            program = Parser.parse(file);
        } catch (ParserException e) {
            Util.abort("parsing error: " + e);
            return null;
        }
        return program.interp(Scope.buildInitScope());
    }
View Full Code Here

     */
    public Node parse() throws ParserException {
        List<Node> elements = new ArrayList<>();
        elements.add(Name.genName(Constants.SEQ_KEYWORD));      // synthetic block keyword

        Node s = nextNode();
        Node first = s;
        Node last = null;
        for (; s != null; last = s, s = nextNode()) {
            elements.add(s);
        }

        return new Tuple(
View Full Code Here

        this.file = file;
    }


    public Value typecheck(String file) {
        Node program;
        try {
            program = Parser.parse(file);
        } catch (ParserException e) {
            Util.abort("parsing error: " + e);
            return null;
        }
        Scope s = Scope.buildInitTypeScope();
        Value ret = program.typecheck(s);

        while (!uncalled.isEmpty()) {
            List<FunType> toRemove = new ArrayList<>(uncalled);
            for (FunType ft : toRemove) {
                invokeUncalled(ft, s);
View Full Code Here

TOP

Related Classes of org.yinwang.yin.ast.Node

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.