public static bool IsAtomToken(LexerToken token) { return token is TokenString || token is TokenInteger || token is TokenIdentifier; }
SExp CreateAtom(LexerToken token) { SExp atom = null; if (token is TokenLeftParen) { atom = new __LeftParen(); } else if (token is TokenInteger) { int n = 0; int.TryParse(token.Value, out n); atom = new Integer(n); } else if (token is TokenString) { atom = new String(token.Value); } else if (token is TokenIdentifier) { atom = new Identifier(token.Value); } else { string msg = string.Format("failed to create atom from token '{0}'.", token.Value); throw new ParserException(msg); } return atom; }