Parsing Signed Numbers in ANTLR

One of the more interesting things I’ve been working on lately is a scripting language to drive a simulation system. It describes nominal values of key parameters, how to vary them, do an analysis, gather the results and present those results. ANTLR and ANTLRWorks are usually great tools to create the lexer and parser of such a scripting language. That’s how I started out this time too. Since I thought it would be trivial, I left parsing signed numbers to nearly the end of the project. It was a bit of a surprise how difficult this was.