-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The C++ resource management is much easier and more secure. This simplified the parse function and fixed a resource leak therein.
- Loading branch information
Showing
4 changed files
with
73 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef __SCANNER_HPP__INCLUDED__ | ||
#define __SCANNER_HPP__INCLUDED__ | ||
|
||
#undef yyFlexLexer | ||
#include <FlexLexer.h> | ||
#include "parser.hxx" | ||
|
||
// Tell flex which function to define | ||
#ifdef YY_DECL | ||
# undef YY_DECL | ||
#endif | ||
#define YY_DECL \ | ||
int yy::scanner::lex( \ | ||
yy::parser::semantic_type* yylval, \ | ||
yy::parser::location_type* yylloc) | ||
|
||
|
||
namespace yy | ||
{ | ||
// To feed data back to bison, the yylex method needs yylval and | ||
// yylloc parameters. Since the yyFlexLexer class is defined in the | ||
// system header <FlexLexer.h> the signature of its yylex() method | ||
// can not be changed anymore. This makes it necessary to derive a | ||
// scanner class that provides a method with the desired signature: | ||
|
||
class scanner : public yyFlexLexer | ||
{ | ||
public: | ||
explicit scanner(std::istream* in=0, std::ostream* out=0); | ||
|
||
int lex(parser::semantic_type* yylval, | ||
parser::location_type* yylloc); | ||
}; | ||
} | ||
|
||
#endif // include guard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters