Hi Carl,

In the BaseX query parser, tokenization and parsing is a joint
operation. in the past, we thought about splitting these steps, as the
tokens could also be used in the GUI to provide better highlighting.
However, we'd probably need some more coders interested in making that
happen..

However, thanks for the suggestion,
Christian


On Thu, Nov 6, 2014 at 3:12 PM, Carl Leitner <litlf...@gmail.com> wrote:
> On a somewhat related note, I assume that when compiling xquery you are
> creating some kind of token stream.  Would it be possible to add a function
> like
>  xquery:tokenize ($query as xs:string) as item()*
> which takes as input an xquery string and output the token string.
>
> Presumably this could be another route used to meet the use case discussed
> below to select functions from a toolbox module.
>
> Here is an example of similar functionality in PHP:
> http://php.net/manual/en/function.token-get-all.php
>
> Cheers,
> -carl
>
>
> On Nov 6, 2014, at 8:26 AM, Christian Grün <christian.gr...@gmail.com>
> wrote:
>
> Hi Marco,
>
> You may be surprised (or not) that I thought about a similar
> functionality. Indeed I wondered if we could allow function items as
> input for client:query and xquery:evaluate.
>
> I like your idea of providing an explicit serialization function. For
> several reasons, we cannot guarantee that the serialized
> representation of an XQuery expression will always be executable. In
> some case, it's even not possible because the optimizer creates new
> expressions that have no counterpart in the original XQuery language.
> If we provide an explicit function for serializing function code,
> however, we'd be able to point this out.
>
> I have added a new GitHub issue [1].
>
> Christian
>
> [1] https://github.com/BaseXdb/basex/issues/1021
>
>
> On Wed, Nov 5, 2014 at 3:23 PM, Marco Lettere <marco.lett...@dedalus.eu>
> wrote:
>
> Hello all,
> just out of curiosity, would it be too hard to have a serialization tool for
> functions that does more or less the inverse of inspect:functions i. e.
> given a function item returns the full function code?
> The use case is that I want to send out a client:execute request that is a
> XQuery script where functions can be attached at runtime selecting them out
> of a "toolbox" xqm module. And of course I don't want to manually parse the
> xqm to cut out the required function which could be done but is not very
> elegant.
>
> Example:
>
> declare function local:f($i as xs:integer) as xs:integer{ $i + 1 };
>
> inspect:serialize(local:f#1)
>
> would yield the string "declare function local:f($i as xs:integer) as
> xs:integer{ $i + 1 };"
>
> I've seen that even if it is not possible to serialize or cast to string a
> function item, if the function is assigned to a map, calling map:serialize
> yields something similar to the full function code. So I thought maybe the
> serialization mechanism is already in place and would just need a bit of
> generalization.
> Regards,
> Marco.
>
>

Reply via email to