[Versa] Problem with splitting the grammar
Uche Ogbuji
uche.ogbuji at fourthought.com
Tue Sep 27 15:28:49 MDT 2005
On Tue, 2005-09-27 at 15:22 -0600, Michael Olson wrote:
> On Sep 27, 2005, at 3:13 PM, Uche Ogbuji wrote:
>
> > On Tue, 2005-09-27 at 14:07 -0600, Michael Olson wrote:
> >> If we split the grammar, then the production (in bind) for a function
> >> definition must be something like
> >>
> >> @function function_name = ([^;])+ ';'
> >>
> >> Basically, the bind parser does not know the grammar of the function,
> >> so it just gives it everything.
> >>
> >> This causes a problem back in versa land for a query that looks like
> >>
> >> @prefix ft = foo
> >> @function myFunc () = ft:s - ft:p -> ft:o;
> >> @prefix ft = bar;
> >> myFunc()
> >>
> >>
> >> Because "myFunc" would not be parsed until after the complete bind
> >> expression is parsed.
> >>
> >> Is this bad?
> >>
> >> We could just disallow redefining, probably the best.
> >
> > I'm not sure I follow, but if I do, this is a semantic issue, not a
> > grammar issue. In the above specific case, line 3 would pretty much be
> > a no-op. An implementation would implement the semantics of the
> > function using the prefixes in scope at the time, which are foo. That
> > function would always have those constant URIs using the foo prefix,
> > regardless of the next line.
> >
> > I don't really see a problem.
> >
>
> The problem is with the first statement I made. By splitting the
> grammars, we have 2 parsers. One for bind and one for what every
> language bind is binding. So, from binds POV, the string "ft:s - ft:p
> -> ft:o" is opaque. So to use this new approach, we would first create
> a bind parser and parse the context query. That would result in a
> bunch of variables, functions and the end query that are just opaque
> strings. Then, a Versa parser is created to parse the variables,
> functions and finally the query. Because of the two-step, we lose
> order of the context grammar and the function "myFunc" would use the
> second, overriding, prefix definition for ft.
I don't see it this way at all. Maybe this is why I don't see Versa
Bind vs Versa as big as a split as you and Chime say. To me, it's
purely a syntactic split, not a semantic one. I don't think those can
be opaque strings. That would cause many, many problems over and above
the one you brought up. It would be more of a semantic table or tree or
in most practical cases, a data structure of parsed objects.
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://fourthought.com
http://copia.ogbuji.net http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/
More information about the Versa
mailing list