구문 (신택스)

올바르게 구조화된 명령문 또는 표현식으로 간주되는 기호 조합을 정의하는 규칙 집합입니다.

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(Backus-Naur Form) 또는 EBNF를 사용하여 공식적으로 정의됩니다. 파서는 소스 코드에서 추상 구문 트리(AST)를 구성합니다. 구체적 구문(텍스트)과 추상적 구문(트리)의 구분은 컴파일러 설계에 중요합니다. "구문 설탕(Syntactic sugar)"은 기능을 변경하지 않고 코드를 더 읽기 쉽게 만듭니다.

📚 출처