Overview ^

This is an implementation of 'POSIX bc' for Parrot. 'bc' is an arbitrary precision calculator dating back from Unix stone age. See http://en.wikipedia.org/wiki/Bc_%28Unix%29 for details. This implementation is based on Python classes generated by ANTLR.

Why Parrot bc ^

Self education. A fairly simple language but has symbols and subroutines. Test for decimal bignum libraries. A starting point for more interesting languages like R, GDL, JavaScript.

Strategy ^

The language grammar is in grammar/bc_python.g. ANTLR2 takes the grammar and generates Python classes for lexer, parser and tree parser. The driver program bc.py takes bc source and generates PIR. The generated PIR sets up a PAST data structure, and from there on Allison Randalls TGE takes over.

Current state ^

The PAST generation is underway. Currently 'bc' is tranlated directly into PIR.

Vision ^

Do the code generation like bc -> PAST (punie) -> PIR. Be compatible with Pirate and Pugs. Switch to ANTLR3 and let ANTLR3 create parser, lexer and treewalker in PIR. When that is achieved, 'Parrot bc' would need only 'parrot' at compile and run time.

SEE ALSO ^

  L<http://www.funet.fi/pub/doc/posix/p1003.2/d11.2/4.3>
  L<http://en.wikipedia.org/wiki/Bc_%28Unix%29>
  L<http://parrotcode.org>
  L<http://pugscode.org>
  L<http://pirate.tangentcode.com/>
  L<http://www.javadude.com/articles/antlrtut/>
  L<http://svn.lohutok.net/nam/trunk/parrot/docs/compiler_tools.pod>


parrot