codeimage.io

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.
3import names.ascii { 아스키식별자계속, 아스키식별자시작 }
4import print { 글자합치기 }
5import util { 문자열배열에있음 }
7export 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 ], 이름)
21export function 씨전처리예약이름들(글: string) -> Array<string> {
22 let 글자들 = 글.scalars()
23 let mut 이름들: Array<string> = []
24 let mut 색인 = 0
25 while 색인 < 글자들.length {
26 if 글자들[색인] == "/" && 색인 + 1 < 글자들.length &&
27 글자들[색인 + 1] == "/" {
28 색인 = 색인 + 2
29 while 색인 < 글자들.length && 글자들[색인] != "\n" &&
30 글자들[색인] != "\r" {
31 색인 = 색인 + 1
32 }
33 continue
34 }
35 if 글자들[색인] == "/" && 색인 + 1 < 글자들.length &&
36 글자들[색인 + 1] == "*" {
37 색인 = 색인 + 2
38 while 색인 + 1 < 글자들.length &&
39 !(글자들[색인] == "*" && 글자들[색인 + 1] == "/") {
40 색인 = 색인 + 1
41 }
42 if 색인 + 1 < 글자들.length { 색인 = 색인 + 2 }
43 continue
44 }
45 if 글자들[색인] == "\"" || 글자들[색인] == "'" {
46 let 닫개 = 글자들[색인]
47 색인 = 색인 + 1
48 while 색인 < 글자들.length {
49 if 글자들[색인] == "\\" {
50 색인 = 색인 + 2
51 continue
52 }
53 if 글자들[색인] == 닫개 {
54 색인 = 색인 + 1
55 break
56 }
57 색인 = 색인 + 1
58 }
59 continue
60 }
61 if 아스키식별자시작(글자들[색인]) {
62 let 시작 = 색인
63 색인 = 색인 + 1
64 while 색인 < 글자들.length && 아스키식별자계속(글자들[색인]) {
65 색인 = 색인 + 1
66 }
67 이름들.push(글자합치기(글자들, 시작, 색인))
68 continue
69 }
70 색인 = 색인 + 1
71 }
72 이름들

SHA256 850eecff1e728fd054ede1fa800e203061b72817c8658147bc940b58523cb81a