什么是语法错误?

During the application development, we may cause syntax errors which will prevent applications to run or compile. Syntax errors are described as compile-time errors which are detected before compiling applications except for interpreted languages.

在应用程序开发期间,我们可能会导致语法错误,这将阻止应用程序运行或编译。 语法错误被描述为编译时错误,在编译应用程序之前会检测到这些错误,但解释语言除外。

语法错误 (Syntax Error)

The syntax is the form of the words specified by the programming language. Syntax errors occurred by using the programming language keyword form in an inappropriate way. For example, even the following syntax is true for the Java programming language.

语法是由编程语言指定的单词的形式。 通过以不适当的方式使用编程语言关键字形式发生语法错误。 例如,对于Java编程语言,甚至以下语法也适用。

System.out.println("Hello Poftut.com");

The following example has a syntax error where the string Hello Poftut.com does not have double quotes where println() requires double-quotes.

以下示例存在语法错误,其中字符串Hello Poftut.com没有双引号,而println()需要双引号。

System.out.println(Hello Poftut.com);

Some Integrated Development Environments (IDE) provides

一些集成开发环境(IDE)提供

语法错误类型和消息(Syntax Error Types and Messages)

Syntax errors have not well-defined types but we can list some of the popular below.

语法错误没有明确定义的类型,但我们可以在下面列出一些常见的错误。

  • Incorrectly spelled statements

    拼写错误的陈述
  • Incorrectly spelled variables

    拼写错误的变量
  • Incorrect end of lines like `;` or EOL

    不正确的行尾,如`;`或EOL
  • Incorrectly used variables

    变量使用不正确
  • Missing Quotes, brackets, etc.

    缺少引号,方括号等

Java中的语法错误(Syntax Error In Java)

Java programming language may have syntax errors. Here are some of them.

Java编程语言可能存在语法错误。 这里是其中的一些。

System.out.println(Hello Poftut.com);

int a === 15;

PHP中的语法错误 (Syntax Error In PHP)

PHP has also syntax errors like below.

PHP也有如下语法错误。

$age = 12.a;

echo age;

JavaScript中的语法错误 (Syntax Error In JavaScript)

JavaScript syntax errors are like below.

JavaScript语法错误如下所示。

test === 123;

JavaScript language has the SyntaxError object which is created as an exception and provides information about syntax errors.

JavaScript语言具有SyntaxError对象,该对象被创建为异常,并提供有关语法错误的信息。

  • `SyntaxError.prototype.message` provides the syntax error message

    `SyntaxError.prototype.message`提供语法错误信息
  • `SyntaxError.prototype.name` provides the name of the syntax error.

    `SyntaxError.prototype.name`提供语法错误的名称。
  • `SyntaxError.prototype.fileName` provides information about path of the syntax error.

    SyntaxError.prototype.fileName提供有关语法错误路径的信息。
  • `SyntaxError.prototype.lineNumber` provides the line number of the syntax error.

    SyntaxError.prototype.lineNumber提供语法错误的行号。
  • `SyntaxError.prototype.columnNumber` provides the column of the syntax error

    `SyntaxError.prototype.columnNumber`提供语法错误列
  • `SyntaxError.prototype.stack` provides the stack of the syntax error.

    `SyntaxError.prototype.stack`提供语法错误的堆栈。
LEARN MORE  JavaScript "Uncaught TypeError: Cannot set property '...' of null " Error Solutions
了解更多JavaScript“ Uncaught TypeError:无法设置null的属性'...'错误解决方案

翻译自: https://www.poftut.com/what-is-syntax-error/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值