[Staff] Expression Parser

Here you can find side projects of the staff and great projects which we think should get extra support. (Note that featured projects are not projects by staff members of MaxCoderz)

Moderator: MaxCoderz Staff

Post Reply
User avatar
Maxcoderz Staff
Posts: 3085
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England

[Staff] Expression Parser

Post by benryves »

I've been working on a little expression parser over the weekend. Given an input string in the format

Code: Select all

.db "(-8>>2)+ceil(pi())+2**sqrt(abs((~0>>>(30|1))-(10>?1)))",0
it will produce a floating-point value (10 in this case). The internal number cruncher is BBC BASIC's FPP (so you would need BBC BASIC installed) and so all the features of BBC BASIC's FPP are provided either in the form of a function or an operator. The syntax is vaguely C-like with a few functions (min, max, pow) turned into operators (<?, >?, **) and a few additional operators (\ for integer division, >>> for an unsigned right shift).

I suspect the technique is more useful than the implementation (especially given the dependency on BBC BASIC), so would anyone find it useful if I wrote this up?

Edit: Apparently not. Here's an archive of the source with some documentation.
Regular Member
Posts: 88
Joined: Sun 14 Sep, 2008 10:00 am

Re: [Staff] Expression Parser

Post by Galandros »

I was dreaming on making something like that. :p

I will see the code to see how is that made.
Post Reply