Syntax vs. Semantics

在程序设计中经常会使用到Syntax和Semantics,那么这两者分别是什么意思,又有什么区别呢?

Syntax是语法,Semantics是语义;从字面的意思来看,前者注重的是“法则”,而后者则偏重于“涵义”。以SQL语句为例,在Oracle中,解析Sql语句要先经过语法检查,然后再进行语义检查。语法检查时,会判断你写的SQL语句中是否有错别字,如把select写成了selct等;而语义则是判断你写这个SQL的目的是什么——是要查询,还是个性数据等。

 

ContractedBlock.gif ExpandedBlockStart.gif Code
What is the difference between syntax and semantics. 


This question could be answered merely by taking a definition out of 
any dictionary or cognitive psychology text book. John R. Anderson 
defines the two in his book " Cognitive psychology and its 
implications"(1995) as, 
Semantics- Grammatical rules for assigning meaning to a sentence. 
Syntax- Grammatical rules for specifying correct word order and 
inflectional structure in a sentence. 
Doing this does not really give a clear explanation of the 
differences between the two. It is beter explained if the features of 
the two are explored more thoroughly. 
Word order is the basic principal of syntax, those trying to 
understand what is written use the syntactic cues of word order to 
help give the sentence structure and meaning. Word order gives a 
sentence the correct intonnation especially with the use of funtion 
words such as,a and who, due to this its meaning becomes much 
clearer. If the words of a sentence were not in the correct order 
there would be no syntactic cues as to the meaning of the sentence. 
This point leads on to the difference between syntax and semantics. 
Semantics are an individuals own interpretation of the meaning of a 
"sentence" based on their prior knowledge. Therefore a sentence that 
seemingly makes no syntactic sense, can have meaning when using 
semantic cues. The sentence "Baby milk drinks" does not have a 
syntactic meaning, but through semantics most people would interpret 
it as meaning " Baby drinks milk " as our prior knowledge tells us 
that a baby drinks milk, and therefore we can find a meaning from the 
key words. 
The difference between syntax and semantics is that syntax is only 
concerned with what is linguistically and grammatically correct, 
semantics requires all ones prior knowledge which, as Anderson 
states, " goes far beyond anything which is language specific". 


转载于:https://www.cnblogs.com/ungshow/archive/2012/04/02/1361347.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值