codeimage.io

STUDIO HAZE · image

Topaz source

Open by house policy. Topaz is our own language.

Topaz 5.21 · 113 files

topaz/src/names/coffeescript.tpz

Topaz · 2126 B · Original file

1// CoffeeScript reserved words and interpolation names that anonymous names avoid.
3import names.ascii { 아스키식별자계속, 아스키식별자시작 }
4import print { 글자합치기 }
5import util { 문자열배열에있음 }
7export function 커피스크립트예약이름(이름: string) -> bool {
8 문자열배열에있음([
9 "and", "arguments", "await", "break", "by", "catch", "class",
10 "continue", "debugger", "delete", "do", "else", "eval", "extends",
11 "false", "finally", "for", "from", "function", "if", "in",
12 "instanceof", "is", "isnt", "loop", "new", "no", "not", "null",
13 "of", "off", "on", "or", "own", "return", "super", "switch",
14 "then", "this", "throw", "true", "try", "typeof", "undefined",
15 "unless", "until", "when", "while", "yes", "yield"
16 ], 이름)
19// CoffeeScript 보간 본문은 실행 코드다. 바깥 리터럴의 #{...} 구간만
20// 읽어 그 안의 ASCII 식별자를 예약한다. 중첩 보간은 중괄호 깊이로
21// 함께 들어오며, 이 보수적 집합은 살아 있는 이름을 별칭이 가리는
22// 방향만 막는다.
23export function 커피스크립트보간이름들(글: string) -> Array<string> {
24 let 글자들 = 글.scalars()
25 let mut 이름들: Array<string> = []
26 let mut 깊이 = 0
27 let mut 색인 = 0
28 while 색인 < 글자들.length {
29 if 색인 + 1 < 글자들.length && 글자들[색인] == "#" &&
30 글자들[색인 + 1] == "\{" {
31 깊이 = 깊이 + 1
32 색인 = 색인 + 2
33 continue
34 }
35 if 깊이 > 0 && 글자들[색인] == "\{" {
36 깊이 = 깊이 + 1
37 색인 = 색인 + 1
38 continue
39 }
40 if 깊이 > 0 && 글자들[색인] == "\}" {
41 깊이 = 깊이 - 1
42 색인 = 색인 + 1
43 continue
44 }
45 if 깊이 > 0 && 아스키식별자시작(글자들[색인]) {
46 let 시작 = 색인
47 색인 = 색인 + 1
48 while 색인 < 글자들.length && 아스키식별자계속(글자들[색인]) {
49 색인 = 색인 + 1
50 }
51 이름들.push(글자합치기(글자들, 시작, 색인))
52 continue
53 }
54 색인 = 색인 + 1
55 }
56 이름들

SHA256 9bc3d2f7bce4d6a13e144ce21868a9ec4d0db045c8aa83c0b2ebd546895964ee