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 start/end
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}.%
99 \footnote{This syntax resembles the one of programming languages identifiers.}
102 \begin{footnotesize} \begin{verbatim}
103 <alpha> ::= [ 'A - Z' | 'a - z' | `_` ]+
104 <id> ::= <alpha> [ <alpha> | <dec> ]*
107 \end{verbatim}\end{footnotesize} %$
109 \caption{Textual syntax of variables} \label{VarTS}
113 The syntax of query expressions (production \GP{query}) is described in
117 \begin{footnotesize} \begin{verbatim}
118 <qualifier> ::= [ "inverse" ]? [ "sub" | "super" ]? <path>
119 <main> ::= [ "main" <path> ]?
120 <cons> ::= <path> [ "in" | "match" ] <query>
121 <istrue> ::= [ "istrue" <cons> [ "," <cons> ]* ]?
122 <isfalses> ::= [ "isfalse" <cons> [ "," <cons> ]* ]*
123 <exp> ::= <path> [ "as" <path> ]?
124 <sec> ::= [ "attr" <exp> [ "," <exp> ]* ]?
125 <opt_args> ::= <main> <istrue> <isfalses> <sec>
126 <source> ::= [ "pattern" ]? <query>
127 <paths> ::= [ <path> [ "," <path> ]* ]?
128 <query> ::= "(" <query> ")" | <string> | "[" <xavs> "]"
129 | "property" <qualifier> <opt_args> "of" <source>
130 | "let" <svar> "=" <query> "in" <query>
131 | <query> ";;" <query> | <svar> | <avar>
132 | "ex" <query> | <avar> "." <path>
133 | "add" [ "distr" ]? [ <xgroups> | <avar> ] "in" <query>
134 | "for" <avar> "in" <query> [ "sup" | "inf" ] <query>
135 | "while" <query> [ "sup" | "inf" ] <query>
136 | <path> "{" <paths> "}" "{" <queries> "}"
137 | "gen" <path> [ "{" <queries> "}" | "in" <query> ]
138 <queries> ::= [ <query> [ "," <query> ]* ]?
139 <xattr> ::= <path> "=" <query>
140 <xgroup> ::= "{" <xattr> [ ";" <xattr> ]* "}"
141 <xgroups> ::= <xgroup> [ "," <xgroup> ]*
142 <xav> ::= <string> [ "attr" <xgroups> ]?
143 <xavs> ::= [ <xav> [ ";" <xav> ]* ]?
144 \end{verbatim} \end{footnotesize}
146 \caption{Textual syntax of queries} \label{QueryTS}
150 The syntax of result expressions (production \GP{avs}) is described in
154 \begin{footnotesize} \begin{verbatim}
155 <attr> ::= <path> "=" <string> | "{" <string> [ "," <string> ]* "}"
156 <group> ::= "{" <attr> [ ";" <attr> ]* "}"
157 <av> ::= <string> [ "attr" <group> [ "," <group> ]* ]?
158 <avs> ::= [ <av> [ ";" <av> ]* ]?
159 \end{verbatim} \end{footnotesize}
161 \caption{Textual syntax of results} \label{ResultTS}
164 The textual syntax of the language extension provided by the basic library
165 is in \figref{BasicTS}.
168 \begin{footnotesize} \begin{verbatim}
169 <query> ::= "empty" | "false" | "true"
171 | <query> [ "and" | "or" | "xor"| "sub" | "meet" | "eq" | "le"| "lt" ] <query>
172 | <query> [ "union" | "intersect" ] <query> | { <queries> }
173 | "if" <query> "then" <query> "else" <query>
174 | "select" <avar> "from" <query> "where" <query>
175 \end{verbatim} \end{footnotesize}
177 \caption{Textual syntax of basic extension} \label{BasicTS}