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

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

All files » sc/lang/compiler/parser/ » expression.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 30 31 32 33 34 35 36 37 38 39 401     1   1           1 493               1 297   297 327     325 42       295 8     287      
(function(sc) {
  "use strict";
 
  require("./parser");
 
  var Parser = sc.lang.compiler.Parser;
 
  /*
    Expression :
      AssignmentExpression
  */
  Parser.addParseMethod("Expression", function() {
    return this.parseAssignmentExpression();
  });
 
  /*
    Expressions :
      Expression
      Expressions ; Expression
  */
  Parser.addParseMethod("Expressions", function() {
    var nodes = [];
 
    while (this.hasNextToken() && !this.matchAny([ ",", ")", "]", "}", ":", ".." ])) {
      nodes.push(
        this.parseExpression()
      );
      if (this.match(";")) {
        this.lex();
      }
    }
 
    if (nodes.length === 0) {
      this.throwUnexpected(this.lookahead);
    }
 
    return nodes.length === 1 ? nodes[0] : nodes;
  });
})(sc);