トークナイザーとは?
トークナイザーは生のソースコードを1文字ずつ走査し、それらの文字をキーワード、演算子、リテラルといったトークンと呼ばれる意味のある単位にまとめます。空白やコメントを取り除きつつ、各トークンに型と位置を付与します。生成されるトークンの並びは、パーサーが構文木を構築するために消費する入力となります。
なぜ重要か
先にトークン化することで、構造化されていない文字の並びを、パーサーが推論できる離散的な単位へと変換します。トークンの境界が明確であれば、文法規則やエラーメッセージをはるかに簡単に表現できます。
関連ガイド
What Is Register Allocation?Register allocation is the compiler step that decides which program values are kept in fast CPU registers and…
What Is Template Instantiation?Template instantiation is the compiler generating concrete code from a generic template for each specific set…
What Is a Basic Block?A basic block is a straight-line sequence of instructions with one entry and one exit, used as the unit of an…