- 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);
}
推薦閱讀
- Oracle從入門到精通(第3版)
- Mastering ServiceStack
- Python爬蟲開發:從入門到實戰(微課版)
- 你必須知道的204個Visual C++開發問題
- EPLAN實戰設計
- Gradle for Android
- Multithreading in C# 5.0 Cookbook
- C#開發案例精粹
- C++20高級編程
- Building Dynamics CRM 2015 Dashboards with Power BI
- Java并發編程之美
- Learning Splunk Web Framework
- Python+Office:輕松實現Python辦公自動化
- Machine Learning for OpenCV
- 零基礎學C++(升級版)