Code coverage report for sc/lang/compiler/parser/program.js

Statements: 100% (14 / 14)      Branches: 100% (4 / 4)      Functions: 100% (4 / 4)      Lines: 100% (14 / 14)      Ignored: none     

All files » sc/lang/compiler/parser/ » program.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301     1   1 1 1   1 89   89 89         89 1     89     1 89      
(function(sc) {
  "use strict";
 
  require("./parser");
 
  var Syntax = sc.lang.compiler.Syntax;
  var Node = sc.lang.compiler.Node;
  var Parser = sc.lang.compiler.Parser;
 
  Parser.addParseMethod("Program", function() {
    var marker = this.createMarker();
 
    var node = this.withScope(function() {
      return Node.createProgram(
        this.parseFunctionBody()
      );
    });
 
    if (hasSingleBlockExpression(node)) {
      node.body = node.body[0].body;
    }
 
    return marker.update().apply(node);
  });
 
  function hasSingleBlockExpression(node) {
    return node.body.length === 1 && node.body[0].type === Syntax.BlockExpression;
  }
})(sc);