Before I answer your questions let me first start to say that there are two major classes of computing languages:
- Regular languages: Most log files follow this format. Each line is a full expression, and can be parsed separately. Essentially, all your needs can be met by just a lexer or regular expressions.
- Syntactical languages: There is a specific grammar and rules surrounding what makes proper syntax (or sentence structure). Most programming languages and even some markup languages follow this format. Essentially you need both a lexer and a parser.
If your need is parsing log files, you can probably get away with reading them line by line and using a regular expression to get the fields. If the log line is very simple, you can easily hand roll your parser and avoid the syntax ugliness of regular expressions. I've done both approaches and it's fairly quick work.
If you need something a bit more robust, then you can use ANTLR, Flex, Yacc, etc. depending on your platform needs. Understand that ANTLR, while itself is a Java tool, can generate C/C++ and C# code as well as Java code.
Now for your questions one by one:
- Is it legal? Absolutely. Most parser generators explicitly put in their licenses that the license does not apply to the generated code. If the source code is proprietary, so is the generated code that came from it.
- Am I just being afraid of writing my own parser? Only you can answer that. However, common sense says that if there is a tool to help you save time and avoid errors, you should probably use it. All the more if it doesn't cost extra money. Just make sure the tool you pick fits the job. If all you need to parse is a regular language, then don't opt for the full fledged parser generators.
- Yacc and Lex on Windows? You can use an alternative like ANTLR, or you can use the Cygwin based tools, or the Bumble-Bee port. You have options.