- Perl 6 Deep Dive
- Andrew Shitov
- 246字
- 2021-07-03 00:05:43
The -c command
The -c command-line checks the syntax of the program and exits. It also runs the BEGIN and CHECK blocks in the program, which are discussed in the section Phasers of Chapter 2, Writing Code later in this book. This command-line option is useful if you only want to check that there are no syntax errors in the code and don't want to execute it, with the exception being the code in the BEGIN and CHECK code blocks.
In the case of correct programming, it prints the following output:
Syntax OK
If there were compile-time errors, the compilation will stop at the first error and will display it on the console, mentioning the line number where it found an error.
The error message contains the description of the error and indicates the exact place in the code with the help of the eject character (). If your console supports colors, the fragment of the code before the eject character is green, and the rest of the line is red.
Here is an example of a program that misses the closing quote for the string:
say "Hello;
Run it to check the syntax, as shown here:
$ perl6 -c err.pl
The program did not compile, and this is what the compiler prints:
===SORRY!=== Error while compiling /Users/ash/code/err.pl Unable to parse expression in double quotes; couldn't find final '"' at /Users/ash/code/err.pl:2 ------> <BOL><EOL> expecting any of: argument list double quotes term
- Spring 5.0 Microservices(Second Edition)
- Java應用與實戰
- Learning RxJava
- Learning AWS Lumberyard Game Development
- Python金融數據分析
- MySQL數據庫基礎實例教程(微課版)
- 微服務從小白到專家:Spring Cloud和Kubernetes實戰
- Terraform:多云、混合云環境下實現基礎設施即代碼(第2版)
- Building Machine Learning Systems with Python(Second Edition)
- Visual C#.NET Web應用程序設計
- LabVIEW虛擬儀器程序設計從入門到精通(第二版)
- Java Fundamentals
- Geospatial Development By Example with Python
- 運維前線:一線運維專家的運維方法、技巧與實踐
- Extending Unity with Editor Scripting