On 1/2/13, David A. Wheeler <dwhee...@dwheeler.com> wrote: > Alan Manuel Gloria: >> It should be trivial to create a Scheme interpreter in Java. >> Actually, you don't even need a scheme interpreter: you just need a >> set of classes to represent common Scheme types, and a virtual member >> function on the base class to print out an s-expression. That way we >> can use its output directly into a Scheme script that executes the >> Java code on the t-expr input, slurps its s-expr output, and compares >> it to the reference s-expr. > > I've done something like that in Java, and it's working! I've created > output/scheme/Pair.java; a Pair represents a Scheme Pair, and it has static > Scheme-like routines like cons, list, append, nullp (for "null?"), pairp, > and so on. It's not a full Scheme, but it's enough so that action rules > have a trivial mapping to Scheme (they basically use Scheme procedure names, > with Java syntax). Scheme's () is represented as Java null, Scheme atoms > are represented as Java strings, and rule results are "$RULENAME.v". Data > is represented as Java type "Object" (which is the root of the Java class > hierarchy). > > Here's an example, it looks pretty clear to me: > > body returns [Object v] : > i_expr (same body1=body {$v = cons($i_expr.v, $body1.v);} > | dedent {$v = list($i_expr.v);} ) ; > > Thoughts? > > I think this is better done in Java than in C++. For one thing, Java has > automatic garbage collection, and C++ doesn't, which makes Java a better > match to the problem.
*shrug* std::shared_ptr (or boost::shared_ptr for pre-C++11) should do fine, especially since we don't handle the circular #1= stuff in the spec anyway. Still, since there's already a Java class, that's fine too. Sincerely, AmkG ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss