c++syntax-errorlazy-c++

LZZ syntax error for typedef enum _foo { a } foo;


Why does LZZ tell me that the line typedef enum _foo { a } foo; has a syntax error?

Test.lzz:1:19: Syntax error before '{'.
Test.lzz:1:1: Discarding 'typedef'.
Test.lzz:1:28: Syntax error before ';'.
Test.lzz:1:28: Inserting '<identifier>' before ';'.

Solution

  • From the documentation:

    Unlike a real C++ parser, Lzz does not maintain a type and template name database. Lzz parses using context information only. However, because the C++ grammar is ambiguous this strategy is inadequate in several contexts; fortunately, Lzz can skip over most of them.

    This tool doesn't accept C++ as its input; it accepts a cut-down language that looks vaguely like C++, producing C++ as its output. If you want to use it, you will have to learn its own language, and hope that it's adequate for the code you want to write. Personally, I'd suggest you stick to Standard C++, since that language is well documented and widely understood.