public FunctionDeclarationStatementNode(LexicalScope scope, string name, ParameterNode[] parameters, ElementNode[] body, SourceSpan sourceSpan)
     : base(sourceSpan)
 {
     this.scope = scope;
     this.name = name;
     this.parameters = parameters;
     this.body = body;
 }
Beispiel #2
0
 public BlockNode(LexicalScope scope, ElementNode[] elements, SourceSpan span)
     : base(span)
 {
     this.scope = scope;
     this.elements = elements;
 }
Beispiel #3
0
        public SourceUnitTree BuildSourceTree(ParseTreeNode rootNode, SourceUnit sourceUnit, bool allowSingle, out bool isExpression)
        {
            ElementNode[] elements;
            if (allowSingle && rootNode.Term.Name != "Prog")
            {
                // Single statement, not a "valid production", example "6+2" or simply a identifier "b"

                elements =  new ElementNode[] { new FlowControlStatementNode(FlowControlOperations.Return, BuildExpression(rootNode), SourceSpan.None) };
                isExpression = true;
                return new SourceUnitTree(Scope.Build(), elements, SourceSpan.None);
            }

            elements = rootNode.ChildNodes[0].ChildNodes.Select(n => BuildElement(n)).ToArray();
            isExpression = false;
            return new SourceUnitTree(Scope.Build(), elements, Span(rootNode));
        }
Beispiel #4
0
 public SourceUnitTree(LexicalScope scope, ElementNode[] elementNodes, SourceSpan sourceSpan)
     : base(sourceSpan)
 {
     this.elementNodes = elementNodes;
     this.scope = scope;
 }