- 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
- Django+Vue.js商城項目實戰
- 機器學習系統:設計和實現
- Python自然語言處理實戰:核心技術與算法
- C語言程序設計
- 零基礎Java學習筆記
- Internet of Things with ESP8266
- 深度探索Go語言:對象模型與runtime的原理特性及應用
- C語言程序設計實踐
- Python大規模機器學習
- Java RESTful Web Service實戰
- JavaScript前端開發基礎教程
- Python編程入門(第3版)
- ASP.NET Core and Angular 2
- Beginning C# 7 Hands-On:The Core Language
- JavaScript Unit Testing