Code coverage report for sc/lang/compiler/parser/primary-expr.js

Statements: 100% (23 / 23)      Branches: 100% (18 / 18)      Functions: 100% (3 / 3)      Lines: 100% (23 / 23)      Ignored: none     

All files » sc/lang/compiler/parser/ » primary-expr.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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 711     1   1 1                             1 762 17 17 10 9 2 8     699 2 251 4     442                           1 470 6     464               454     10      
(function(sc) {
  "use strict";
 
  require("./parser");
 
  var Token = sc.lang.compiler.Token;
  var Parser = sc.lang.compiler.Parser;
 
  /*
    PrimaryExpression :
      ( ... )
      { ... }
      ListExpression
      HashedExpression
      RefExpression
      EnvironmentExpression
      ThisExpression
      PrimaryIdentifier
      StringExpression
      PrimaryArgExpression
  */
  Parser.addParseMethod("PrimaryExpression", function() {
    switch (this.matchAny([ "(", "{", "[", "#", "`", "~" ])) {
    case "(": return this.parseParentheses();
    case "{": return this.parseBraces();
    case "[": return this.parseListExpression();
    case "#": return this.parseHashedExpression();
    case "`": return this.parseRefExpression();
    case "~": return this.parseEnvironmentExpression();
    }
 
    switch (this.lookahead.type) {
    case Token.Keyword:       return this.parseThisExpression();
    case Token.Identifier:    return this.parsePrimaryIdentifier();
    case Token.StringLiteral: return this.parseStringExpression();
    }
 
    return this.parsePrimaryArgExpression();
  });
 
  /*
    PrimaryArgExpression :
      ImmutableListExpression
      NilLiteral
      TrueLiteral
      FalseLiteral
      IntegerLiteral
      FloatLiteral
      SymbolLiteral
      CharLiteral
  */
  Parser.addParseMethod("PrimaryArgExpression", function() {
    if (this.match("#")) {
      return this.parseImmutableListExpression();
    }
 
    switch (this.lookahead.type) {
    case Token.NilLiteral:
    case Token.TrueLiteral:
    case Token.FalseLiteral:
    case Token.IntegerLiteral:
    case Token.FloatLiteral:
    case Token.SymbolLiteral:
    case Token.CharLiteral:
      return this.parseLiteral();
    }
 
    return this.throwUnexpected(this.lex());
  });
})(sc);