コード例 #1
0
ファイル: Parser.cs プロジェクト: JasonWilkins/visitor-tk
        void top_list(VectVisitor top)
        {
            if (Token.CLOSE_PAREN == lookahead) {
                match(Token.CLOSE_PAREN);
                top.visitItem();
            } else if (
                Token.BOOL == lookahead ||
                Token.NUM == lookahead ||
                Token.CHAR == lookahead ||
                Token.STRING == lookahead ||
                Token.ID == lookahead ||
                Token.OPEN_PAREN == lookahead ||
                Token.QUOTE == lookahead ||
                Token.BACKQUOTE == lookahead ||
                Token.COMMA == lookahead ||
                Token.SPLICE == lookahead ||
                Token.VECTOR == lookahead) {

                ConsVisitor cons = top.visitItem_Cons();
                cons.visit();
                list_contents(cons);
                cons.visitEnd();
                match(Token.CLOSE_PAREN);
            } else {
                // ERROR
                throw new SyntaxError(m_attrib.loc, lookahead, Token.CLOSE_PAREN, Token.BOOL, Token.NUM, Token.CHAR, Token.STRING, Token.ID, Token.OPEN_PAREN, Token.QUOTE, Token.BACKQUOTE, Token.COMMA, Token.SPLICE, Token.VECTOR);
            }
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: JasonWilkins/visitor-tk
        void top_datum(VectVisitor top)
        {
            if (Token.BOOL == lookahead ||
                Token.NUM == lookahead ||
                Token.CHAR == lookahead ||
                Token.STRING == lookahead ||
                Token.ID == lookahead) {

                AtomVisitor atom = top.visitItem_Atom();
                simple_datum(atom);
            } else if (Token.OPEN_PAREN == lookahead) {
                match(Token.OPEN_PAREN);
                top_list(top);
            } else if (
                Token.QUOTE == lookahead ||
                Token.BACKQUOTE == lookahead ||
                Token.COMMA == lookahead ||
                Token.SPLICE == lookahead) {

                ConsVisitor cons = top.visitItem_Cons();
                cons.visit();
                abbreviation(cons);
                cons.visitEnd();
            } else if (Token.VECTOR == lookahead) {
                VectVisitor vec = top.visitItem_Vect();
                vec.visit();
                vector(vec);
                vec.visitEnd();
            } else {
                // ERROR
                throw new SyntaxError(m_attrib.loc, lookahead, Token.BOOL, Token.NUM, Token.CHAR, Token.STRING, Token.ID, Token.OPEN_PAREN, Token.QUOTE, Token.BACKQUOTE, Token.COMMA, Token.SPLICE);
            }
        }