(src: string)
| 68 | |
| 69 | // From glsl2s https://github.com/cimaron/glsl2js/blob/4046611ac4f129a9985d74704159c41a402564d0/preprocessor/comments.js |
| 70 | const preprocessComments = (src: string): string => { |
| 71 | let i; |
| 72 | let chr; |
| 73 | let la; |
| 74 | let out = ''; |
| 75 | let line = 1; |
| 76 | let in_single = 0; |
| 77 | let in_multi = 0; |
| 78 | |
| 79 | for (i = 0; i < src.length; i++) { |
| 80 | chr = src.substring(i, i + 1); |
| 81 | la = src.substring(i + 1, i + 2); |
| 82 | |
| 83 | // Enter single line comment |
| 84 | if (chr == '/' && la == '/' && !in_single && !in_multi) { |
| 85 | in_single = line; |
| 86 | i++; |
| 87 | continue; |
| 88 | } |
| 89 | |
| 90 | // Exit single line comment |
| 91 | if (chr == '\n' && in_single) { |
| 92 | in_single = 0; |
| 93 | } |
| 94 | |
| 95 | // Enter multi line comment |
| 96 | if (chr == '/' && la == '*' && !in_multi && !in_single) { |
| 97 | in_multi = line; |
| 98 | i++; |
| 99 | continue; |
| 100 | } |
| 101 | |
| 102 | // Exit multi line comment |
| 103 | if (chr == '*' && la == '/' && in_multi) { |
| 104 | // Treat single line multi-comment as space |
| 105 | if (in_multi == line) { |
| 106 | out += ' '; |
| 107 | } |
| 108 | |
| 109 | in_multi = 0; |
| 110 | i++; |
| 111 | continue; |
| 112 | } |
| 113 | |
| 114 | // Newlines are preserved |
| 115 | if ((!in_multi && !in_single) || chr == '\n') { |
| 116 | out += chr; |
| 117 | line++; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | return out; |
| 122 | }; |
| 123 | |
| 124 | const tokenPaste = (str: string): string => str.replace(/\s+##\s+/g, ''); |
| 125 |
no outgoing calls
no test coverage detected