Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Goの字句解析を覗いてみる
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
mm-masahiro
September 27, 2025
Programming
280
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goの字句解析を覗いてみる
mm-masahiro
September 27, 2025
Other Decks in Programming
See All in Programming
FastAPI の並行処理モデルを完全に理解する
hoto17296
7
2.5k
Go 1.27 における memory allocation の高速化
andpad
0
290
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.1k
Oxlintはいいぞ(続)
yug1224
1
340
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
310
テーブルをDELETEした
yuzneri
0
150
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
300
React本体のコードリーディング
high_g_engineer
1
150
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
200
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.9k
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
950
Featured
See All Featured
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
450
AI: The stuff that nobody shows you
jnunemaker
PRO
9
930
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Accessibility Awareness
sabderemane
1
180
Believing is Seeing
oripsolob
1
200
The Cult of Friendly URLs
andyhume
79
7k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
The SEO Collaboration Effect
kristinabergwall1
1
530
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
220
A better future with KSS
kneath
240
18k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Transcript
Goの字句解析を覗いてみる 2025/9/27 株式会社Voicy 森永 雅大
© Voicy, Inc. func hoge(foo …string) { ~~~ } コンパイル通ると思いますか?
func hoge(foo…string) { ~~~ } 空白なし ① ②
© Voicy, Inc. The Go Programming Language Specification go.dev/ref/spec
© Voicy, Inc. 字句解析とは?
© Voicy, Inc. 字句解析とは? • 文字の並びを解析して、ある言語にとって意味のある最小単位(トーク ン)に分割する仕組み ◦ 字句解析によって、文がトークンに分割される ex.)
var myName = "masahiro"
© Voicy, Inc. 字句解析とは? • 文字の並びを解析して、ある言語にとって意味のある最小単位(トーク ン)に分割する仕組み ◦ 字句解析によって、文がトークンに分割される ex.)
var myName = "masahiro" → var / myName / = / "masahiro"
© Voicy, Inc. Goの字句解析の仕様
© Voicy, Inc. 4つのトークンの種類 • Identifiers • Keywords • Operators
and punctuation • Literals Goの字句解析の仕様
© Voicy, Inc. Identifiers • 変数や関数名などの名前を表すトークン • 1つ以上の文字や数字から成る • 最初の1文字目(character)は、文字(letter)でないといけない
◦ _ は使える ex. 4種類のトークン func voicy() { voicy := "音声配信プラットフォーム " type hiringRole struct { engineer bool } エンジニアが発信しているチャンネル := "https://voicy.jp/channel/1305" }
© Voicy, Inc. Identifiers • 変数や関数名などの名前を表すトークン • 1つ以上の文字や数字から成る • 最初の1文字目(character)は、文字(letter)でないといけない
ex. 4種類のトークン func voicy() { voicy := "音声配信プラットフォーム " type hiringRole struct { engineer bool } エンジニアが発信しているチャンネル := "https://voicy.jp/channel/1305" }
© Voicy, Inc. 空白の扱い • 空白は通常は無視されるが、空白がないと複数あるべきトークンが、別の1つのトー クンとして扱われてしまう場合にはトークンの区切りとして扱われる 空白の扱い var x
= 1 var x=1
© Voicy, Inc. 最長一致のルール 最長一致のルール • 意味のある単位として取れる限り最長の文字列をトークンとして扱う a + 10
a++
© Voicy, Inc. コンパイル通ると思いますか? func hoge(foo …string) { ~~~ }
func hoge(foo…string) { ~~~ } 空白なし ① ②
© Voicy, Inc. コンパイル通ると思いますか? func hoge(foo …string) { ~~~ }
func hoge(foo…string) { ~~~ } 空白なし ① ②
© Voicy, Inc. func hoge(foo…string) {} コンパイル通ると思いますか? 空白あっても なくてもOK!!
音声×テクノロジーでワクワクする社会をつくる