RE: Please make sure the grammar is directly machine consumable.

-------- Original Message --------
> From: Yosi Scharf <mailto:syosi@MIT.EDU>
> Date: 22 August 2005 16:28
> 
> Seaborne, Andy wrote:
> 
> > Yosi,
> > 
> > Could you let me know what the "small hand tweak" is to the grammar?
> > Was it to the SPARQL grammar or the output of the conversion?
> > 
> > Was it one of the diffs you sent in July (I never found out what the
> > diffs were diff'ed against - some of them are already in the LC
> > grammar but I didn't get the diffs until after the text was frozen
> > for LC). 
> > 
> >     Andy
> > 
> > Tim Berners-Lee wrote:
> > 
> > > 
> > > Richard,
> > > 
> > > I didn't realize the grammar in the spec is machine-generated.
> > > Maybe it should be hand-edited and everything else generated from
> > > it. 
> > > 
> > > Yosi (on vacation right now) has generated (with a small hand
tweak)
> > > the CFG grammar in RDF from the spec.   (See sparql* in
> > > http://www.w3.org/2000/10/swap/grammar/
> > > )  This is in plain BNF (  cfg:mustBeOneSequence properties with
> > > nested RDF collections ) 
> > > 
> > > See the bnf.n3 ontology in that directory as well as the
> > > bnf-rules.n3 which go from some forms of ebnf to bnf, also in that
> > > directory. 
> > > 
> > > Tim
> > > 
> > > On Aug 18, 2005, at 16:26, Richard Newman wrote:
> > > 
> > > > As I recall from discussions with Andy Seaborne while I was
> > > > implementing twinql[1], the grammar in the SPARQL docs are
> > > > directly generated from a JavaCC grammar file. The source,
> > > > therefore, is machine-consumable -- at least, if you're using
> > > > JavaCC! 
> > > > 
> > > > However, the output is not a particular friendly grammar to work
> > > > with -- optional dots after productions, for example, tripped up
> > > > my tool (so twinql makes them compulsory), and it took a bit of
> > > > work to get it into a usable state (as I detailed in a previous
> > > > email[2]). 
> > > > 
> > > > -R
> > > > 
> > > > [1] <http://www.holygoat.co.uk/projects/twinql/>
> > > > [2]
> > > > <http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/
> > > > 2005Aug/0055.html> On 18 Aug 2005, at 11:28, Tim Berners-Lee
> > > > wrote:  
> > > > 
> > > > 
> > > > > 
> > > > > This is a followup from a discussion between Yosi Scharf,
> > > > > implementer of SPARQL in cwm, currently on vacation,  and Eric
> > > > > P'dH, co-editor of the spec, several weeks ago.
> > > > > 
> > > > > Yosi has built his implementation of SPARQL from a file which
is
> > > > > almost the one generated from the TR, but with a slight tweak
to
> > > > > make the file grammar able to be parsed by a predictive parser
> > > > > [1] a simple form of LL(1) recursive descent parser.  I
> > > > > understood that the tweak was editorial in that the it didn't
> > > > > change the language, just the way it was expressed as a
> > > > > context-free grammar. 
> > > > > 
> > > > > A situation in which code can be generated directly from the
> > > > > spec is a very strong position to be in.  I am not aware of
any
> > > > > time this has previously happened for a W3C language, but I
may
> > > > > be wrong.  As it is demonstrably simple to make the step here
I
> > > > > would request it be done at last call stage before the call
for
> > > > > implementation at CR. 
> > > > > 
> > > > > [1] http://www.inf.ed.ac.uk/teaching/courses/cs2/LectureNotes/
> > > > > CS2Ah/LangProc/lp10.pdf 
> > > > > 
> > > > > Tim Berners-Lee
> > > > > MIT/CSAIL/DIG
> > > > > 
> > > > > 
> > > > > 
> > > > 
> > > 
> > > 
> The diff I sent you (attached) was completely hand written. I was
> describing how I went from 
> http://www.w3.org/2005/01/yacker/uploads/s20050622 , as it was at the
> time, to http://www.w3.org/2005/01/yacker/uploads/yosiJune28a . I
> believe I tried making it in terms of the grammar that was then
current
> in rq23. I don't know how well I succeeded. The content of the changes
> I did, and the reasoning behind them, remains. The first change makes
> things recursive enough to avoid the optional dot problem in all
cases.
> The other changes are needed to make the grammar LL(1).  I then take
> the grammar in http://www.w3.org/2005/01/yacker/uploads/yosiJune28a
and
> run it through yacker to get something which is has been slightly hand
> edited into http://www.w3.org/2000/10/swap/grammar/sparql.n3 . The
hand
> edits have been things I could have changed yacker to do for me, if I
> knew perl and yacker.          
> 
> The first change (the rest are readability nightmares, and I can
easily
>  understand your not wanting those in the grammar), makes the grammar
> LALR(1), and I don't think it is so bad. I change a GraphPatternList
> into
>
http://www.w3.org/2005/01/yacker/uploads/yosiJune28a?lang=perl&markup=ht
ml#prod-yosiJune28a-GraphPatternList
> , a set of things that may or may not be triples. A triple is followed
> by a dot and a GraphPatternList, or directly by something that is not
a
> triple. Therefore, we have a direct statement of how dots work, and no
> optDot problem.       
> 
> Yosi

Yosi - Thanks

Not sure what s20050622 is (something you and Eric worked on?) but I can
work from the two listings you point to.  I have a first pass at an
LL(1) grammar which passes all the WG tests; can't enter it into yacker
though - I need Eric's help for that.  I'll work though your version and
maximize readability.

I'll announce something for interested parties after some testing and
general cleanup.

	Andy

Received on Monday, 22 August 2005 17:24:03 UTC