On Wed, Jan 23, 2013 at 7:56 PM, David A. Wheeler <dwhee...@dwheeler.com> wrote: > Alan Manuel Gloria <almkg...@gmail.com> >> Hmm. Okay, I propose this: >> >> 1. We give a set amount of time to play around with sweet.g, kick its >> tires, drive it around, try smashing some brick houses with it. > > +1. > >> 2. Convert sweet.g's actions from Java to Scheme (or better, provide >> some sort of automated conversion from sweet.g's actions to Scheme, we >> don't need a complete conversion, I assume your list() etc. functions >> just need to be converted to s-exprs. You could probably use (set! v >> (cons restart-tail rr)). Or just drop "v" completely.). Mostly >> because we'll be targeting SRFI, and I am more confident of acceptance >> if the SRFI's spec at least has some Scheme code. > > I think the work to auto-convert would be *much* larger than just > hand-converting it to Scheme. Hand-converting this stuff is easy.
I mean auto-converting just the actions, like so: restart_tail returns [datum] : it_expr more=restart_tail { (cons $it_expr $more) } | comment_eol retry1=restart_tail {$retry1} | (FF | VT)+ EOL retry2=restart_tail {$retry2} | restart_end {'()} ; I suspect it'll be easier for people interested primarily in Scheme rather than Java to process. >> 3. Plan out the pre-conditions and post-conditions of the different >> productions (as we would implement in the actual Scheme code). Also >> plan out the exact calling convention of productions-cum-procedures. > > I intend for there to be a 1-to-1 mapping from the key BNF productions to > Scheme procedures, and for each procedure to return a list with 2 values: > "why stopped" and "result". The "why stopped" for it_expr would be the > indent it read that caused it to return; the "why stopped for head, rest, and > several others would be symbol like 'eol, 'sublist, 'group_splice, or > ''restart_end. Calling convention also needs the inputs to the procedures (indent level for head, rest, etc.), and the why-stopped needs to be specified precisely too. Also: signalling success and failure to parse? > >> 4. Mark the places where the pre-conditions and post-conditions of >> the productions would be violated by the ANTLR code, but which are >> somehow "magically" fixed by putting "error". > > Pre/post sure; not sure what you mean by magic. > >> Also: maybe we should initiate SRFI process "soon". > > Well, we need to redo this part of the Scheme implementation. I expect that > to be really easy. Once we do that, then yes, we need to start the SRFI > process. > >> That way, when someone on the SRFI list raises fuss about the >> sweet-expressions grammar, we haven't sunk time into figuring out how >> to translate the ANTLR Scheme by hand into actual Scheme code. We can >> then back-propagate any changes into ANTLR Java sweet.g, check things >> out, then re-convert back to ANTLR Scheme. >> >> Or something. > > I don't think the SRFI process will go far until we have a "working" Scheme > implementation. SRFI allows: "5. An outline of how it might be implemented. This should be considered a last resort, and in this case the rationale for the feature must be stronger. " sweet.g is already an outline of how it might be implemented; we just need a stronger rationale (^^). I suspect it can be argued that we're using reasonably well-studied parsing tech here, and that the translation from a parser spec to working Scheme code can be done mechanically (except the productions will probably get shifted all over the place if done mechanically), so that "the spec is the implementation", and that after the spec itself is reasonably stable we can start writing a sample implementation that can work. > >> Ara ara, so I guess that means we might need to change t-expr calling >> convention in order to properly receive a current indent, and just >> wrap it with a default current indent of "". > > Why? The only time t-expr is called is when the current indent is "". Hmm. Okay, now I'm really confused. There's a "comment_eol restart=t_expr" bit here: > | (GROUP_SPLICE | scomment) hspace* /* Initial; Interpet as group */ > (group_i=it_expr {$v = $group_i.v;} /* Ignore initial GROUP/scomment */ > | comment_eol > (indent g_body=body {$v = $g_body.v;} /* Normal GROUP use */ > | same ( g_i=it_expr {$v = $g_i.v;} /* Plausible separator */ > /* Handle #!sweet EOL EOL t_expr */ > | comment_eol restart=t_expr {$v = $restart.v;} ) > | dedent error )) So, this pattern should trigger it: foo ! \\ ; comment_eol ! ; comment_eol bar But I don't understand what exactly gets returned here. Why does it recurse to t_expr at this point? Or am I completely misunderstanding it_expr?? > >> Hmm. >> >> Looks like a complete rewrite of the code (^.^)v > > That's good. Have you SEEN that code? :-) :-) :-). I deny ever seeing it! (~.~);;;;;; > > In all seriousness, it's actually a rewrite of just a few procedures, and we > can reuse lots of pieces (I used the original Scheme code to help develop the > BNF). The result will be MUCH cleaner; the current code hacks around several > situations that the new code handles cleanly. No more "readblock-clean" and > "readblock-clean-rotated", whose purpose was NEVER obvious from the BNF. > It'll just be a relatively short list of procedures whose names and functions > obviously map to the BNF. Agreed. Sincerely, AmkG ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d _______________________________________________ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss