summaryrefslogtreecommitdiff
path: root/tests/examplefiles/q/example.q
blob: 132b8f9ec1a81337d3405ba7f25b3bce56661935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/ shebang
#!/bin/q

/ preprocessor
\d .namespace

/ keywords such as flip and prd should not be highlighted in comments
"keywords such as flip and prd should not be highlighted in strings"

/ keep syntax highlighting for timing code
\t 1+1
\ts 1+1

/ highlight until comment but not next line
\c 20 40 / comment
a:1 / this is no longer part of the system command

/ 2-digit system commands run til end of line
\cd /foo/bar

/ prompt
q)1+2

/
this is a
multi-line comment
\

 /
this is not a
multi-line comment
\

"string with escapted quote \" and random escape \\"

``foo`bar                       / symbols
`/not/a/symbol                  / not a symbol
`:`:/path/to/file               / file symbols
'`length                        / exception

2000.01m                        / month
2000.01.01                      / date
2000.01.01D                     / timestamp
2000.01.01D00                   / timestamp
2000.01.01D00:00                / timestamp
2000.01.01D00:00:00             / timestamp
2000.01.01D00:00:00.000         / timestamp
2000.01.01D00:00:00.000000      / timestamp

2000.01.01T                     / datetime
2000.01.01T00                   / datetime
2000.01.01T00:00                / datetime
2000.01.01T00:00:00             / datetime
2000.01.01T00:00:00.000         / datetime

00:00                           / time
00:00:00                        / time 
00:00:00.000                    / time

8c6b8b64-6815-6084-0a3e-178401251b68 / guid

101010b                         / booleans
(0w;0N;0n;0Wp)                  / null/infinities
0x01fe                          / octal

(1;1j;1n;1p)                    / long integers
(1c;1h;1i;1t;1u;1v)             / integers
(1e;1f;1.;.1;1.0;1.0f)          / floats
(.1e8;1.e8;1e-8f;1E-8)          / floats

/ ascii operators
(-;=;+;*;#;$;%;@;!;~;^;&;:;.;,;<;>;';\;|;/;?;_)

/ k keywords
(abs; acos; asin; atan; avg; bin; binr; by cor; cos; cov; dev;
 delete; div; do enlist; exec; exit; exp; from; getenv; hopen if;
 in; insert; last; like; log; max; min; prd select; setenv; sin;
 sqrt; ss; sum tan; update; var wavg; while; within; wsum; xexp)

/ q operators
(aj; aj0; ajf; ajf0; all; and; any; asc; asof; attr; avgs; ceiling;
 cols; count; cross; csv; cut; deltas; desc; differ; distinct; dsave;
 each; ej; ema; eval; except; fby; fills; first; fkeys; flip; floor;
 get; group; gtime; hclose; hcount; hdel; hsym; iasc; idesc; ij; ijf;
 inter; inv; key; keys; lj; ljf; load; lower; lsq; ltime; ltrim; mavg;
 maxs; mcount; md5; mdev; med; meta; mins; mmax; mmin; mmu; mod; msum;
 neg; next; not; null; or; over; parse; peach; pj; prds; prior; prev;
 rand; rank; ratios; raze; read0; read1; reciprocal; reval; reverse;
 rload; rotate; rsave; rtrim; save; scan; scov; sdev; set; show;
 signum; ssr; string; sublist; sums; sv; svar; system; tables; til;
 trim; txf; type; uj; ujf; ungroup; union; upper; upsert; value; view;
 views; vs; where; wj; wj1; ww; xasc; xbar; xcol; xcols; xdesc;
 xgroup; xkey; xlog; xprev; xrank)

.foo.bar : {[x;y]x+y}           / function declaration
.foo.bar : {x+y}                / function declaration
foo.bar : "string"              / variable declaration
foo.bar ,: "amend"              / variable amend


{x+y}/[1 2]                     / anonymous function

f:{[x;y]                        / multiline function
 x:`foo;
 y:`bar;
 z:x,y;
 z}