本文整理汇总了C#中Dsl.Visit方法的典型用法代码示例。如果您正苦于以下问题:C# Dsl.Visit方法的具体用法?C# Dsl.Visit怎么用?C# Dsl.Visit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsl
的用法示例。
在下文中一共展示了Dsl.Visit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFile
public static IEnumerable<string> GenerateFile(string file)
{
var name = Path.GetFileNameWithoutExtension(file);
var directory = Path.GetDirectoryName(file);
File representation;
using (var stream = System.IO.File.OpenRead(file))
{
var lexer = new GrammarLexer(new AntlrInputStream(stream));
var tokenStream = new CommonTokenStream(lexer);
var context = new GrammarParser(tokenStream).program();
var dsl = new Dsl(name);
dsl.Visit(context);
representation = dsl.File;
}
var outputs = representation.GenerateSource();
if (outputs.HasMessageContent)
{
if (outputs.HasMarkers)
{
var path = Path.Combine(directory, $"{representation.Name}MarkerInterfaces.cs");
System.IO.File.WriteAllText(path, outputs.Markers);
yield return path;
}
if (outputs.HasMessages)
{
var path = Path.Combine(directory, $"{representation.Name}Messages.cs");
System.IO.File.WriteAllText(path, outputs.Messages);
yield return path;
}
if (outputs.HasEnumerations)
{
var path = Path.Combine(directory, $"{representation.Name}Enums.cs");
System.IO.File.WriteAllText(path, outputs.Enumerations);
yield return path;
}
}
if (outputs.HasStateDefinitions)
{
var path = Path.Combine(directory, $"{representation.Name}StateSubscriptions.cs");
System.IO.File.WriteAllText(path, outputs.StateDefinitions);
yield return path;
}
if (outputs.HasEntities)
{
var path = Path.Combine(directory, $"{representation.Name}Entities.cs");
System.IO.File.WriteAllText(path, outputs.Entities);
yield return path;
}
}