Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
AstInterfaces.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections;
3 using System.Linq;
4 using System.Text;
5 
6 namespace Irony.Parsing {
7  // These are generic interfaces for AST implementors. They define some basic interface that Parser needs to
8  // construct AST tree. Note that we expect more than one interpreter/AST implementation: Irony.Interpreter.Ast
9  // namespace provides just one of them. That's why these AST interfaces are here, and not in Interpreter.Ast namespace.
10  // In the future, I plan to introduce advanced interpreter, with its own set of AST classes - it will probably live
11  // in a separate assembly Irony.Interpreter2.dll.
12 
13  // Basic interface for AST nodes; Init method is the chance for AST node to get references to its child nodes, and all
14  // related information gathered during parsing
15  // Implementing this interface is a minimum required from custom AST node class to enable its creation by Irony
16  // parser. Alternatively, if your custom AST node class does not implement this interface then you can create
17  // and initialize node instances using AstNodeCreator delegate attached to corresponding non-terminal in your grammar.
18  public interface IAstNodeInit {
19  void Init(ParsingContext context, ParseTreeNode parseNode);
20  }
21 
22  // Grammar explorer uses this interface to discover and display the AST tree after parsing the input
23  // (Grammar Explorer additionally uses ToString method of the node to get the text representation of the node)
24  public interface IBrowsableAstNode {
25  SourceLocation Location { get; }
26  IEnumerable GetChildNodes();
27  }
28 
29  //Simple visitor interface
30  public interface IAstVisitor {
31  void BeginVisit(IVisitableNode node);
32  void EndVisit(IVisitableNode node);
33  }
34 
35  public interface IVisitableNode {
36  void AcceptVisitor(IAstVisitor visitor);
37  }
38 
39 
40 }