public override void Traverse(ISyntaxTreeVisitor visitor) { visitor.Visit(this); visitor.Start(this); base.Traverse(visitor); visitor.Finish(this); }
public static void Traverse <T>(this List <T> nodes, ISyntaxTreeVisitor visitor) where T : SyntaxNode { foreach (var n in nodes) { n?.Traverse(visitor); } }
public ConversionTestCase(string name, string description, ISyntaxTreeVisitor syntaxTreeVisitor, CodeWriter codeWriter, string testDirectory) { Name = name; Description = description; SyntaxTreeVisitor = syntaxTreeVisitor; CodeWriter = codeWriter; TestDirectory = testDirectory; }
public override void Traverse(ISyntaxTreeVisitor visitor) { visitor.Visit(this); visitor.Start(this); base.Traverse(visitor); Variable.Traverse(visitor); From.Traverse(visitor); To.Traverse(visitor); Step?.Traverse(visitor); visitor.Finish(this); }
public CsvNode Parse(String input, ISyntaxTreeVisitor <CsvNode, IParseTree> treeVisitor) { Assume.NotNull(input, nameof(input)); Assume.NotNull(treeVisitor, nameof(treeVisitor)); var stream = new AntlrInputStream(input); ITokenSource lexer = new CsvLexer(stream); ITokenStream tokens = new CommonTokenStream(lexer); var parser = new CsvParser(tokens) { BuildParseTree = true }; var tree = parser.start(); return(treeVisitor.Visit(input, tree)); }
public Node Parse <TResult>(String input, ISyntaxTreeVisitor <TResult, IParseTree> treeVisitor, IHasSyntaxTree treeFactory) { Assume.NotNull(input, nameof(input)); Assume.NotNull(treeVisitor, nameof(treeVisitor)); Assume.NotNull(treeFactory, nameof(treeFactory)); var stream = new AntlrInputStream(input); ITokenSource lexer = new CsvLexer(stream); ITokenStream tokens = new CommonTokenStream(lexer); var parser = new CsvParser(tokens) { BuildParseTree = true }; var tree = parser.start(); treeVisitor.Visit(input, tree); return(treeFactory.GetSyntaxTree().Safe(syntaxTree => syntaxTree.Root)); }
static Fixture() { SyntaxTreeVisitors = new ISyntaxTreeVisitor[] { new PowerShellSyntaxTreeVisitor(), new CSharpSyntaxTreeVisitor() }; CodeWriters = new CodeWriter[] { new PowerShellCodeWriter(), new CSharpCodeWriter() }; _data = new List <object[]>(); foreach (var syntaxTreeVisitor in SyntaxTreeVisitors) { foreach (var codeWriter in CodeWriters) { if (syntaxTreeVisitor.Language == codeWriter.Language) { continue; } var sourceLanguage = Enum.GetName(typeof(Language), syntaxTreeVisitor.Language); var targetLanguage = Enum.GetName(typeof(Language), codeWriter.Language); var testDirectory = Fixture.GetTestDirectory(); testDirectory = Path.Combine(Path.Combine(testDirectory, "Languages"), sourceLanguage + "To" + targetLanguage); var testManifestFile = Path.Combine(testDirectory, "tests.json"); var testManifestContent = File.ReadAllText(testManifestFile); var testManifest = JsonConvert.DeserializeObject <TestManifest>(testManifestContent); foreach (var testCase in testManifest.TestCases) { _data.Add(new[] { new ConversionTestCase(testCase.Name, testCase.Description, testCase.Category, syntaxTreeVisitor, codeWriter, testDirectory) }); } } } }
/// <summary> /// Accept method for the visitor /// </summary> /// <param name="visitor">The visitor</param> public override void Accept(ISyntaxTreeVisitor visitor) { visitor.Visit(this); }
/// <summary> /// Accept method for the visitor /// </summary> /// <param name="visitor">The visitor</param> public abstract void Accept(ISyntaxTreeVisitor visitor);
public ExpressionChildrenVisitor(ISyntaxTreeVisitor?preOrderVisitor, ISyntaxTreeVisitor?postOrderVisitor, ISyntaxTreeVisitor childrenVisitor) { _preOrderVisitor = preOrderVisitor; _postOrderVisitor = postOrderVisitor; _childrenVisitor = childrenVisitor; }
public void Accept(ISyntaxTreeVisitor visitor) { visitor.VisitSyntaxTree(this); }
public void AcceptSyntaxTreeVisitor(ISyntaxTreeVisitor visitor) { visitor.VisitStatement(this); }
public StatementChildrenVisitor(ISyntaxTreeVisitor visitor, ISyntaxTreeVisitor childrenVisitor) { _visitor = visitor; _childrenVisitor = childrenVisitor; }
public void AcceptSyntaxTreeVisitor(ISyntaxTreeVisitor visitor) { visitor.VisitSpecifier(this); }
public void AcceptSyntaxTreeVisitor(ISyntaxTreeVisitor visitor) { visitor.VisitStructFunctionAssociation(this); }
public void AcceptSyntaxTreeVisitor(ISyntaxTreeVisitor visitor) { visitor.VisitUnknown(this); }
public ParseTreeChildrenVisitor(ISyntaxTreeVisitor?preOrderVisitor, ISyntaxTreeVisitor?postOrderVisitor, ISyntaxTreeVisitor childVisitor) { _preOrderVisitor = preOrderVisitor; _postOrderVisitor = postOrderVisitor; _childVisitor = childVisitor; }
public void AcceptSyntaxTreeVisitor(ISyntaxTreeVisitor visitor) { visitor.VisitExpression(this); }
public void AcceptSyntaxTreeVisitor(ISyntaxTreeVisitor visitor) { visitor.VisitEnumDeclaration(this); }