frameworker

June 23, 2009

EXPRESSIONS IN PDQFORMS

Filed under: Uncategorized — frameworker @ 4:50 am

I realize this document is pretty dry, but I needed to document this implementation to facilitate discussion with othere in the quest to improve it. Without going into why I took the approach I did, I will say that I did become very proficient in using strings with Objective C 🙂

I OVERVIEW OF EXPRESSION SYNTAX

Expressions may be FORMULAE (including BOOLEAN FORMULAE), FUNCTIONS, TABLE LOOKUPS or CONDITIONAL EXPRESSIONS.

Expressions are written in infix notation, just as you’d expect. They consist of OPERATORS, OPERANDS, SEPARATORS and FUNCTION NAMES.

A. OPERATORS include BOOLEAN OPERATORS

== <= or == or => != or && || !

and ARITHMETIC OPERATORS

+ – * % (modulus) ^ (exponentiation)

B. OPERANDS may be cell references or numbers. Numbers are evaluated as double-precision floating point.

C. SEPARATORS include ( ) , ;

The “=” character is prepended to all expressions, just like in VisiCalc.

D. All other tokens, those which are not OPERATORS, OPERANDS or SEPARATORS, are FUNCTION NAMES.

FUNCTION NAMES that end with “TABLE” are a special case. They perform Table Lookups for forms that use Tax Tables.

II FORMULAE

Operands, within formulae, may be cell references or numbers. Numbers are evaluated as double-precision floating point.

III BOOLEAN FORMULAE

Boolean Formulae, expressions that resolve to YES (1) or NO (0), are used in the scriptIf component of Conditional Expressions. They aren’t used elsewhere at this time, but they could be. Any positive number could be interpreted as YES, but we currently require “1”.

IV FUNCTIONS

Functions are snippets of code that get dispatched interpretively.

Function arguments may be formulae or can, themselves, be functions.

Quotes are used to transmit function (and table lookup) arguments as literals.

*Describe how a function gets added to PDQForms and the function dispatch mechanism.*
*Show the recursive function parsing routine.*

V TABLE LOOKUPS

Table Lookups are used to find income tax, for example, for Federal filers whose taxable income is less than $100,000.

See the blog post on TABLE LOOKUPS IN PDQFORMS for a more detailed description of how they’re implemented.

VI CONDITIONAL EXPRESSIONS

Conditional Expressions are of the form =IF(scriptIf;scriptThen;scriptElse)

(“IF” is a reserved word)

ScriptIf, a Boolean Formula, resolves to a value of zero or one. If scriptIf resolves to 0, scriptThen is executed, otherwise scriptElse is executed. ScriptThen and scriptElse can be Table Lookups, Functions or Formulae.

Conditional Expressions may not be “nested.”

VII LIMITATIONS

Expressions may not contain functions. For now, if an expression needs an embedded function, an invisible widget, that calls the function, can be referenced from the expression.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: