이 섹션에는 전체 Q 언어 문법이 나열되어 있습니다. 토큰 구조는
렉시칼 요소를 참조하십시오.
다음 테이블에
문법의 프리젠테이션에 사용되는 인쇄 규정에 대한 요약이 표시되어 있습니다.
- 스타일
- 의미
- [
]
- 선택적 요소
- ( )+
- 하나 이상의 발생
- ( )*
- 0개 이상의 발생
- ID,
STRING_LITERAL
- 토큰
- let, for_all, =>, ~<>
- 예약어 또는 구두점
expr
: expr′
| expr′ |= expr′
expr′
: implies-expr
| let-expr
| if-expr
| universal-expr
| existential-expr
let-expr
: let ID = expr in expr′
if-expr
: if expr then expr else expr′
universal-expr
: for_all ID in expr = expr′
existential-expr
: there_exists ID in expr = expr′
implies-expr
: or-expr
| or-expr implies implies-expr
or-expr
: and-expr
| or-expr or and-expr
and-expr
: relational-expr
| and-expr and relational-expr
relational-expr
: additive-expr
| additive-expr = additive-expr
| additive-expr <> additive-expr
| additive-expr ~= additive-expr
| additive-expr ~<> additive-expr
| additive-expr < additive-expr
| additive-expr <= additive-expr
| additive-expr > additive-expr
| additive-expr = additive-expr
additive-expr
: multiplicative-expr
| additive-expr + multiplicative-expr
| additive-expr - multiplicative-expr
multiplicative-expr
: unary-expr
| multiplicative-expr * unary-expr
| multiplicative-expr / unary-expr
unary-expr
: primary-expr
| - unary-expr
| not unary-expr
primary-expr
: constant
| $ ID
| $ ID of primary-expr
| map { expr } over primary-expr
| filter { expr } over primary-expr
| traverse { expr } over primary-expr
| sort-expr
| ID primary-expr
| conversion-expr
| parenthesized-expr
| path
상수
: REGEXP_LITERAL
| STRING_LITERAL
| INTEGER_LITERAL
| REAL_LITERAL
| BOOLEAN_LITERAL
sort-expr
: sort-component ( & sort-component )* over primary-expr
sort-component
: sort-direction { expr }
sort-direction
: sort
| sortd
conversion-expr
: conversion-operator primary-expr
conversion-operator
: string
| integer
| real
| boolean
parenthesized-expr
: ( )
| ( expr )
| ( expr (, expr )+ )
path
: anchor
| anchor -association-chain
| association-chain
anchor
: this
| current
| model
| ID
association-chain
: simple-association ( -simple-association )* [ association-chain-tail ]
simple-association
: [ ID : ] [^] ASSOC_LITERAL [ { expr } ]
association-chain-tail
: -reference-association
| -composite-association
reference-association
: @ ID
composite-association
: ( component-association ( ; component-association )+ )
component-association
: reference-association
| association-chain