Question

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 ';'.
Was it helpful?

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.

OTHER TIPS

You see this a lot in code carried over from C. Could you not just do instead

enum foo { a }

The Lzz documentation does say that declarators after class definitions aren't supported (see class definitions under supported constructs), and it gives a few examples. The same applies to enums, though doesn't say this explicitly.

Note Lzz will allow a class (or enum) definition without a trailing semicolon.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top