STUDIO HAZE · image
Topaz source
Open by house policy. Topaz is our own language.
Topaz 5.21 · 113 files
topaz/src/names/c.tpz
Topaz · 2584 B · Original file
1
// C reserved words and preprocessor-resident names that anonymous names avoid.3
import names.ascii { 아스키식별자계속, 아스키식별자시작 }4
import print { 글자합치기 }5
import util { 문자열배열에있음 }7
export function 씨예약이름(이름: string) -> bool {8
문자열배열에있음([9
"_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic",10
"_Imaginary", "_Noreturn", "_Static_assert", "_Thread_local", "alignas",11
"alignof", "auto", "bool", "break", "case", "char", "const",12
"constexpr", "continue", "default", "do", "double", "else", "enum",13
"extern", "false", "float", "for", "goto", "if", "inline", "int",14
"long", "nullptr", "register", "restrict", "return", "short", "signed",15
"sizeof", "static", "static_assert", "struct", "switch", "thread_local",16
"true", "typedef", "typeof", "typeof_unqual", "union", "unsigned", "void",17
"volatile", "while"18
], 이름)19
}21
export function 씨전처리예약이름들(글: string) -> Array<string> {22
let 글자들 = 글.scalars()23
let mut 이름들: Array<string> = []24
let mut 색인 = 025
while 색인 < 글자들.length {26
if 글자들[색인] == "/" && 색인 + 1 < 글자들.length &&27
글자들[색인 + 1] == "/" {28
색인 = 색인 + 229
while 색인 < 글자들.length && 글자들[색인] != "\n" &&30
글자들[색인] != "\r" {31
색인 = 색인 + 132
}33
continue34
}35
if 글자들[색인] == "/" && 색인 + 1 < 글자들.length &&36
글자들[색인 + 1] == "*" {37
색인 = 색인 + 238
while 색인 + 1 < 글자들.length &&39
!(글자들[색인] == "*" && 글자들[색인 + 1] == "/") {40
색인 = 색인 + 141
}42
if 색인 + 1 < 글자들.length { 색인 = 색인 + 2 }43
continue44
}45
if 글자들[색인] == "\"" || 글자들[색인] == "'" {46
let 닫개 = 글자들[색인]47
색인 = 색인 + 148
while 색인 < 글자들.length {49
if 글자들[색인] == "\\" {50
색인 = 색인 + 251
continue52
}53
if 글자들[색인] == 닫개 {54
색인 = 색인 + 155
break56
}57
색인 = 색인 + 158
}59
continue60
}61
if 아스키식별자시작(글자들[색인]) {62
let 시작 = 색인63
색인 = 색인 + 164
while 색인 < 글자들.length && 아스키식별자계속(글자들[색인]) {65
색인 = 색인 + 166
}67
이름들.push(글자합치기(글자들, 시작, 색인))68
continue69
}70
색인 = 색인 + 171
}72
이름들73
}SHA256 850eecff1e728fd054ede1fa800e203061b72817c8658147bc940b58523cb81a