Exemplo n.º 1
0
        void simple_datum(AtomVisitor atom)
        {
            if (Token.BOOL == lookahead) {
                if (m_attrib.value is bool) {
                    atom.visit((Boolean)m_attrib.value);
                } else {
                    throw new TypeExpected(m_attrib.loc, "bool");
                }

                match(Token.BOOL);
            } else if (Token.NUM == lookahead) {
                if (m_attrib.value is long) {
                    atom.visit((long)m_attrib.value);
                } else if (m_attrib.value is float) {
                    atom.visit((float)m_attrib.value);
                } else if (m_attrib.value is double) {
                    atom.visit((double)m_attrib.value);
                } else if (m_attrib.value is Complex) {
                    atom.visit((Complex)m_attrib.value);
                } else if (m_attrib.value is Rational) {
                    atom.visit((Rational)m_attrib.value);
                } else {
                    throw new TypeExpected(m_attrib.loc, "long, float, double, Complex, or Rational");
                }

                match(Token.NUM);
            } else if (Token.CHAR == lookahead) {
                if (m_attrib.value is char) {
                    atom.visit((char)m_attrib.value);
                } else {
                    throw new TypeExpected(m_attrib.loc, "char");
                }

                match(Token.CHAR);
            } else if (Token.STRING == lookahead) {
                if (m_attrib.value is string) {
                    atom.visit((string)m_attrib.value);
                } else {
                    throw new TypeExpected(m_attrib.loc, "string");
                }

                match(Token.STRING);
            } else if (Token.ID == lookahead) {
                if (m_attrib.value is Symbol) {
                    atom.visit((Symbol)m_attrib.value);
                } else {
                    throw new TypeExpected(m_attrib.loc, "Symbol");
                }

                match(Token.ID);
            } else {
                throw new SyntaxError(m_attrib.loc, lookahead, Token.BOOL, Token.NUM, Token.CHAR, Token.STRING, Token.ID);
            }
        }
Exemplo n.º 2
0
 public SafeAtomVisitor(AtomVisitor atom)
 {
     m_atom = atom;
 }
Exemplo n.º 3
0
 public AtomMultiVisitor(AtomVisitor car, AtomVisitor cdr)
 {
     this.car = car;
     this.cdr = cdr;
 }