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`提供语法错误的堆栈。