The main class of a compiler generated with Coco/R has to be provided by the user. It
has to create a scanner and a parser object, initiate parsing and possibly report the
number of errors detected. In its simplest form it can look like this:
public class Compiler {
public static void Main(string[] arg) {
Scanner scanner = new Scanner(arg[0]);
Parser parser = new Parser(scanner);
parser.Parse();
Console.WriteLine(parser.errors.count + " errors detected");
}
}
coco/r的编译器主类
本文介绍如何使用 Coco/R 生成的代码来实现一个简单的编译器主类。用户需要创建扫描器和解析器对象,并启动解析过程。示例代码展示了如何报告检测到的错误数量。

被折叠的 条评论
为什么被折叠?



