Harmonia
 Harmonia-Mode User's Guide Printer-Friendly Version  

Introduction

This is the first public software release for the Harmonia project. It consists of Harmonia-Mode, a demonstration application for the Harmonia Framework. Harmonia-Mode is an editing mode for XEmacs, like java-mode and c-mode. It demonstrates a set of enhanced editing features enabled by the Harmonia Framework.


An example of Harmonia-Cool-Mode


Harmonia-Mode

Harmonia-mode provides editing features to your XEmacs document as you're editing. Some of these features include syntax highlighting, proper (Emacs-style) indentation, visual indications of compile errors, and pop-up menus that provide semantic information (such as the definition of a particular symbol). No doubt, you have have seen many of these features provided by higher-end commercial editors, such as Visual Studio, Eclipse or Metrowerks CodeWarrior. In the Harmonia-mode world, however, we don't stop there. Harmonia-mode also provides you with structural browsing, navigation and search capabilities, and structural elision (on a buffer-by-buffer basis for this first version). Best of all, Harmonia-mode is language-independent, meaning that support for a particular programming language is provided via plugin module, giving the programmer access to all of these features in any language in which he or she wishes to program.

Harmonia Language Support

Harmonia supports the following languages in this second release.

Language Versions Supported
C C99, GNU C
Java Java 2 v1.4.2
Scheme R5RS
Cool 2002 (used in CS164 compiler course at UC Berkeley)
Titanium 2.630 (September 2004)

We are planning to support many more languages in the future. Not yet released, but in various stages of development are language plug-ins for Cobol, Common Lisp, C++, JavaScript, Regular expressions, SRCL (used in IBM ViaVoice), Tcl, and XML.

How Harmonia Works

Harmonia runs three compiler analyses on your XEmacs buffer: lexing, parsing (syntax) and semantic analysis. Conceptually, all of these analyses happen on every keystroke (actually, they occur at varying times between keystrokes). Thus, it is important to make the analyses fast, so they don't get in the way. Both lexing and parsing are incremental, meaning they take time proportional to the size of the change you make. Semantics is non-incremental (currently), but in the languages supported does not take any perceptible amount of time (less than 20-30 ms on average).

Using the results of these analyses, Harmonia-mode will supply you with syntax highlighting, indentation, error-detection, and a few other features. Note that you won't gain the benefit of some of these features in sections of your program that are not syntactically correct. Syntax highlighting uses lexical (non-structural) information, and will most often exist and appear to be correct. Indentation has been engineered to use lexical information when the syntax tree is not available. Error detection and other services are usually based on Harmonia's access to the parse tree of your program, thus they will only work in areas of your program that are (or were) syntactically correct. Harmonia-mode remembers the structure of your program as you edit it, but if you type a new method declaration from scratch, it won't know what type signature it has until you type the last semicolon.


siize is a misspelled identifer in Harmonia-Cool-Mode

Just like a C, Java, Titanium or Cool compiler (or Scheme interpreter/compiler), Harmonia-mode will not be able to run its semantic analyses unless the syntax analysis ran without finding errors.

Note: Harmonia-Mode is not a replacement for a compiler. Harmonia-Mode will not generate code, nor will it plug into the backend of your compiler to do so. All analyses performed in Harmonia-Mode are used only within the editor.


The Future

In the future, we will be releasing the full source code for Harmonia, including the tools we use to build language modules. This will enable you to write language modules for your own languages, as well as see how we designed and implemented our analysis technology.

Next Section: Installation