2014-04-23
md
National Language Support
Part 5 – Constructing a Parse Tree-> <-Part 3 – Adding Constants and Functions
 Part 4 of Parsing and Evaluating Mathematical Expressions 

This is a stub for an article that was never written. Nevertheless, NLS is implemented in the source code.

Most important applications are localized meaning that there are multiple versions adapted to different languages. Some applications go beyond translating the user interface. Function names in formulas in LibreOffice.Calc and Excel are also translated. Thus in the English version the function that returns the square root of a number is called SQRT while in the French version it is called RACINE.

Translation of function names is only one aspect of supporting national languages. Interchange is another. When a spreadsheet is first created and saved with a localized French version and then it is opened in another language version of that application, all formulas are correctly translated. Clearly, the file are stored in a language neutral fashion.

Mimicking these two behaviours is the subject of this section which is a detour than can be skipped. Actually, the accompanying source code is the actual parser used in Caleçon which can be downloaded.

While there are numerous references to Caleçon on this site, the Delphi version is no longer available. The "soon available" Free Pascal / Lazarus version has been promised for years, but has never materialized. Actually, the software is not total vapourware. It runs on my Linux desktop as evidenced by this screen shot.

There are small problems with default directories that I never seem to have time to solve. Perhaps soon?
October 21, 2021

Source code

The source code for the tokenizer, parser and translation units is available along with a simple demonstration programme and test code. It is in the archive ParsingMathExpr-4.zip.

The demonstration program compiles with Delphi version 2 and up. It should also compile with Lazarus/FreePascal with minimal changes. As before, unit tests require DUnit.pas which works with newer versions of Delphi only. Unit testing was done with Delphi 2010.

Part 5 – Constructing a Parse Tree-> <-Part 3 – Adding Constants and Functions