Syntax vs Semantics

Eden.Yang·2023년 11월 6일
0

PLT

목록 보기
9/14

syntax

  • form of an utterance

semantics

  • meaning

Colorless green ideas sleep furiously!

이 말은 syntax에는 틀린 게 없지만 semantic입장에선 틀렸다.


넷 중에 뭐가 에러가 날까?

둘 다 semantic error이다.


// C++ program to demonstrate semantic error
 
#include <iostream>
using namespace std;
 
// Driver Code
int main()
{
    // Return statement before cout
    return 0;
 
    // Print the value
    cout << "GFG!";
}

문법상의 문제는 없지만 return이 먼저 적혔기에 semantic error이다.

print("Hello, World!"

이 구문은 syntax error이고

def divide(a, b):
    return a * b

이 구문은 semantic에러이다.

profile
손끝에서 땅끝으로, 골방에서 열방으로

0개의 댓글