Thanks for that, as you say not quite, but certainly interesting to look through. I like the idea of supporting more than one type of formula file type. Somethign that ChaosPro seems to have taken to extremes. It certainly stretches my meagre knowledge of python (which is not a bad thing). The code seems to parse and check the tokens (something I already have working). Though it does build them into a tree, which is presumably an execution tree. I wanted to avoid lex and yacc as I want to run this as an applet, so it has to be small javaCC alone is 370k - more than 3 times as large as my applet.. I think I just have to bite the bullet and start into it. Too late tonight though. I have a dusty old copy of the dragon book, which hasn't been opened in 15 years. regards David Edwin wrote:
On Tue, 2004-02-10 at 17:04, David Burnett wrote:
Hi All,
I am trying to implement a parser for my FractaCanvas project to read fractint formulae. I have got as far as extracting tokens and checking for placement. Does anyone have any design doc that describes how parser.c works (you do use design doc don't you).
OK, this is not really all that similar to what you asked for, but...
I've written a parser + compiler for Fractint .frm files in Python, using the PLY parser-generator. While this may not be directly usable for you, it is at least a concise description of what I think the Fractint parser understands. It actually parses a superset of the syntax accepted by Fractint and understands a bunch of UltraFractal constructs - that may or may not be a problem for you.
The lexer + parser are relatively self-contained and output an AST. You can find them at
http://cvs.sourceforge.net/viewcvs.py/gnofract4d/gnofract4d/libfract4d/compi...
You'll need fractlexer.py, fractparser.py, absyn.py, lex.py and yacc.py.
You could also try looking at the user documentation that comes with UltraFractal - it has a good, albeit informal, description of the syntax and standard library that I found that very useful.
Regards, -- Edwin