我在OCaml中实现了一个简单的C语言语言,并且像往常一样,AST是我的中间代码表示形式。因为我会在树上做相当多的遍历,所以我想实现 访客模式来缓解疼痛。我的AST当前遵循该语言的语义: type expr = Plus of string*expr*expr | Int of int | ...
type command = While of boolexpr*block | Assign o
interface ICarElementVisitor {
void visit(Engine engine);
}
interface ICarElement {
//want to use this
void accept(ICarElementVisitor visitor); // CarElements have to provide accept(
比方说,我有一个访问者接口这样的: ''' <remarks>Visitor Pattern</remarks>
Public Interface IVisitor
Sub Visit(value As Type1)
Sub Visit(value As Type2)
Sub Visit(value As Type3)
Sub Visit(value As
我使用下面的访问者模式代码解析的XML文件: using RimWorld;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using UnityEngine;
using Verse;