Skip to content

Commit

Permalink
Fix C++ parser to handle e.g. std::pair<int,double>
Browse files Browse the repository at this point in the history
Closes #7

Bump to version 0.2.6
  • Loading branch information
dail8859 committed Aug 3, 2015
1 parent fcefe5a commit 2bdee3d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
17 changes: 15 additions & 2 deletions Parsers/C_Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,21 @@ Keywords Parse_C(const ParserDefinition *pd, const char *text)
std::vector<std::string> params;
std::vector<std::string> function;
const TRexChar *begin,*end;
char *dup, *p;
int chevron = 0;

if(trex_search(tr_function, text, &begin, &end))
// HACK: Duplicate the string so it can be modified and any commas within <...> needs removed to support templates e.g. std::pair<int, double>
dup = strdup(text);
p = dup;
while (*p)
{
if (*p == '<') chevron++;
else if (*p == '>') chevron--;
else if (*p == ',' && chevron > 0) *p = ' ';
p++;
}

if (trex_search(tr_function, dup, &begin, &end))
{
TRexMatch params_match, func_match;
const TRexChar *cur_params;
Expand Down Expand Up @@ -81,6 +94,6 @@ Keywords Parse_C(const ParserDefinition *pd, const char *text)
keywords["$PARAM"] = params;
keywords["$FUNCTION"] = function;
}

free(dup);
return keywords;
}
8 changes: 4 additions & 4 deletions Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#define VERSION_NUM 0,2,5,0
#define VERSION_LINEAR 250
#define VERSION_LINEAR_TEXT TEXT("250")
#define VERSION_TEXT TEXT("0.2.5") // This must match the tag pushed on the server minus the "v"
#define VERSION_NUM 0,2,6,0
#define VERSION_LINEAR 260
#define VERSION_LINEAR_TEXT TEXT("260")
#define VERSION_TEXT TEXT("0.2.6") // This must match the tag pushed on the server minus the "v"
#define VERSION_STAGE TEXT("") // "alpha", "beta", ""
2 changes: 2 additions & 0 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ void Class::Method(int x, float pi = 3.14)

void Class::Method(std::mystring = std::string()) // This doesn't work, but should

void function(std::pair<int, std::pair<float, double>> p, int x)

Constructor(int x) // bug if space is before parenthesis

~Destructor()

0 comments on commit 2bdee3d

Please sign in to comment.