本文整理汇总了C#中CodeGenerator.VisitChild方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.VisitChild方法的具体用法?C# CodeGenerator.VisitChild怎么用?C# CodeGenerator.VisitChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.VisitChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimpleCodeTest
public void SimpleCodeTest()
{
// GIVEN
var source = @"
function max(a: number, b: number) : number do
while (a < b) do
skip;
end;
end;
a.b.c;
toString('Hello World', 10);
(10 + 5) * b;
foreach (var str : string in ['Hello', 'World']) do
if (a > 10)
if (true) writeline(str); end;
else
skip;
end;
end;
object Person
name: string;
age: number;
end;
attribute @not-null(id: string, id2: number);
var b : number = 100;
";
var analyzer = new CodeGenerator();
// WHEN
var node = ParseWithAbstractTreeVisitor(Compiler, source);
var result = analyzer.VisitChild(node as CompilationUnit);
// THEN
Debug.WriteLine(result.ToString());
}
示例2: SimpleMacroTest
public void SimpleMacroTest()
{
// GIVEN
var source = @"
implicit macro debugMacro(tree: { * > foreach[body][loop-variable = str] > * }) do
writeline('Actual parameters of helloMacro');
writeline('-------------------');
var i : number = 1;
foreach (var str : string in convertToString(tree)) do
writeline(i + '. AST');
write(str);
writeline('-------------------');
i = i + 1;
end;
end;
function max(a: number, b: number) : number do
while (a < b) do
skip;
end;
end;
a.b.c;
toString('Hello World', 10);
(10 + 5) * b;
foreach (var str : string in ['Hello', 'World']) do
if (a > 10)
if (true) writeline(str); end;
else
skip;
end;
skip;
end;
foreach (var i : number in [1,2,3,4]) do
skip;
end;
object Person
name: string;
age: number;
end;
attribute @not-null(id: string, id2: number);
var b : number = 100;
";
var macroInterpreter = new MacroInterpreter(new CompilerService());
var codeGenerator = new CodeGenerator();
// WHEN
var node = ParseWithAbstractTreeVisitor(Compiler, source);
macroInterpreter.VisitChild(node as CompilationUnit);
var result = codeGenerator.VisitChild(macroInterpreter.Root);
// THEN
Debug.WriteLine(result.ToString());
}