DiceTool expressions (current and future)

Thoughts, Help, Feature Requests

Moderators: dorpond, Azhrei, giliath

Post Reply
User avatar
giliath
RPTools Founder
Posts: 275
Joined: Tue Jan 31, 2006 11:10 am
Location: Austin, TX

DiceTool expressions (current and future)

Post by giliath »

I have been working (for entirely too long) on a replacement for the expression engine component of DiceTool. Currently we use JEP, but the license is GPL and I don't like the virul nature of it. (Also JEP is overkill for this app.)

I have re-engineered the expression engine using Antlr and ended up with a decently powerful expression parser and easy integration of custom functions.

In both JEP and the new parser I decided to go with a preprocessor for the dice rolling XdY instead of build it into the expression language. I use a pair of regular expressions like so:

Code: Select all

s/[dD](\d+)/roll(1, $1)/g
s/(\d+)[dD](\d+)/roll($1, $2)/g
Basically this means substitute XdY with roll(X, Y), using the function format built into the parser. These preprocessors will be customizable from the interface so that users can customize it for other games.

Also, I plan on putting an editor for the JavaScript into DiceTool and putting all of the customizations, preprocessor, javascript and tabs into the save file so that they are easily portable.
~Giliath

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Post by Azhrei »

Assuming that you're using a PCRE, you could use:

Code: Select all

s/(\d*)d(\d+)/roll($1 ? $1 : 1, $2)/ig
<grin>
I'm sure that such a change would tremendously speed up the program!
</grin>

User avatar
giliath
RPTools Founder
Posts: 275
Joined: Tue Jan 31, 2006 11:10 am
Location: Austin, TX

Post by giliath »

Thx for the input. I am actually using Java's built in regular expressions which are pseudo perl-compatible, so I kinda doubt they support variant.

PS. I was starting to wonder if anyone read my post.

:D
~Giliath

User avatar
Steel Rat
Great Wyrm
Posts: 1765
Joined: Tue Jun 13, 2006 5:55 pm
Location: Oak Harbor, WA
Contact:

Post by Steel Rat »

Reading it an understanding it are two different things :P

I do some PHP programming, and Visual Basic, but RegEx always confuses the hell out of me.
Steel Rat
-----------
RPGMapShare.com - RPG Maps and Mapping objects.
Discord Server

Emryys
Dragon
Posts: 780
Joined: Tue Jan 31, 2006 9:01 pm
Location: Beneath the Aurora Borealis
Contact:

Post by Emryys »

Steel Rat wrote:Reading it an understanding it are two different things :P
...the hair on the top of Emryys' head rustles with the wind... ;)
Game On!
Image

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Post by Azhrei »

giliath wrote:Thx for the input. I am actually using Java's built in regular expressions which are pseudo perl-compatible, so I kinda doubt they support variant.
Yeah, I wouldn't know. I've never used REs in Java...

The cool thing about them is that they're encapsulated inside a class and the strings used can be supplied externally! Meaning that users could do their own updates or make their own changes, if they want. Even going so far as to override your class (the one with the roll() method) and defining their own. Of course, that kind of support requires some work from the developer to do the whole Class.forName() thing. :(
PS. I was starting to wonder if anyone read my post.

:D
I only visit these boards once or twice a week. I have about a dozen boards I frequent, so I try to do a couple a day. Or thereabouts. :)

Post Reply

Return to “DiceTool”