[Versa] EBNF round 3

Michael Olson Mike.Olson at fourthought.com
Thu Sep 15 14:39:16 MDT 2005


One thought I did have (if we want to go back to a ton of different  
type of expressions) is that I liked how XPath forced precedence into  
their grammar by having all of these different types of expressions  
(once you got your head around it at least).

Is this something we want to try and tackle in our grammar?

As an example

2 * 2 + 3

should equal 7, but our grammar would parse it as 10

and you would do it by defining a difference between an additive  
expression and multiplicative-expression and use ENBF to set  
precedence.

additive-expression = numeric-expression (+/-) numberic-expression

I can work up an example or you can look here  
http://www.w3.org/TR/xpath#section-Expressions and follow the Expr  
production...

This can also be done with precedence in the parser, but then it is not  
as defined in the spec (I feel)

Mike

On Sep 15, 2005, at 2:19 PM, Michael Olson wrote:

>
> Changes:
>   keyword arguments in versa-query function definitions
>
>
>
> [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" variable-name '=' query
>
> [5] function-declaration  ::= "@function" function-name '('  
> function-argument-definition-list ')' = query-expression
>
> [6] prefix-declaration  ::= "@prefix" prefix '=' uriref
>
> [7] context-declaration  ::= "@context" context-name '=' query
>
> [8] query ::= context-reference? query-expression
>
> [9] context-reference ::= '{' context-name '}'
>
> [10] query-expression ::= '(' query-expression ')'
>                         | query-expression slice_operator
>                         | traversal
>                         | filter
>                         | function-call
>                         | anonymous-function
>                         | variable-reference
>                         | operator-expression
>                         | pattern
>                         | DOT
>
> [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 ::= (query-expression "-" query-expression "->"  
> query-expression)
>                            | ( '[' '-' query-expression "->"  
> query-expression ']' )
>
> [15] forward-filter ::= (query-expression "|-" query-expression "->"  
> query-expression)
>                         | ( '[' "|-" query-expression "->"  
> query-expression ']' )
>
> [16] backward-traversal ::= (query-expression "<-" query-expression  
> "-" query-expression)
>                             | ( '[' query-expression "<-"  
> query-expression "-" ']' )
>
> [17] backward-filter ::= (query-expression "<-" query-expression "-|"  
> query-expression )
>                          | ( '[' query-expression "<-"  
> query-expression "-|" ']' )
>
>
> [18] function_call ::= function-name '(' argument-list ')'
>
> [19] argument-list ::= fixed-argument-list? keyword-argument-list?
>
> [20] fixed-argument-list ::= query-expression ( ',' query-expression )*
>
> [21] keyword-argument-list ::= keyword-argument ( ',' keywrod-argument  
> ) *
>
> [22] keyword-argument ::= keyword-argument-name '=' query-expression
>
> [23] keyword-argument-name :: = qname
>
> [24] operator-expression  ::= operator-expression? operator  
> query-expression
>
> [25] anonymous-function ::= '(!' function-argument-definition-list ':'  
> query-expression ')'
>
> [26] function-argument-defintion-list ::=  
> function-fixed-argument-definition-list?  
> function-keyword-argument-definition-list?
>
> [27] function-fixed-argument-definition-list ::=  
> (function-fixed-argument-definition ( ','  
> function-fixed-argument-definition ) * ) ?
>
> [28] function-fixed-argument-definition ::= qname
>
> [29] function-keyword-argument-definition-list ::=  
> (function-keyword-argument-definition ( ','  
> function-keyword-argument-definition ) * ) ?
>
> [30] function-keyword-argument-definition ::= keyword-argument-name  
> '=' query-expresion
>
> [31] pattern  ::= node-pattern | literal-pattern | wild-card
>
> [32] node-pattern ::= uri-pattern | qname-pattern
>
> [33] uri-pattern ::= uriref
>
> [34] qname-pattern ::= qname
>                        | '*:' localname
>                        | prefix ':*'
>
> [35] literal-pattern ::= string-constant
>                          | literal-constant
>                          | number-constant
>                          | boolean-constant
>                          | typed-literal-pattern
>                          | language-literal-pattern
>
> [36]  operator ::= '!'
>                    | '<'
>                    | '>'
>                    | '<='
>                    | '>='
>                    | '='
>                    | '!='
>                    | '<>'
>                    | 'and'
>                    | '&'
>                    | 'or'
>                    | '|'
>                    | 'not '
>                    | 'union'
>                    | 'intersection'
>                    | '+'
>                    | '-'
>                    | '*'
>                    | '\'
>                    | '*'
>
>
> [37] variable-reference ::= '$' variable-name
>
> [38] variable-name ::= qname
>
> [39] function-name ::= qname
>
> [40] context-name ::= qname
>
> #Strings must be escaped following section 4.6.2.1
> [41] string-constant ::= single-line-string | multiline-string
>
> [42] single-line-string ::= single-line-apos | single-line-quote
>
> [43] single-line-apos ::= '\'' [\'\n]*'\''
>
> [44] single-line-quote ::= '"' [\"\n]*'"'
>
> [45] multi-line-string ::= '""".*'"""'
>
> [46] literal-constant ::= typed-literal-constant |  
> language-literal-constant
>
> [47] typed-literal-constant ::= string '^^' uriref
>
> [48] language-literal-constant ::= string '@' language
>
> [49] number-constant ::= (signed-number ( (\.simple-number)? ) ('e'  
> signed-number)?
>
> [50] signed-number ::= [-+]?simple-number
>
> [51] simple-number ::= [-+]?[0-9]+
>
> [52] boolean-constant ::= 'true' | 'false'
>
> [53] typed-literal-pattern ::= ('!') ? string '^^' ('!') ?  
> (node_pattern | wild_card)
>                                | wild_card '^^' ('!') ? uriref
>                                | wild_card '^^' ('!') ? (node-pattern  
> | wild-card)
>
>
> [54] language-literal-pattern ::= string '@' wild-card
>                                   | wild-card '@' ('!') ? language
>
> [55] language ::= [a-z]+(-[a-z0-9]+)*
>
>
> #qName, prefix and localname as defined here:  
> http://www.w3.org/TR/2004/REC-xml-20040204
>
>
> #uri references are escaped as per section 4.5
> [56] uriref ::= '<'[\<]* '>'
>
>
>
>
> ----------------------------------------------------------------------- 
> ------------------
> 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
>
> _______________________________________________
> Versa mailing list
> Versa at lists.fourthought.com
> http://lists.fourthought.com/mailman/listinfo/versa
>
------------------------------------------------------------------------ 
-----------------
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