On Fri, Dec 18, 2009 at 07:01:36AM -0800, Scott Stafford wrote:
> We don't have a formal spec of it or anything, but from what I can
> tell we evolved the same syntax as the internal Google effort.  No
> frills, just a sequence of N field names separated by dots (.). I'll
> try to write out the rules in English, but I might mess this up since
> I'm just doing it from memory...
> 
> The 1st through N-1th field can be:
> 
>   a required/optional Message field_name
>   a repeated Message field_name subscripted by [INDEX|
> SUBFIELD_NAME=value]
> 
> and the Nth field could be:
> 
>   a repeated field_name subscripted by [INDEX|SUBFIELD_NAME=value]
>   a required, optional, or repeated field_name
> 
> INDEX is any integer, where values >=0 indicate the sequence number of
> the element in the repeated field, or <0 in which case it counts from
> the last item, Python-style, so [-1] is the last element.
> 
> SUBFIELD_NAME can be any [required|optional] [string|int*] field in
> the field_name Message.
> 
> Does that make sense?  Sorry it's not a formal syntax, I never took
> that class. ;)  I just wrote the parser directly, using
> boost::tokenizer.
> 
> If you do write up the formal syntax, please post it!
As I understand formal syntax for Your 'xpath' in BNF like form
looks like:

query ::= query-part | query "." query-part
query-part ::= field-name | field-name "[" selector "]"
selector ::= number | attr-query
attr-query ::= field-name "=" field-value
field-value ::= number | '"' text '"'
field-name ::= text

Here is form with extended predicates that I'd like to see:

query ::= query-part | query "." query-part
query-part ::= field-name | field-name "[" selector "]"
selector ::= number | attr-query
attr-query ::= attr-match | "!" attr-query | "(" attr-query ") | \
               attr-query "or" attr-query | attr-query "and" attr-query
attr-match ::= field-name | field-name "=" field-value 
field-value ::= number | '"' text '"'
field-name ::= text

Is it acceptable? I'll try to create python implementation of last form.

                                Pavel

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.


Reply via email to