As usual sourceforge Mailman/svn is being silly, seems to be dropping commits and all mail entirely now ;( Here is the current parser status.
At this point, it is possible to run a self-contained Scheme program which generates a statement, using a hack like: ////////////////////////////////// proc f() { println "Hello"; } _scheme """ (begin (define f '(AST_name f ())) `(AST_call ,f () ) ) """; ///////////////////////////////////// This program prints "Hello" as expected. There are some issues, the worst one of which is that Scheme is case insensitive. So in the above '(AST_name F ()) would also work .. and you'd have to use '(AST_name "F" ()) to call F. Ouch. I have yet to figure out how to pass arguments from Ocaml level, but this should be easy. Now the problem is how to fix the parser. Unfortunately, I cannot see any way to do this 'incrementally'. When a grammar production is processed, if the non-terminals return Scheme values and the action is written in Scheme to return a Scheme value, all is fine. Also, it is possible to convert Scheme values to Felix AST terms (and, most of the algebraic combinations of them used in the AST system). however it is not possible for a Scheme user action to accept Felix terms from non-terminals: there's no flx->ocs converter, only an ocs->sex->flx converter. Ocs scheme does provide a 'wrapped value' term, but I have no idea how to use it: the wrapped value is a function unit->unit, so it would have to store the wrapped value in a known variable to be useful. Sooo .. at present the only solution is to *completely* rewrite the grammar to use scheme actions. This is probably fairly easy for simple terms, but some terms do pattern matching and other conditionals to decide on the final term to be returned. Duplicating that in Scheme is probably possible but not trivial (scheme doesn't have any pattern matching facility). Although difficult .. the result of this effort would roughly leave the initial (hard coded) grammar as: compilation_unit: statements ENDMARKER { $1 } statements: statement statements { $1 :: $2 } | {[]} statement: dypgen-extension coding here ... svalue svalue: {} /* yep, empty, ready for extension */ literals: put all the literals here And that's it. The whole grammar would basically be deleted OTHER than literals and the stuff needed to add extensions: the grammar would now go into the library. Literals are needed to map literal tokens to terms by extraction of the token attributes. The 'extension' adding stuff would need to be rewritten to use Scheme values, and extra stuff for handling new nonterminals probably added, including management of priorities. A consequence of all this is that 'anything goes' during parsing. Type checking done now by the user actions and structure of the parser would be delayed until svalue -> flx term conversion, that is, after parsing is done. One final thing: I have ignored source reference processing, so errors will probably be very badly reported. This needs to be fixed later. Bottom line: I have no idea what to do to avoid breaking Felix for some time. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language