官术网_书友最值得收藏!

  • 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);
}
主站蜘蛛池模板: 武夷山市| 株洲市| 鄂尔多斯市| 绥化市| 潍坊市| 龙海市| 湄潭县| 盘锦市| 台中县| 独山县| 松原市| 冀州市| 南平市| 富宁县| 兴宁市| 长宁区| 高尔夫| 盘锦市| 米易县| 蓬溪县| 吐鲁番市| 剑河县| 寻乌县| 安陆市| 西乡县| 永嘉县| 泸州市| 义乌市| 双辽市| 衢州市| 婺源县| 曲周县| 东至县| 桐城市| 柳江县| 霍州市| 西和县| 新和县| 迁西县| 双江| 河池市|