Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
350
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goの字句解析を覗いてみる
mm-masahiro
September 27, 2025
Transcript
16 slides
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!!
音声×テクノロジーでワクワクする社会をつくる
Other Decks in Programming
See All in Programming
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
2
120
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
300
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
2k
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
600
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
140
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
100
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
970
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
240
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
220
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
170
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Invisible Side of Design
smashingmag
301
52k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
520
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
The Curious Case for Waylosing
cassininazir
1
610
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
350
Accessibility Awareness
sabderemane
1
290
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
300
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
A Tale of Four Properties
chriscoyier
163
24k