RE: simplify math expression

new topic     » goto parent     » topic index » view thread      » older message » newer message

> -----Original Message-----
> From: a.tammer at hetnet.nl [mailto:a.tammer at hetnet.nl]

> maybe we could cooperate on nimplementing your libs and my ICD.lib
> could turn into quite a powerful tool I guess

It's pretty easy to add new stuff to the lib with an include file.  In fact,
booleval.e is an add on I wrote.  You don't have to have booleval.e to run
matheval.  

If you want to add a new type of matheval sequence, you have to create the
funtion that handles it, a parse routine, a pretty print routine, and you
also need to initialize it.  In order to parse it, you might have to fool
the parser using some notation like (otherwise, it would try to make 1e1000
into a constant, i.e., atom--KABOOM):

MAKEBIG("1e1000")

Then, for the parsing routine for MAKEBIG (really a function), you would
have to know to convert the token to your right (should be {DATA,"1e1000"} )
into a BIGNUM.  My notation for the parsing routines is to prefix the
routine with a 'C', for Collapse, because that's actually what it does.  The
parser scans the input and tokenizes everything, and then, based on
precedence rules (specified in the initialization), the 'Collapse' routine
sucks up the tokens around it (based on whether it's binary or left/right
unary).

  You would also have to use add_to_func().  This would allow the builtin
operators to use your new stuff.  For instance, ADD doesn't know how to add
BIGNUM's.  So you would write a routine that handles all the cases of adding
BIGNUM's (BIGNUM+BIGNUM,BIGNUM+CONSTANT, etc).

I don't think you'd be able to have constant operations automatically
promote to BIGNUM's, but then you probably shouldn't be using constants if
you think you might create a BIGNUM.  You could always use MAKEBIG to
promote manually like if you had a variable or some other result that you
knew was a constant (since it would be faster to calculate as a constant).

If you're interested, I could help you with any questions.  I'd definitely
recommend reading the docs before you start.  They give you an idea of how
some of the guts of the lib work.

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu