Ejemplo n.º 1
0
 public SafeVectorVisitor(VectVisitor vect)
 {
     m_vect = vect;
 }
Ejemplo n.º 2
0
 void vector(VectVisitor vec)
 {
     if (Token.VECTOR == lookahead) {
         match(Token.VECTOR);
         vector_contents(vec);
         match(Token.CLOSE_PAREN);
     } else {
         throw new SyntaxError(m_attrib.loc, lookahead, Token.VECTOR);
     }
 }
Ejemplo n.º 3
0
        void vector_contents(VectVisitor vec)
        {
            if (Token.CLOSE_PAREN == lookahead) {
                // EPSILON
            } 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) {

                datum_list(vec);

                if (Token.CLOSE_PAREN != lookahead) {
                    throw new SyntaxError(m_attrib.loc, lookahead, Token.CLOSE_PAREN);
                }

            } else {
                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);
            }
        }
Ejemplo n.º 4
0
        void top_level(VectVisitor vec)
        {
            datum_list(vec);

            if (Token.EOF != lookahead) {
                // ERROR
                throw new SyntaxError(m_attrib.loc, lookahead, Token.EOF);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
 public Parser(Reader reader, VectVisitor visitor, TxtLocation loc)
 {
     m_scanner = new Scanner(reader);
     m_visitor = visitor;
     m_loc = loc;
 }
Ejemplo n.º 8
0
 public Parser(Reader reader, VectVisitor visitor)
     : this(reader, visitor, null)
 {
 }
Ejemplo n.º 9
0
        void datum_list(VectVisitor vec)
        {
            while (
                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) {

                top_datum(vec);
            }
        }
Ejemplo n.º 10
0
 public VectorMultiVisitor(VectVisitor car, VectVisitor cdr)
 {
     this.car = car;
     this.cdr = cdr;
 }