[Versa] EBNF (start)
Uche Ogbuji
uche.ogbuji at fourthought.com
Thu Sep 15 11:24:23 MDT 2005
On Thu, 2005-09-15 at 10:19 -0600, Michael Olson wrote:
> I haven't finished up all of the terminals yet, but do have the start
> of all of the different expressions. Thought I would get it out for
> early review.
>
> I added some "symbols" because I think it will make parsing easier, but
> let me know if you don't like something.
>
> My intent is that "pattern" is a bit different then just the constants
> that we have definied. I'd like to see some stuff in pattern like
>
> *:foo
>
> to match a foo in any namespace or
>
> "foo"@*
>
> to match a foo string in any language.
>
> And I am working on resolving those now.
Good idea. These should be very useful. I wonder whether our regex
function plus the above is enough to match the power of SPARQL's
built-in regex.
> [1] versa-query ::= declaration-list? query
>
> [2] declaration-list ::= declaration ';' declaration-list ?
>
> [3] declaration ::= variable-declaration
> | function-declaration
> | prefix-declarion
> | context-declaration
>
> [4] variable-declaration ::= "@variable" qname '=' query
>
> [5] function-declaration ::= "@function" qname '(' ( qname ( ',' qname
> ) * ) * ')' = query-expression
I think we should add defaulted (keyword) argument support here.
Perhaps
[5] function-declaration ::= "@function" qname '(' ( qname ( '='
query-expression )? ( ',' qname ( '=' query-expression )? ) * ) * ')' =
query-expression
> [6] prefix-declaration ::= "@prefix" prefix '=' uriref
>
> [7] context-declaration ::= "@context" qname '=' query
>
> [8] query ::= context-reference? query-expression
>
> [9] context-reference ::= '{' qname '}'
>
> [10] query-expression ::= '(' query-expression ')'
> | query-expression slice_operator
> | traversal
> | filter
> | function-call
>
> [11] slice-operator ::= '[' (signed-number | (signed-number ':') | (':'
> signed-number) | (signed-number ':' signed-number)
>
> [12] traversal ::= forward-traversal | backward-traversal
>
> [13] filter ::= forward-filter | backward-filter
>
> [14] forward-traversal ::= (pattern-expression "-" pattern-expression
> "->" filter-expression)
> | ( '[' '-' pattern-expression "->"
> filter-expression ']' )
>
> [15] forward-filter ::= (pattern-expression "|-" pattern-expression
> "->" filter-expression)
> | ( '[' "|-" pattern-expression "->"
> filter-expression ']' )
>
> [16] backward-traversal ::= (filter-expression "<-" pattern-expression
> "-" pattern-expression)
> | ( '[' filter-expression "<-"
> pattern-expression "-" ']' )
>
> [17] backward-filter ::= (filter-expression "<-" pattern-expression
> "-|" pattern-expression )
> | ( '[' filter-expression "<-"
> pattern-expression "-|" ']' )
>
> [18] pattern-expression ::= pattern-expression slice-operator
> | '(' pattern-expression ')'
> | pattern
> | variable-reference
> | '{' query '}'
>
>
> [20] filter-expression ::= '(' filter-expression ')'
> | filter-expression slice-operator
> | function-call
Do we need to add function (i.e. function name)?
> | anonymous-function-call
Isn't this just the same '{' query '}' as above? i.e. anonymous
equivalent to the named function I mention above?
> | pattern
> | operator-expression
> | variable-reference
I think some of the above confusion could be minimized by adding an expr
production, such as:
[X] expr ::= '(' expr ')'
| function-call
| pattern
| operator-expression
| variable-reference
| '.'
I may be missing some here, but then
[20] filter-expression ::= '(' filter-expression ')'
| expr
| pattern
?
Or perhaps I'm misunderstanding your grammar. In the above I'm trying
to separate lists/patterns (which include function calls such as
'all()') from predicates (which include function names such as
'isresource').
> [21] function_call ::= qname '(' ( argument-expression ( ','
> argument-expression ) * ) ? ')'
ditto passing kwargs here
> [23] argument-expression ::= argument-expression slice-operator
> | '(' argument-expression ')'
> | filter
> | traverse
> | pattern
> | function-call
> | anonymous-function-call
again this should be function name and anonymous function defn.
> | variable-reference
>
> [24] operator-expression ::= operator-expression? operator
> filter-expression
>
> [25] pattern ::= node-pattern | literal-pattern | particle
I think we can now separate the particles, and have '*' sit by itself
here, and have '.' in under expr?
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://fourthought.com
http://copia.ogbuji.net http://4Suite.org
Use CSS to display XML, part 2 - http://www-128.ibm.com/developerworks/edu/x-dw-x-xmlcss2-i.html
XML Output with 4Suite & Amara - http://www.xml.com/pub/a/2005/04/20/py-xml.html
Use XSLT to prepare XML for import into OpenOffice Calc - http://www.ibm.com/developerworks/xml/library/x-oocalc/
Schema standardization for top-down semantic transparency - http://www-128.ibm.com/developerworks/xml/library/x-think31.html
More information about the Versa
mailing list