構文(シンタックス)
正しく構造化されたステートメントまたは式と見なされる記号の組み合わせを定義するルールのセット。
Components: 1. Sensors (Perception). 2. Actuators (Action). 3. Performance Measure (Goal). 4. Environment. 5. Knowledge Base.
graph LR
Center["構文(シンタックス)"]:::main
Rel_semantics["semantics"]:::related -.-> Center
click Rel_semantics "/terms/semantics"
Rel_compiler["compiler"]:::related -.-> Center
click Rel_compiler "/terms/compiler"
Rel_python["python"]:::related -.-> Center
click Rel_python "/terms/python"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 5歳でもわかるように説明
構文は、コンピュータ言語の文法ルールです。日本語で「赤い猫」と言いますが、「猫 赤い が」とは言いません。言い方を間違えると、コンピュータは混乱してあなたを理解できません。
🤓 Expert Deep Dive
構文は、バッカス・ナウア記法(BNF)またはEBNFを使用して形式的に定義されることがよくあります。パーサーは、ソースコードから抽象構文木(AST)を構築します。具象構文(テキスト)と抽象構文(ツリー)の区別は、コンパイラの設計にとって重要です。「糖衣構文(シンタックスシュガー)」は、機能を変更せずにコードを読みやすくします。