Ejemplo n.º 1
0
        void abbrev_prefix(ConsVisitor abbrev)
        {
            abbrev.visit_Atom_car().visit(Abbrev.get_symbol(lookahead));

            if (Token.QUOTE == lookahead) {
                match(Token.QUOTE);
            } else if (Token.BACKQUOTE == lookahead) {
                match(Token.BACKQUOTE);
            } else if (Token.COMMA == lookahead) {
                match(Token.COMMA);
            } else if (Token.SPLICE == lookahead) {
                match(Token.SPLICE);
            } 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);
            }
        }
Ejemplo n.º 2
0
        void abbreviation(ConsVisitor cons)
        {
            if (Token.QUOTE == lookahead ||
                Token.BACKQUOTE == lookahead ||
                Token.COMMA == lookahead ||
                Token.SPLICE == lookahead) {

                abbrev_prefix(cons);

                ConsVisitor cdr = cons.visit_Cons_cdr();
                cdr.visit();
                datum(cdr, true);
                cdr.visit_cdr();
                cdr.visitEnd();
            } else {
                throw new SyntaxError(m_attrib.loc, lookahead, Token.QUOTE, Token.BACKQUOTE, Token.COMMA, Token.SPLICE);
            }
        }
Ejemplo n.º 3
0
 public SafeConsVisitor(ConsVisitor cons)
 {
     m_cons = cons;
 }
Ejemplo n.º 4
0
        void list_contents_tail(ConsVisitor cons)
        {
            if (Token.CLOSE_PAREN == lookahead) {
                cons.visit_cdr();
            } 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 cdr = cons.visit_Cons_cdr();
                cdr.visit();
                datum(cdr, true);
                list_contents_tail(cdr);
                cdr.visitEnd();
            } else if (Token.DOT == lookahead) {
                dot_tail(cons);
            } else {
                throw new SyntaxError(m_attrib.loc, lookahead, Token.DOT, Token.CLOSE_PAREN, Token.BOOL, Token.NUM, Token.CHAR, Token.STRING, Token.ID, Token.OPEN_PAREN, Token.QUOTE, Token.BACKQUOTE, Token.COMMA, Token.SPLICE);
            }
        }
Ejemplo n.º 5
0
        void list_contents(ConsVisitor cons)
        {
            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(cons, true);
                list_contents_tail(cons);
            } else {
                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.º 6
0
        void list(ConsVisitor cons, bool set_car)
        {
            if (Token.CLOSE_PAREN == lookahead) {
                match(Token.CLOSE_PAREN);

                if (set_car) {
                    cons.visit_car();
                } else {
                    cons.visit_cdr();
                }

            } 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 new_cons = set_car ? cons.visit_Cons_car() : cons.visit_Cons_cdr();
                new_cons.visit();
                list_contents(new_cons);
                new_cons.visitEnd();
                match(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.º 7
0
 void dot_tail(ConsVisitor cons)
 {
     if (Token.DOT == lookahead) {
         match(Token.DOT);
         datum(cons, false);
     } else {
         throw new SyntaxError(m_attrib.loc, lookahead, Token.DOT);
     }
 }
Ejemplo n.º 8
0
        void datum(ConsVisitor cons, bool set_car)
        {
            if (Token.BOOL == lookahead ||
                Token.NUM == lookahead ||
                Token.CHAR == lookahead ||
                Token.STRING == lookahead ||
                Token.ID == lookahead) {

                AtomVisitor atom = set_car ? cons.visit_Atom_car() : cons.visit_Atom_cdr();
                //atom.visit();
                simple_datum(atom);
                //atom.visitEnd();
            } else if (Token.OPEN_PAREN == lookahead) {
                match(Token.OPEN_PAREN);
                list(cons, set_car);
            } else if (
                Token.QUOTE == lookahead ||
                Token.BACKQUOTE == lookahead ||
                Token.COMMA == lookahead ||
                Token.SPLICE == lookahead) {

                ConsVisitor new_cons = set_car ? cons.visit_Cons_car() : cons.visit_Cons_cdr();
                new_cons.visit();
                abbreviation(new_cons);
                new_cons.visitEnd();
            } else if (Token.VECTOR == lookahead) {
                VectVisitor vec = set_car ? cons.visit_Vect_car() : cons.visit_Vect_cdr();
                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.º 9
0
 public ConsMultiVisitor(ConsVisitor car, ConsVisitor cdr)
 {
     this.car = car;
     this.cdr = cdr;
 }