Hello Alec,
First of all, thank you for the very powerfull tool, it is
real good. I hope you did not leave it and continue the
tech support, because I meet very big problem while
using the CppCC and don`t know how to solve it by
myself.
I use the last windows build of your program. I need to
write a parser for a C-like language, so I based it on your
C example. The input function is looks for example like
this:
************************************
() file ()
{
externalDefinition()+
}
() externalDefinition()
{
<K_A> {cout << "a";}
| <K_B> {cout << "b";}
| <K_C> {cout << "c";}
}
************************************
and it is translated to the next loop:
************************************
void cppcc::TestParser::file ()
throw (ScanException, ParseException)
{
externalDefinition();
while ((scanner.la()->id == TestToken::K_A) ||
(scanner.la()->id == TestToken::K_B) || (scanner.la()-
>id == TestToken::K_C)) {
externalDefinition();
}
}
************************************
So when the input file contains correct data all is ok,
when it contains incorrect data, a scan exception will be
generated, but when the next token is not a K_A, K_B or
K_C but equal to the some keyword defined in scanner
(for example ')') no error will be generated but the loop
just will be finished as in normal situation. I don`t know
how I can fix this type of errors, can you help me?
I create a test program to represent this problem. It is
created as console application for MS Windows in Visual
C++, but I think there are no big problems to compile it
for the other platform.
The normal input file is 'normal.txt', when you parse it,
you will see the next output:
abccab
The file which results in scan error is 'error.txt', the
result is:
abccerror.txt: 5:1: Unexpected character 'v'.
The file with problem is 'problem.txt', the result is:
abcc
so the program finished as in normal situation but do not
complete the parsing.
Sample program