Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/strip-comments-from-a-string.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / strip-comments-from-a-string.wiki` 64 lines ยท 1259 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text lq "<<<" 8 text rq ">>>" 9 text s1 "apples, pears # and bananas" 10 text s2 "apples, pears ; and bananas" 11 text s3 " no comment here " 12 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 13 fn emit a view uchar * to void 14 o = ulong 0 15 while lt o len a bound 4096 16 k = write 1 a o sub len a o 17 if le k 0 18 exit 1 19 end 20 o = add o ulong k 21 end 22 end 23 note cut at the first '#' or ';', then drop whitespace (space, tab) at both ends of what is left 24 fn strip a view uchar * to void 25 e = len a 26 for i ulong len a 27 c = get a i 28 if and eq e len a or eq c 35 eq c 59 29 e = i 30 end 31 end 32 s = ulong 0 33 while lt s e bound 4096 34 c = get a s 35 if and ne c 32 ne c 9 36 break 37 end 38 s = add s 1 39 end 40 while gt e s bound 4096 41 c = get a sub e 1 42 if and ne c 32 ne c 9 43 break 44 end 45 e = sub e 1 46 end 47 emit lq 48 emit part a s sub e s 49 emit rq 50 emit nl 51 end 52 fn main to int 53 strip s1 54 strip s2 55 strip s3 56 ret 0 57 end 58 59 {{out}} 60

61 <<<apples, pears>>>

62 <<<apples, pears>>>

63 <<<no comment here>>>

64