Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions checktestdata.l
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,22 @@ SCIENTIFIC { return Parser::OPT_SCIENTIFIC; }

\" {
/* begin of string */
#if ( FLEXCPP_VERSION >= 20700LL )
begin(StartCondition_::string);
#else
begin(StartCondition__::string);
#endif
}

<string>{
\" {
/* end of string */
setMatched(matched().substr(0,matched().length()-1));
#if ( FLEXCPP_VERSION >= 20700LL )
begin(StartCondition_::INITIAL);
#else
begin(StartCondition__::INITIAL);
#endif
return Parser::STRING;
}

Expand Down
16 changes: 16 additions & 0 deletions parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,34 @@ class Parser: public ParserBase
parse_t parseResult;

private:
#if ( BISONCPP_VERSION >= 60000LL )
void error(); // called on (syntax) errors
#else
void error(char const *msg);
#endif
int lex(); // returns the next token from the
// lexical scanner.
void print(); // use, e.g., d_token, d_loc
#if ( BISONCPP_VERSION >= 60000LL )
void exceptionHandler(std::exception const &exc);
#else
void exceptionHandler__(std::exception const &exc);
#endif

// support functions for parse():
#if ( BISONCPP_VERSION >= 60000LL )
void executeAction_(int ruleNr);
void errorRecovery_();
void nextCycle_();
void nextToken_();
void print_();
#else
void executeAction(int ruleNr);
void errorRecovery();
int lookup(bool recovery);
void nextToken();
void print__();
#endif
};


Expand Down
14 changes: 12 additions & 2 deletions parser.ih
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,37 @@
#include "parser.h"


#if ( BISONCPP_VERSION >= 60000LL )
inline void Parser::error()
#else
inline void Parser::error(char const *msg)
#endif
{
std::cerr << "Syntax error\n";
std::cerr << "Syntax error on line " << d_scanner.lineNr() << std::endl;
}

// $insert lex
inline int Parser::lex()
{
int res = d_scanner.lex();
#if ( BISONCPP_VERSION >= 60000LL )
d_val_ = STYPE_(d_scanner.matched());
#else
d_val__ = STYPE__(d_scanner.matched());
#endif
return res;
}

inline void Parser::print()
{
}

inline void Parser::exceptionHandler(std::exception const &exc)
#if ( BISONCPP_VERSION < 60000LL )
inline void Parser::exceptionHandler__(std::exception const &exc)
{
throw; // re-implement to handle exceptions thrown by actions
}
#endif


// Add here includes that are only required for the compilation
Expand Down
23 changes: 22 additions & 1 deletion scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,23 @@ class Scanner: public ScannerBase
int lex();

private:
#if ( FLEXCPP_VERSION >= 20700LL )
int lex_();
int executeAction_(size_t ruleNr);
#else
int lex__();
int executeAction__(size_t ruleNr);
#endif

void print();
void preCode(); // re-implement this function for code that must
// be exec'ed before the patternmatching starts

#if ( FLEXCPP_VERSION >= 20700LL )
void postCode(PostEnum_ type);
#else
void postCode(PostEnum__ type);
#endif
// re-implement this function for code that must
// be exec'ed after the rules's actions.
};
Expand All @@ -67,22 +76,34 @@ inline int Scanner::lex()
parserStart = 0;
return res;
}
#if ( FLEXCPP_VERSION >= 20700LL )
return lex_();
#else
return lex__();
#endif
}

inline void Scanner::preCode()
{
// optionally replace by your own code
}

inline void Scanner::postCode([[maybe_unused]] PostEnum_ type)
#if ( FLEXCPP_VERSION >= 20700LL )
inline void Scanner::postCode(PostEnum_ type)
#else
inline void Scanner::postCode(PostEnum__ type)
#endif
{
// optionally replace by your own code
}

inline void Scanner::print()
{
#if ( FLEXCPP_VERSION >= 20700LL )
print_();
#else
print__();
#endif
}


Expand Down