lexer working with pcre, not building any objects for handling tokens yet
This commit is contained in:
1 parent
25888fe55a
commit
96010ea9ae
5 files changed
+37
-5
No files matched your search
+11
-1
@@ -88,7 +88,7 @@ bool I_CLASSNAME::parse(istream & i)
|
||||
while (buff_pos < buff_size)
|
||||
{
|
||||
int longest_match_length = 0;
|
||||
int longest_match_index;
|
||||
int longest_match_index = -1;
|
||||
int longest_match_ovector[ovector_size];
|
||||
for (int i = 0; i < sizeof(tokens)/sizeof(tokens[0]); i++)
|
||||
{
|
||||
@@ -108,6 +108,16 @@ bool I_CLASSNAME::parse(istream & i)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (longest_match_index >= 0)
|
||||
{
|
||||
cout << "Matched a " << tokens[longest_match_index].name << endl;
|
||||
buff_pos += longest_match_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no pattern matched the input at the current position */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user