This site's content was compiled from 1993 to 2006. Beyond that, Google is your friend.

Formula Parsing Cluster

Maintainer

Javier Alonso

Description

This small cluster was born from the need to resolve small formulae in the style of

X + ( STEP * 2 ) / KERF

that are defined in a parametric CAD/CAM system under development.

Use of more complex libraries like EiffelLex or EiffelParse (let alone YOOC...) seemed like overkill for such a small task, so this (micro)cluster was developed on the fly to solve positional references related to a working area or slab of material, in a new approach to parametric design. Instead of giving precise numerical positions, these are entered as formulae which use named variables such as thickness, width and length. In this way, if a part to be machined has, say, six holes in it proportionally spaced, the proportion is kept constant if overall dimensions are changed. In actual parametric systems a new part program is generated for any dimensional change, but you need to define a 'pattern program' telling which items are fixed or variable.

Categories

Versions

Links

Features

The cluster contains the following classes:

The parser allows the definition of named variables only limited by system resources, and works as follows:

Once an instance of the parser is created, new variables can be defined by means of

set_var ( name : STRING; value : DOUBLE )

also, the value of an existing variable can be obtained by

get_var ( name : STRING ) : DOUBLE

Setting the value of an existing variable implies the re-evaluation of the actual expression. Recalculation is also forced by the command

set_expression ( ns : STRING )

The usual way to employ the formula parser is

evaluate_string ( ns : STRING ) : DOUBLE

which set ns as the actual expression, evaluates it, and returns the result.

The parsing process goes this way:

Any character not matching any of these groups is rejected and the process stopped with the corresponding error flag and message.

As can be seen from the source code, this generation process is conceptually similar to the workings of a finite state machine (as the vast majority is, by the way).

Finally, just one final lexem of type solved literal remains in the list, containing the result of the whole evaluation process.

Supported compilers

Platforms

Licensing

Google
 
Web eiffelzone.com