Version 0 of GSoC Idea: Parser For expr Command

Updated 2012-02-29 08:49:15 by SEH

Parser For expr Command

Areas Language parsing, computer arithmetic
Good if student knows variable, based on interests
Priority Low
Difficulty low to medium
Benefits to the student introduction to grammar and parsing concepts
Benefits to Tcl Leverage ease of use of existing tools
Mentor Steve Huntley

Project Description

Perl enables arbitrary precision math by means of a pragma, which overloads the standard math operators and thus transparently accepts large integers as arguments for mathematical expressions. In this way Perl is able to do not only large integer math transparently as Tcl does, but also floating-point, rational number, vector, etc. calculations [L1 ] [L2 ].

This approach could not work with Tcl, since it does not have math operators per se, but instead has the command expr with its own syntax for math expressions. However, it should be straightforward to overload the expr command itself; with a command that is able to parse existing valid math expressions, and can be expanded to accept a wider range of operations.

The goal of this project would be to write a selection of parsers/lexers for mathematical expressions, and incorporate them into a replacement for the expr command, thus allowing for transparent use of a wider range of numerical types (similar to Perl's usage), and experiments on new ways to execute expressions that are currently valid, such as:

  • compiling to C statements and executing via critcl
  • compiling to bytecode using methods outlined by KK [L3 ]
  • automatic interfacing to graphing functions

The exact mix of features would be dependent on the skills and interests of the student.

Existing pure-Tcl parsing tools such as Yeti or taccle should be suitable for the task. Evaluation of parser features and selection of tools would be part of the project.

Requirements:

  • flexible