Twitter hashtag: #esspec
便利ツール
時事ネタ
自己紹介 (近況報告)
syumai syumai.icon
JSConf JP面白かったです
懇親会は行けずに残念
File System Access APIすごい
tars0x9752 (たーず / naoki aoyama) tars0x9752.icon
nerd font をめちゃくちゃ久々にバージョンアップしたらいろいろ breaking changes が入ってて大変なことになった
polybarよさそうyebis0942.icon
iwatsurut
とくに、イベントもなく過ごしています。
yebis0942yebis0942.icon
JSConf JP、発表資料だけ読みました
Track Aのアーカイブは非公開っぽい
C++の仕様でECMAScriptの正規表現の仕様が一部参照されているらしい
仕様の再利用よさそう
GitHubのmonospaceフォント使ってみてます
tars0x9752.icon monaspace kana
yebis0942.iconmonospaceなmonaspaceでした…
Texture healingすごい
OpenTypeフォントのcontextual alternatesという規格を使って隣接文字に応じて字形のバランスを調節している
20:50 再開
前回のあらすじ
今回の範囲
Static Semantics: TV
TV = template value
インデックス付きのtemplate objectのコンポーネントを組み立てるために使われる
The TV of TemplateCharacter :: $ is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
$とその他の一般的な文字列は生成規則の中で別のalternativeとして定義されているので、ここでも別に記載する必要がある
TemplateCharacter :: \ NotEscapeSequence is undefined.
通常のtemplate string literalではsyntax error
code:js
\x // synatx error
tagged template literalではsynatx errorが発生しない
code:js
((s)=>s)\x // undefined
((...args) => { return console.log(args),"" })a \00 b${1}2${3}4;
''
処理系ごとのエラーメッセージ
code:console
// V8
\09
VM100:1 Uncaught SyntaxError: Octal escape sequences are not allowed in template strings.
// SpiderMonkey
\09
Uncaught SyntaxError: octal escape sequences can't be used in untagged template literals or in strict mode code
(英語) colloquially: 口語で言うところの
Static Semantics: TRV
TRV = Template Raw Value
TVと似ているが、エスケープシーケンスはそのままの文字列としてstringになる
String.raw()っぽい
code:js
\x0${1}\x0${2}
\x0${1}\x0${2}
^^^^
Uncaught SyntaxError: Invalid hexadecimal escape sequence
String.raw\x0${1}\x0${2}
'\\x01\\x02'
NOTE: template stringの中の<CR>, <CR><LF>は<LF>に正規化される
Automatic Semicolon Insertion
three basic rules of semicolon insertion:
1. offending token(どんな生成規則にも一致しないトークン)が以下のルールのいずれか1つ以上に当てはまっていたら、offending tokenの直前にセミコロンを入れる
a. offending tokenと直前のトークンの間に1つ以上のLineTerminatorがある
b. offending tokenが}
c. The previous token is ) and the inserted semicolon would then be parsed as the terminating semicolon of a do-while statement (14.7.2).
2. パースできないままソースコードの終端にたどり着いたら末尾にセミコロンを入れる
3. restricted production
code:js
// 1-a
const
a
=
1
/* セミコロンが自動挿入される */console // offending token
.log(
a
)
code:js
// 1-b
if (true) { a = 1 /* セミコロンが自動挿入される */ }
() => { console.log(s) /* セミコロンが自動挿入される */ }
code:js
// 1-c
let i = 0
do {
i++
} while(i < 5) /* セミコロンが自動挿入される */ {
console.log(i)
}
code:js
// 2
console.log(1) /* セミコロンが自動挿入される */
code:js
$ cat f.js
let a = 0
a
++
$ node f.js
/Users/syumai/go/src/github.com/syumai/til/js/esspec8/f.js:4
SyntaxError: Unexpected end of input
追加の上書き条件
empty statementにはならない
空のソースコード?
Scriptは文法定義上は空でも許されるので違いそう
code:js
eval(if(true)) // Uncaught SyntaxError: expected expression, got end of script
eval(if(true);) // OK
というケースではない?yebis0942.icon
for文のセミコロンにはならない
code:js
for (let i = 0; i < 10; i++) {
console.log(i);
}
// 以下の場合は自動セミコロン挿入しない
for (
let i = 0
i < 10
i++
) {
console.log(i);
}
for (
let i = 0
;i < 10
;i++
) {
console.log(i);
}