raz / conform / run / RawStrings.raz

61 lines · 1.1 KiB · raw · history · last change 264716cb

1(* Raw strings: no escapes, over lines, indented with the code *)
2module RawStrings;
3import Out;
4
5const
6 Path = `C:\tmp\"a b"\n`;
7 Usage = `
8usage: tool [-v] file
9 -v say what is done
10`;
11 Joined = `back` + "`" + `quote`;
12 Names: [2][]const U8 = [`one`, `two`];
13
14proc show(s: []const U8);
15begin
16 Out.int(LEN(s)); Out.str(" |"); Out.str(s); Out.str("|\n");
17end;
18
19proc main*;
20var b: [8]U8;
21begin
22 show(Path);
23 show(Usage);
24 show(Joined);
25 show(Names[1]);
26 show(``);
27 show(`one
28two`);
29 (* indented: the closing line's blanks come off every line, and a
30 line of blanks alone is empty *)
31 show(`
32 first
33 second
34
35 third
36 `);
37 (* a tab as the indentation *)
38 show(`
39 x
40 y
41 `);
42 (* not indented: something follows the opening backquote *)
43 show(` a
44 b
45 `);
46 (* the closing backquote at the margin takes nothing off *)
47 show(`
48 kept
49`);
50 (* empty, indented *)
51 show(`
52 `);
53 (* carriage returns are left out *)
54 show(`cr
55lf`);
56 if `abc` = "abc" then Out.str("equal\n"); end;
57 b := `héllo`;
58 Out.int(I64(b[1])); Out.ln;
59end;
60
61end RawStrings.