I hope subscribers to this list will be interested in a generalised language toolkit that I have published under Gnu GPL. The toolkit is written in the D language using the gdc D language frontend to gcc, and it includes the beginnings of a GENERIC interface with gcc4, as well as an interface to libtcc, the tiny C compilation library. The toolkit itself is at

http://languagemachine.sourceforge.net

This is a complete rewrite of software that I developed and used in real projects over a long period that began in 1975. The software consists of:

  * a shared library which implements the grammatical engine
  * a minimal main program
  * several different flavours of a metalanguage compiler
  * an application that generates the web pages from wiki-style text
  * a D language processor with a D language generator backend
* examples including forward polish, reverse polish and infix calculator examples * an infix calculator example that compiles C code for immediate execution using libtcc
  * experiments with a gcc interface

The language machine is intended to be useful across a wide range of applications, from quick'n'dirty text mungers upwards - anything that has a linguistic or grammatical component. The LMN metalanguage compiles to rules wrapped as shebang scripts, to rules wrapped in the C and D languages, and to rules compiled as (slightly odd) C and D language procedures, and it's quite easy to call external procedures in the C and D languages. A nice feature is that the source text format is compatible with wikimedia markup conventions, so some of the web pages (including the metalanguage definition) are generated directly from the LMN source text.

The beginnings of an interface to gcc4 can be found at

http://languagemachine.sourceforge.net/gcc_interface.html

The infix calculator that directly generates and executes C code using libtcc is at

http://languagemachine.sourceforge.net/tcc_calc.html

The neat thing about the language machine is that it lets you play directly with the fundamentals of language. The engine can generate a diagram that explains exactly how rules are applied: it turns out that an engine that directly and efficiently implements the most general kind of recognition grammar is very much like a macro processor that lets you define your own syntax as part of the macro definition. It does this in a way that lets you concentrate on recognising and transforming patterns that happen to contain nonterminal symbols. Going at it this way, you can do everything from lexical analysis to code generation.

In technical terms, the language machine directly implements analytic or recognition grammars with absolutely no restriction on the kind of rewriting rules that you can usefully use - each side of a rule can contain any number of symbols, and either side can usefully be empty. There is an explanation of how this approach fits into accepted ideas about language at

http://languagemachine.sourceforge.net/grammar.html

I hope some of you will share my excitement at the possiblities that can arise when this beast has a live interface to the GCC code generators, and that some of you can help make it happen.

Peri Hankey

--
http://languagemachine.sourceforge.net - The language machine

Reply via email to