This is mostly just curiosity, but is it possible to hook into
Factor's parser/lexer to define new forms of literal? I know it's
possible to write parsing words like V{ but I'm more interested in
"standalone" forms like rationals 2/3. From what I can tell, rational
syntax is hard-wired into Factor's parser as part of string>number. I
don't see an easy way to extend it.The background is that I'm playing with ideas around game simulation programs, where die rolls are a common need. I can obviously write a word dieroll ( n m -- roll ) to roll n m-sided dice and produce a result - but where n and m are literals (as they often are) the usual syntax is nDm (for example, 3D6) and it'd be nice to be able to express that directly in Factor. Is that possible? From what I recall of old-style forths, it wasn't - they hard coded the word splitter and numeric parsing code. What I've been able to dig into with Factor indicates that the parser's structure is similar, but I could easily have missed something. As I say, it's not a big deal (it may never even make it into real code, it's just ideas) but if anyone can point me at an example, or tell me it's not possible, that's be nice. Paul. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
