[Versa] EBNF (start) (functions)
Michael Olson
Mike.Olson at fourthought.com
Thu Sep 15 12:02:54 MDT 2005
Note, I have broken this into a couple of threads to help keep things
straight.
>
>> [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
I'm not sure I agree that these need support for that. These function
definitions are very closely bound to the query. They have no life
outside of this query and are most likely written to clean up the
actual query.
Granted, you can do a few new things with a function now that were
probably not (easily) possible in versa-1 (recursion in versa???) even
so, I think that having them so bound to the local context means there
is not a lot of need for defaulted or key word arguments.
>>
>>
>> [20] filter-expression ::= '(' filter-expression ')'
>> | filter-expression slice-operator
>> | function-call
>
> Do we need to add function (i.e. function name)?
>
What is a function name and how does it differ from a function call?
>> | anonymous-function-call
>
> Isn't this just the same '{' query '}' as above? i.e. anonymous
> equivalent to the named function I mention above?
No, I'm gong with your syntax of (!x : $x) for now.
The '{' query '}' above is a way to nest traversals with out the parser
getting confused. This is the main reason for may initial statement of
"I added symbols..."
>
>> | pattern
>> | operator-expression
>> | variable-reference
>
>> [21] function_call ::= qname '(' ( argument-expression ( ','
>> argument-expression ) * ) ? ')'
>
> ditto passing kwargs here
>
This one I agree with because these functions could be defined
externally and used across queries.
>> [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.
>
I agree that changing "anonymous-function-call" to just
"anonymous-function" may clean up some confusion. So in the grammar
where I said "anonymous-function-call" I meant (!x :$x)
Mike
------------------------------------------------------------------------
-----------------
Mike Olson Principal
Consultant
mike.olson at fourthought.com +1 720 253 4662
Fourthought, Inc.
http://Fourthought.com
PO Box 270590, http://4Suite.org
Louisville, CO 80027-5009, USA
XML strategy, XML tools, knowledge management
More information about the Versa
mailing list