zoukankan      html  css  js  c++  java
  • Syntactic and Semantic Errors

    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)

     

  • 相关阅读:
    J2EE开发工作中遇到的异常问题及解决方法总结
    报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
    配置JAVA的环境变量
    win7系统下ping不是内部或外部命令
    【pyhon】理想论坛单帖爬虫取得信息存入MySql数据库
    【Python】安装Python的mysql模块
    【Python】爬取理想论坛单帖爬虫
    挖一口井最好的时间除了十年前就是现在
    【Python】http.client库的用法
    【pyhon】nvshens按目录图片批量下载爬虫1.00(多线程版)
  • 原文地址:https://www.cnblogs.com/shangdawei/p/4703518.html
Copyright © 2011-2022 走看看