- Roslyn Cookbook
- Manish Vasani
- 142字
- 2021-07-15 17:07:32
Creating a syntax tree analyzer to analyze the source file and report syntax issues
A syntax tree analyzer registers action callbacks to analyze the syntax/grammar for the source file and reports pure syntactic issues. For example, a missing semicolon at the end of a statement is a syntactic error, while assigning an incompatible type to a symbol with no possible type conversion is a semantic error.
In this section, we will write a syntax tree analyzer that analyzes all the statements in a source file and generates a syntax warning for any statement that is not enclosed in a block, that is curly braces { and }. For example, the following code will generate a warning for both the if statement and the System.Console.WriteLine invocation statement, but the while statement is not flagged:
void Method()
{
while (...)
if (...)
System.Console.WriteLine(value);
}
推薦閱讀
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- Visual C++數字圖像處理技術詳解
- Python數據分析從0到1
- 大學計算機基礎實驗指導
- MATLAB for Machine Learning
- C程序設計實踐教程
- ExtJS高級程序設計
- Learning jQuery(Fourth Edition)
- Visual Basic程序設計習題與上機實踐
- Instant Debian:Build a Web Server
- Modernizing Legacy Applications in PHP
- Mastering Apache Camel
- C語言程序設計教程
- Developing Java Applications with Spring and Spring Boot
- ANSYS FLUENT 16.0超級學習手冊