summaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2010-03-05 08:26:37 +0000
committerMorgan Deters <mdeters@gmail.com>2010-03-05 08:26:37 +0000
commit88b52c971b43248e6ceacf1c8140a06427d0418d (patch)
tree4ee443c898a858fcdd658f3f043e4180eddd8784 /src/parser
parent29cc307cdf2c42bebf4f5615874a864783f47fd0 (diff)
* public/private code untangled (smt/smt_engine.h no longer #includes
expr/node.h). This removes the warnings we had during compilation, and heads off a number of potential linking errors due to improper inlining of private (library-only) stuff in client (out-of-library) code. * "configure" now takes some options as part of a "bare-option" build type (e.g., "./configure debug-coverage" or "./configure production-muzzle"). * split cdo.h, cdlist.h, cdmap.h, and cdset.h from context.h * split cdlist_black unit test from context_black * implement CDMap<>. * give ExprManagers ownership of the context (and have SmtEngine share that one) * fix main driver to properly report file-not-found * fix MemoryMappedInputBuffer class to report reasons for "errno"-returned system errors * src/expr/attribute.h: context-dependent attribute kinds now supported * test/unit/expr/node_white.h: context-dependent attribute tests * src/prop/cnf_conversion.h and associated parts of src/util/options.h and src/main/getopt.cpp: obsolete command-line option, removed. * src/util/Assert.h: assertions are now somewhat more useful (in debug builds, anyway) during stack unwinding. * test/unit/theory/theory_black.h: test context-dependent behavior of registerTerm() attribute for theories * src/expr/node_builder.h: formatting, fixes for arithmetic convenience node builders, check memory allocations * test/unit/expr/node_builder_black.h: add tessts for addition, subtraction, unary minus, and multiplication convenience node builders * src/expr/attribute.h: more comments * (various) code formatting, comment cleanup, added throws specifier to some destructors * contrib/code-checker: prototype perl script to test (some) code policy * contrib/indent-settings: command line for GNU indent to indent using CVC4 style (sort of; this is a work in progress) * COPYING: legal stuff * DESIGN_QUESTIONS: obsolete, removed
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/antlr_parser.cpp8
-rw-r--r--src/parser/memory_mapped_input_buffer.h36
-rw-r--r--src/parser/parser.cpp8
-rw-r--r--src/parser/parser_exception.h4
-rw-r--r--src/parser/symbol_table.h4
5 files changed, 32 insertions, 28 deletions
diff --git a/src/parser/antlr_parser.cpp b/src/parser/antlr_parser.cpp
index 6eb269bca..e2949286a 100644
--- a/src/parser/antlr_parser.cpp
+++ b/src/parser/antlr_parser.cpp
@@ -171,10 +171,10 @@ const Type* AntlrParser::predicateType(const std::vector<const Type*>& sorts) {
Expr
AntlrParser::mkVar(const std::string& name, const Type* type) {
Debug("parser") << "mkVar(" << name << "," << *type << ")" << std::endl;
- Assert( !isDeclared(name) ) ;
+ Assert( !isDeclared(name) );
Expr expr = d_exprManager->mkVar(type, name);
d_varSymbolTable.bindName(name, expr);
- Assert( isDeclared(name) ) ;
+ Assert( isDeclared(name) );
return expr;
}
@@ -192,10 +192,10 @@ AntlrParser::mkVars(const std::vector<std::string> names,
const Type*
AntlrParser::newSort(const std::string& name) {
Debug("parser") << "newSort(" << name << ")" << std::endl;
- Assert( !isDeclared(name, SYM_SORT) ) ;
+ Assert( !isDeclared(name, SYM_SORT) );
const Type* type = d_exprManager->mkSort(name);
d_sortTable.bindName(name, type);
- Assert( isDeclared(name, SYM_SORT) ) ;
+ Assert( isDeclared(name, SYM_SORT) );
return type;
}
diff --git a/src/parser/memory_mapped_input_buffer.h b/src/parser/memory_mapped_input_buffer.h
index c92e62524..e1639a072 100644
--- a/src/parser/memory_mapped_input_buffer.h
+++ b/src/parser/memory_mapped_input_buffer.h
@@ -11,16 +11,19 @@
** ANTLR input buffer from a memory-mapped file.
**/
-#ifndef MEMORY_MAPPED_INPUT_BUFFER_H_
-#define MEMORY_MAPPED_INPUT_BUFFER_H_
+#ifndef __CVC4__PARSER__MEMORY_MAPPED_INPUT_BUFFER_H
+#define __CVC4__PARSER__MEMORY_MAPPED_INPUT_BUFFER_H
+
+#include <cstdio>
+#include <cerrno>
#include <fcntl.h>
-#include <stdio.h>
#include <stdint.h>
+#include <string.h>
-#include <sys/errno.h>
#include <sys/mman.h>
#include <sys/stat.h>
+
#include <antlr/InputBuffer.hpp>
#include "util/Assert.h"
@@ -33,32 +36,34 @@ class MemoryMappedInputBuffer : public antlr::InputBuffer {
public:
MemoryMappedInputBuffer(const std::string& filename) {
- errno = 0;
struct stat st;
if( stat(filename.c_str(), &st) == -1 ) {
- throw Exception("unable to stat() file");
-// throw Exception( "unable to stat() file " << filename << " errno " << errno );
+ char buf[80];
+ const char* errMsg = strerror_r(errno, buf, sizeof(buf));
+ throw Exception("unable to stat() file `" + filename + "': " + errMsg);
}
d_size = st.st_size;
int fd = open(filename.c_str(), O_RDONLY);
if( fd == -1 ) {
- throw Exception("unable to fopen() file");
+ char buf[80];
+ const char* errMsg = strerror_r(errno, buf, sizeof(buf));
+ throw Exception("unable to fopen() file `" + filename + "': " + errMsg);
}
d_start = static_cast< const char * >(
mmap( 0, d_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0 ) );
- errno = 0;
if( intptr_t( d_start ) == -1 ) {
- throw Exception("unable to mmap() file");
-// throw Exception( "unable to mmap() file " << filename << " errno " << errno );
+ char buf[80];
+ const char* errMsg = strerror_r(errno, buf, sizeof(buf));
+ throw Exception("unable to mmap() file `" + filename + "': " + errMsg);
}
d_cur = d_start;
d_end = d_start + d_size;
}
~MemoryMappedInputBuffer() {
- munmap((void*)d_start,d_size);
+ munmap((void*) d_start, d_size);
}
inline int getChar() {
@@ -71,8 +76,7 @@ private:
const char *d_start, *d_end, *d_cur;
};
-}
-}
-
+}/* CVC4::parser namespace */
+}/* CVC4 namespace */
-#endif /* MEMORY_MAPPED_INPUT_BUFFER_H_ */
+#endif /* __CVC4__PARSER__MEMORY_MAPPED_INPUT_BUFFER_H */
diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp
index 852eda595..a129d97ee 100644
--- a/src/parser/parser.cpp
+++ b/src/parser/parser.cpp
@@ -18,12 +18,12 @@
#include <antlr/CharScanner.hpp>
#include <antlr/CharBuffer.hpp>
-#include "parser.h"
-#include "memory_mapped_input_buffer.h"
+#include "parser/parser.h"
+#include "parser/memory_mapped_input_buffer.h"
#include "expr/command.h"
#include "util/output.h"
#include "util/Assert.h"
-#include "parser_exception.h"
+#include "parser/parser_exception.h"
#include "parser/antlr_parser.h"
#include "parser/smt/generated/AntlrSmtParser.hpp"
#include "parser/smt/generated/AntlrSmtLexer.hpp"
@@ -125,7 +125,7 @@ Parser* Parser::getNewParser(ExprManager* em, InputLanguage lang,
Parser* Parser::getMemoryMappedParser(ExprManager* em, InputLanguage lang, string filename) {
MemoryMappedInputBuffer* inputBuffer = new MemoryMappedInputBuffer(filename);
- return getNewParser(em,lang,inputBuffer,filename);
+ return getNewParser(em, lang, inputBuffer, filename);
}
Parser* Parser::getNewParser(ExprManager* em, InputLanguage lang,
diff --git a/src/parser/parser_exception.h b/src/parser/parser_exception.h
index e30398824..f0ddc6a7f 100644
--- a/src/parser/parser_exception.h
+++ b/src/parser/parser_exception.h
@@ -24,14 +24,14 @@
namespace CVC4 {
namespace parser {
-class CVC4_PUBLIC ParserException: public Exception {
+class CVC4_PUBLIC ParserException : public Exception {
public:
// Constructors
ParserException() { }
ParserException(const std::string& msg): Exception(msg) { }
ParserException(const char* msg): Exception(msg) { }
// Destructor
- virtual ~ParserException() { }
+ virtual ~ParserException() throw() {}
virtual std::string toString() const {
return "Parse Error: " + d_msg;
}
diff --git a/src/parser/symbol_table.h b/src/parser/symbol_table.h
index 5838790a8..4ab2fb521 100644
--- a/src/parser/symbol_table.h
+++ b/src/parser/symbol_table.h
@@ -35,7 +35,7 @@ struct StringHashFcn {
/**
* Generic symbol table for looking up variables by name.
*/
-template<typename ObjectType>
+template <class ObjectType>
class SymbolTable {
private:
@@ -85,7 +85,7 @@ public:
ObjectType getObject(const std::string& name) throw () {
table_iterator find = d_nameBindings.find(name);
Assert(find != d_nameBindings.end());
- return find->second /*.top()*/ ;
+ return find->second; /*.top()*/
}
/**
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback