1 \subsection{Textual syntax} \label{Textual}
3 The syntax of grammatical productions resembles BNF and POSIX notation:
8 \TT{::=} defines a grammatical production by means of a regular expression.
10 Regular expressions are made of the following elements
11 (here \TT{...} is a placeholder):
14 % \TT{.} represents any character between U 0020 and U 007F inclusive;
17 \TT{`...`} represents any character in a character set;
20 \verb+`^ ...`+ represents any character (U+0020 to U+007E) not in a character
24 \TT{"..."} represents a string to be matched verbatim;
27 \GP{...} represents a regular expression defined by a grammatical production;
30 \TT{... ...} represents a conjunctive regular expression;
33 \TT{... | ...} represents a disjunctive regular expression;
36 \TT{[ ... ]?} represents an optional regular expression;
39 \TT{[ ... ]+} represents a regular expression to be repeated one or more times;
42 \TT{[ ... ]*} represents a regular expression to be repeated zero or more times;
45 \TT{[ ... ]} represents a grouped regular expression.
50 {\MathQL} Expressions can contain quoted constant strings with the syntax of
52 \footnote{Note that the first slash of the \GP{path} is not optional as
56 \begin{footnotesize} \begin{verbatim}
58 <num> ::= <dec> [ <dec> ]*
59 <hex> ::= <dec> | 'A - F' | 'a - f'
60 <escaped> ::= "u" <hex> <hex> <hex> <hex> | '"' | "\" | "^"
61 <string> ::= '"' [ "\" <escaped> "^" | '^ "\^' ]* '"'
62 <path> ::= "/" | [ "/" <string> ]+
63 \end{verbatim} \end{footnotesize}
65 \caption{Textual syntax of numbers, strings and paths} \label{StrTS}
69 The meaning of the escaped sequences is shown in \figref{EscTS}
70 (where $ .... $ is a 4-digit placeholder).
74 \begin{center} \begin{tabular}{|l|l|c|}
75 \hline {\bf Escape sequence} & {\bf Unicode character} & {\bf Text} \\
76 \hline \verb+\u....^+ & U+.... & \\
77 \hline \verb+\"^+ & U+0022 & \verb+"+ \\
78 \hline \verb+\\^+ & U+005C & \verb+\+ \\
79 \hline \verb+\^^+ & U+005E & \verb+^+ \\
81 \end{tabular} \end{center}
84 \caption{Textual syntax of escaped characters} \label{EscTS}
87 {\MathQL} character escaping syntax aims at complying with W3C character model
88 for the World Wide Web \cite{W3Ca} which recommends a support for standard
89 Unicode characters (U+0000 to U+FFFF) and escape sequences with
91 In particular {\MathQL} escape delimiters (backslash and caret) are chosen
92 among the {\em unwise} characters for URI references (see \cite{URI}) because
93 URI references are the natural content of constant strings and these
94 characters should not be so frequent in them.
96 Query expressions can contain variables for {\av}'s (production \GP{avar})
97 and variables for {\av} sets, {\ie} for query results (production \GP{svar})
98 according to the syntax of \figref{VarTS}.
101 \begin{footnotesize} \begin{verbatim}
102 <alpha> ::= [ 'A - Z' | 'a - z' | `_` ]+
103 <id> ::= <alpha> [ <alpha> | <dec> ]*
106 \end{verbatim}\end{footnotesize} %$
108 \caption{Textual syntax of variables} \label{VarTS}
112 The syntax of query expressions (production \GP{query}) is described in
116 \begin{footnotesize} \begin{verbatim}
117 <qualifier> ::= [ "inverse" ]? [ "sub" | "super" ]? <path>
118 <main> ::= [ "main" <path> ]?
119 <cons> ::= <path> [ "in" | "match" ] <query>
120 <istrue> ::= [ "istrue" <cons> [ "," <cons> ]* ]?
121 <isfalses> ::= [ "isfalse" <cons> [ "," <cons> ]* ]*
122 <exp> ::= <path> [ "as" <path> ]?
123 <sec> ::= [ "attr" <exp> [ "," <exp> ]* ]?
124 <opt_args> ::= <main> <istrue> <isfalses> <sec>
125 <source> ::= [ "pattern" ]? <query>
126 <paths> ::= [ <path> [ "," <path> ]* ]?
127 <query> ::= "(" <query> ")" | <string> | "[" <xavs> "]"
128 | "property" <qualifier> <opt_args> "of" <source>
129 | "let" <svar> "=" <query> "in" <query>
130 | <query> ";;" <query> | <svar> | <avar>
131 | "ex" <query> | <avar> "." <path>
132 | "add" [ "distr" ]? [ <xgroups> | <avar> ] "in" <query>
133 | "for" <avar> "in" <query> [ "sup" | "inf" ] <query>
134 | "while" <query> [ "sup" | "inf" ] <query>
135 | <path> "{" <paths> "}" "{" <queries> "}"
136 | "gen" <path> [ "{" <queries> "}" | "in" <query> ]
137 <queries> ::= [ <query> [ "," <query> ]* ]?
138 <xattr> ::= <path> "=" <query>
139 <xgroup> ::= "{" <xattr> [ ";" <xattr> ]* "}"
140 <xgroups> ::= <xgroup> [ "," <xgroup> ]*
141 <xav> ::= <string> [ "attr" <xgroups> ]?
142 <xavs> ::= [ <xav> [ ";" <xav> ]* ]?
143 \end{verbatim} \end{footnotesize}
145 \caption{Textual syntax of queries} \label{QueryTS}
149 The syntax of result expressions (production \GP{avs}) is described in
153 \begin{footnotesize} \begin{verbatim}
154 <attr> ::= <path> "=" <string> | "{" <string> [ "," <string> ]* "}"
155 <group> ::= "{" <attr> [ ";" <attr> ]* "}"
156 <av> ::= <string> [ "attr" <group> [ "," <group> ]* ]?
157 <avs> ::= [ <av> [ ";" <av> ]* ]?
158 \end{verbatim} \end{footnotesize}
160 \caption{Textual syntax of results} \label{ResultTS}
166 \begin{footnotesize} \begin{verbatim}
167 | "select" <avar> "from" <query> "where" <query>
168 \end{verbatim} \end{footnotesize}
170 \caption{Textual syntax of basic query extensions} \label{BasicTS}