Help wanted with parsing rules of law into C

Dave Sherman dave at utcsrgv.UUCP
Sat Jul 16 07:43:53 AEST 1983


	I am trying to design a system in C which "solves"
tax problems by applying law to facts, and would like to store the
"facts" in something as close as possible to the present wording of
the Income Tax Act. I want my parser to be able to take a bunch of rules like:
-----
non-qualifying business:
		professional practice
		OR incorporated service business
		BUT NOT personal service business
-----
small business deduction:
		IF non-qualifying business THEN
		12.6667 PERCENTOF small business limit
		OTHERWISE 21 PERCENTOF small business limit
-----
and generate C code which can compute the results.
I have designed a parser which takes examples like these, makes up
a table of terms with rules for each, and will generate C code to
implement each rule at run-time. (References which remain unresolved will
be asked of the run-time user as a way of gathering facts.)
	The problem I'm having is that the various keywords operate
in different ways, and I don't have a mechanism for converting them,
especially when in combination, into C. For example,
-----
small business limit:
	LEASTOF (
	active business income PLUS active business income from partnerships ,
	taxable income MINUS ( 2.25 TIMES non-business foreign tax credit
	PLUS 2 TIMES business foreign tax credit) ,
	annual business limit ,
	total business limit MINUS cumulative deduction account )
-----
approaches the limit of what I can handle with a simple linear translation
of the rule into C.
	I really have no background in this area. Should I be using yacc
for my parser? Do I need to spend a couple of months reading up on
parsers and grammar theory? Does anyone have a package or convenient
mechanism for dealing with things like precedence, infix (PLUS) and
prefix (LEASTOF) operators, and all the other complexity of the above
example? Should my program be doing the logic itself instead of
translating into C?
	I'd appreciate any pointers people can give, including
pointers to literature if that's really what I need, or references
to any work people are presently doing in this area, particularly
on UNIX. 

TIA,
Dave Sherman
Toronto



More information about the Comp.unix.wizards mailing list