diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Slice/Parser.h | 13 | ||||
-rw-r--r-- | cpp/src/Slice/Grammer.y | 2 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 26 | ||||
-rw-r--r-- | cpp/src/Slice/Scanner.l | 4 |
4 files changed, 22 insertions, 23 deletions
diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index 0513896be2d..433a32c4ff2 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -125,13 +125,14 @@ YY_DECL; int yyparse(); // -// I must set the initial bison stack depth to the maximum stack -// depth, because the bison stack extension routines use simple -// malloc/alloc, which doesn't work for C++ smart pointers with -// constructors and destructors +// I must set the initial stack depth to the maximum stack depth to +// disable bison stack resizing. The bison stack resizing routines use +// simple malloc/alloc/memcpy calls, which do not work for the +// YYSTYPE, since YYSTYPE is a C++ smart pointer, with a default +// constructor and a destructor. // -#define YYMAXDEPTH 20000 // 20000 should suffice. Default is 10000 for maximum -#define YYINITDEPTH YYMAXDEPTH // initial depth == max depth, as described above +#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. +#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. namespace Slice { diff --git a/cpp/src/Slice/Grammer.y b/cpp/src/Slice/Grammer.y index 30520b322a4..90023395846 100644 --- a/cpp/src/Slice/Grammer.y +++ b/cpp/src/Slice/Grammer.y @@ -23,6 +23,8 @@ yyerror(const char* s) %} +%pure_parser + %token ICE_SCOPE_DELIMITOR %token ICE_MODULE %token ICE_LOCAL diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 6d246ab0fe5..856c60026b5 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -161,11 +161,9 @@ Slice::Contained::Contained(const ContainerPtr& container, const string& name) : _scoped = cont->scoped(); } _scoped += "::" + _name; - if (_unit) - { - _unit->addContent(this); - _comment = _unit->currentComment(); - } + assert(_unit); + _unit->addContent(this); + _comment = _unit->currentComment(); } bool @@ -1137,13 +1135,6 @@ Slice::ClassDecl::ClassDecl(const ContainerPtr& container, const string& name, b // ClassDef // ---------------------------------------------------------------------- -void -Slice::ClassDef::destroy() -{ - _bases.clear(); - Container::destroy(); -} - OperationPtr Slice::ClassDef::createOperation(const string& name, const TypePtr& returnType, @@ -1901,7 +1892,7 @@ void Slice::Unit::error(const char* s) { cerr << _currentFile << ':' << _currentLine << ": " << s << endl; - yynerrs++; + _errors++; } void @@ -1999,6 +1990,7 @@ Slice::Unit::parse(FILE* file, bool debug) assert(!Slice::unit); Slice::unit = this; + _errors = 0; _currentComment = ""; _currentLine = 1; _currentIncludeLevel = 0; @@ -2010,9 +2002,13 @@ Slice::Unit::parse(FILE* file, bool debug) extern FILE* yyin; yyin = file; int status = yyparse(); - if (yynerrs) + if (_errors) { status = EXIT_FAILURE; + } + + if (status == EXIT_FAILURE) + { while (!_containerStack.empty()) { popContainer(); @@ -2031,8 +2027,8 @@ Slice::Unit::parse(FILE* file, bool debug) void Slice::Unit::destroy() { - _builtins.clear(); _contentMap.clear(); + _builtins.clear(); Container::destroy(); } diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 28ae3658b92..5956871df0e 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -207,7 +207,7 @@ L [a-zA-Z_] StringTokPtr ident = new StringTok; ident->v = s; - yylval = ident; + *yylvalp = ident; return ICE_IDENTIFIER; } @@ -222,7 +222,7 @@ L [a-zA-Z_] StringTokPtr ident = new StringTok; ident->v = s; ident->v.erase(ident->v.find_first_of(" \t\v\n\r\f(")); - yylval = ident; + *yylvalp = ident; return ICE_OP_IDENTIFIER; } |