2008 Oct 5, 9:17
Sarah asked me if I knew of a syntax highlighter for the QuickBase formula language which she uses at work. I couldn't find one but thought it might be fun to make a QuickBase Formula syntax highlighter based on the QuickBase help's
description of the formula syntax. Thankfully the language is relatively simple since my skills with ANTLR, the parser generator, are rusty now and I've only
used it previously for personal projects (like Javaish, the ridiculous Java based shell idea I had).
With the help of some great ANTLR examples and an ANTLR cheat
sheet I was able to come up with the grammar that parses the QuickBase Formula syntax and prints out the same formula marked up with HTML SPAN tags and various CSS classes. ANTLR produces the
parser in Java which I wrapped up in an applet, put in a jar, and embedded in an HTML page. The script in that page runs user input through the applet's parser and sticks the output at the bottom
of the page with appropriate CSS rules to highlight and print the formula in a pretty fashion.
What I learned:
- I didn't realize that Java applets are easy to use via script in an HTML page. In the JavaScript I
can simply refer to publicly exposed methods on the applet and run JavaScript strings through them. It makes for a great combination: do the heavy coding in Java and do the UI in HTML. I may end up
doing this again in the future.
- I love ANTLRWorks, the ANTLR IDE, that didn't exist the last time I used ANTLR. It tells you about issues with your grammar as you create it,
lets you easily debug the grammar running it forwards and backwards, display parse trees, and other useful things.
java technical programming quickbase language antlr antlrworks 2008 Oct 2, 9:37Cool graphical ANTLR IDE! They didn't have this the last time I used ANTLR. "ANTLRWorks is a novel grammar development environment for ANTLR v3 grammars written by Jean Bovet (with suggested use
cases from Terence Parr). It combines an excellent grammar-aware editor with an interpreter for rapid prototyping and a language-agnostic debugger for isolating grammar errors. ANTLRWorks helps
eliminate grammar nondeterminisms, one of the most difficult problems for beginners and experts alike, by highlighting nondeterministic paths in the syntax diagram associated with a grammar."
antlr ide graph grammar tool free download development opensource java 2008 Oct 2, 9:28Some good example grammars for ANTLR.
antlr example reference grammar 2008 Oct 2, 9:26Cheat sheet on ANTLR's syntax. ANTLR's another language parser generator.
antlr cheat parser language grammar opensource java software syntax quickreference