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 List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
