博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Syntactic and Semantic Errors
阅读量:5245 次
发布时间:2019-06-14

本文共 2451 字,大约阅读时间需要 8 分钟。

There are two kinds of errors that Basis can find. 

  •  Syntax errors occur during the parsing of input code, and are caused by grammatically incorrect statements.

    Typical errors might be an illegal character in the input, a missing operator, two operators in a row,
    two statements on the same line with no intervening semicolon, unbalanced parentheses, a misplaced reserved word, etc.

  •  Semantic errors occur during the execution of the code, after it has been parsed as grammatically correct.

    These have to do not with how statements are constructed, but with what they mean.
    Such things as incorrect variable types or sizes, nonexistent variables, subscripts out of range, and the like, are semantic errors.

Basis is a single-pass  parser, that is, it looks at its input only once.

It also is a one-look ahead  parser, meaning that at the most it is never looking more than one symbol ahead of the current context.

By the time a syntax error has been detected, it is likely that a lot of the context information to the left of the error has already been lost.

The diagnostic information that Basis gives attempts to be as useful as possible,

but because of the very limited context information available, it is far from perfect.  

Semantic errors are often possible to diagnose more precisely.

We have attempted to make the semantic error information supplied as useful as possible.

Sometimes some of the information is only useful to someone familiar with the internals of Basis;

but we hope that in most cases it will help you find your error.

 

Syntax Error:

error due to missing colon, semicolon, parenthesis, etc.

Syntax is the way in which we construct sentences by following principles and rules.

Example: In C++, it would be a syntax error to say

int x = "five";

This will not compile because it does not follow the syntax of the language and does not make any sense to the compiler.

Semantic Error:

it is a logical error. it is due to wrong logical statements.

Semantics is the interpretations of and meanings derived from the sentence transmission and understanding of the message.

Semantics errors are Logical, while Syntax errors are code errors.

Example: A semantic error would compile, but be incorrect logically:

const int pi = 12345;

Your program will likely compile and run without error but your results will be incorrect.

(Note that these types of errors are usually much harder to debug)

 

 

转载于:https://www.cnblogs.com/shangdawei/p/4703518.html

你可能感兴趣的文章
关于本博客说明
查看>>
线程androidAndroid ConditionVariable的用法
查看>>
stap-prep 需要安装那些内核符号
查看>>
2016寒假自学笔记
查看>>
转载:ASP.NET Core 在 JSON 文件中配置依赖注入
查看>>
socket初识
查看>>
磁盘测试工具
查看>>
代码变量、函数命名神奇网站
查看>>
redis cli命令
查看>>
Problem B: 占点游戏
查看>>
python常用模块之sys, os, random
查看>>
HDU 2548 A strange lift
查看>>
Linux服务器在外地,如何用eclipse连接hdfs
查看>>
react双组件传值和传参
查看>>
BNU29140——Taiko taiko——————【概率题、规律题】
查看>>
[Kaggle] Sentiment Analysis on Movie Reviews
查看>>
价值观
查看>>
mongodb命令----批量更改文档字段名
查看>>
CentOS 简单命令
查看>>
使用 SharedPreferences 分类: Andro...
查看>>