Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 8 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

Building a constraints language with AntLR

At 10:59 AM on Jun 23, 2006, Matthew Schmidt wrote:

Julien Ponge of IzPack fame has written a new article describing how you can build a simple constraints language using the open source AntLR parser generator. This article walks you through the steps needed to build this language and start using it in your applications.

Read the whole article now.
1 . At 12:31 PM on Jun 23, 2006, Prashant Deva wrote:
  Click to reply to this thread Reply

Re: Building a constraints language with AntLR

In the lexer, instead of -

WS : (' ' | '\n' | '\r' | '\t')
  {
	  $setType(Token.SKIP);
  };


you should do -

WS
	: (	' '
	|	'\t'
	|	'\n'	{ newline(); }
	|	'\r' ('\n')?	{ newline(); }
	)
	{$setType(Token.SKIP);}
	;

The call to 'newline()' will ensure the parser records the correct line no and column.

Had you used the 'Lexer Wizard' from my eclipse plugin for ANTLR, this would have been done for you automatically ;)
Virtual Ant - Revolutionary new GUI for Apache Ant
2 . At 1:23 PM on Jun 23, 2006, Julien Ponge wrote:
  Click to reply to this thread Reply

Re: Building a constraints language with AntLR

Thanks for the tip ;-)
Julien Ponge - IzPack project founder.
3 . At 8:08 PM on Jun 23, 2006, Will Hartung DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Building a constraints language with AntLR

Back when I had to write a scripting language, I had essentially no experience with Lex, Yacc or Antlr.

This was several years ago, and no doubt Antlr has advanced since then, but it was quite a leap to try and understand it.

Instead, I found SableCC (http://sablecc.org/), and found for my purposes it was simple to use and easy to understand.

The other thing I particularly liked about SableCC is that there is no code in the Grammar. The Grammar is simply the Grammar, all of you code is written in a Visitor class based on the Grammar.

I don't really want to get in to any debate whether one technique is better than the other or who's tool is more powerful.

Rather, I just wanted to point out an alternative. While Antlr has probably evolved past Lex/Yacc, it's still very much inspired by them, and that made it, for me, hard to pick up as a novice in these tools. I found SableCC easier. If you struggled in the past with these tools, check it out.
4 . At 12:20 AM on Jun 24, 2006, Prashant Deva wrote:
  Click to reply to this thread Reply

Re: Building a constraints language with AntLR

Well, you probably havent noticed the tool support that is now available for ANTLR.

I know this is not too modest of me to mention this, but my plugin ANTLR Studio can make writing and debugging ANTLR grammars far easier and faster than using Lex, Yacc, SableCC all combined.

For example, my debugger can walk you live through your grammar while debugging your java code and show you the live parse trees, ASTs, input text, etc.

Also the Lexer Wizard can generate within 5 minutes a complex lexer which will take you hours and hours in lex or SableCC to get right.

As far as making sense of ANTLR grammars is concerned, I wrote an article showing how simple it really is :)
Virtual Ant - Revolutionary new GUI for Apache Ant
5 . At 6:31 PM on Jun 26, 2006, Daniel MD wrote:
  Click to reply to this thread Reply

Re: Building a constraints language with AntLR

Yeah but those tools are open source or free, your plugin is not ;)

Single User License 99$
6 . At 5:52 AM on Jun 27, 2006, Prashant Deva wrote:
  Click to reply to this thread Reply

Re: Building a constraints language with AntLR

Yes, but the time you save from using my tool would be far greater than $99 ;)

Also this is far cheaper and has more features than most parsing tools which cost >500$.
Virtual Ant - Revolutionary new GUI for Apache Ant
7 . At 3:48 PM on Aug 11, 2006, mark wrote:
  Click to reply to this thread Reply

Example available? [Building a constraints language with AntLR]

Julien: This is really great. Do you have the complete example/package available for download? The links for IConstraintNode & IRootConstraintNode are invalid.

Thanks.
8 . At 8:57 PM on Aug 11, 2006, Julien Ponge wrote:
  Click to reply to this thread Reply

Re: Example available? [Building a constraints language with AntLR]

Hi Mark,

The links are wrong: wherever you see links you should put '[' and ']' around. I can't make anything available for download since that's part of unpublished research work, but nevertheless the idea was to show the essence of building that kind of language with AntLR.

Cheers
Julien Ponge - IzPack project founder.

thread.rss_message