[antlr-interest] Syntax validation using antlr

Andy Tripp antlr at jazillian.com
Mon Jan 19 12:13:40 PST 2009


Use ANTLR, but if you're just checking syntax and not doing any other
processing, you won't need to build an AST.

Buy "The Definitive ANTLR Reference", try a few simple examples from the
book. Then download the C grammar and try that. Read the 
"Error Reporting and Recovery" chapter of the book to produce good 
error messages. Finally, if your language really is a lot like C++,
download the C++ grammar. At some point, you'll realize that the
C++ grammar is, like the language itself, nearly infinite in complexity.
If your language really is like C++, you'll probably realize that
what you're trying is impossible. But if it's more like C with a few
extras, is should be doable.

Beware: the ANTLRv3 C grammar is new and may not be quite right yet,
and the ANTLRv3 C++ grammar doesn't exist yet.

Andy


SSG JJV wrote:
> Hello AntlrMasters,
> 
> I want to develop an antlr program that validates the syntax of a
> proprietary language similar to C++ language. For ex:
> 
> INT a, b;
> 
> I want to validate syntax and throw errors in case of syntactical errors in
> the program.
> In the above example, say if user misses semicolon at the end, i want to
> throw appropriate message to the user.
> 
> Should i use AST approach? Are there any sample 'validation programs
> developed in antlr' already available? Please advice.
> 
> Any initial guidance will be of great help.
> 
> Thanks,
> Munna
> 
> 
> ------------------------------------------------------------------------
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list