| 1 | (* Raw strings: no escapes, over lines, indented with the code *) |
| 2 | module RawStrings; |
| 3 | import Out; |
| 4 | |
| 5 | const |
| 6 | Path = `C:\tmp\"a b"\n`; |
| 7 | Usage = ` |
| 8 | usage: tool [-v] file |
| 9 | -v say what is done |
| 10 | `; |
| 11 | Joined = `back` + "`" + `quote`; |
| 12 | Names: [2][]const U8 = [`one`, `two`]; |
| 13 | |
| 14 | proc show(s: []const U8); |
| 15 | begin |
| 16 | Out.int(LEN(s)); Out.str(" |"); Out.str(s); Out.str("|\n"); |
| 17 | end; |
| 18 | |
| 19 | proc main*; |
| 20 | var b: [8]U8; |
| 21 | begin |
| 22 | show(Path); |
| 23 | show(Usage); |
| 24 | show(Joined); |
| 25 | show(Names[1]); |
| 26 | show(``); |
| 27 | show(`one |
| 28 | two`); |
| 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 |
| 55 | lf`); |
| 56 | if `abc` = "abc" then Out.str("equal\n"); end; |
| 57 | b := `héllo`; |
| 58 | Out.int(I64(b[1])); Out.ln; |
| 59 | end; |
| 60 | |
| 61 | end RawStrings. |