private def simpleTerm()

in rsc/src/main/scala/rsc/parse/scala/Terms.scala [243:325]


  private def simpleTerm(): Term = {
    val start = in.offset
    var canApply = true
    val unfinished = in.token match {
      case ID | THIS | SUPER =>
        canApply = true
        termPath()
      case USCORE =>
        canApply = true
        termWildcard()
      case LPAREN =>
        canApply = true
        val terms = termArgs()
        terms match {
          case Nil => atPos(start)(TermLit(()))
          case term :: Nil => term
          case terms => atPos(start)(TermTuple(terms))
        }
      case LBRACE =>
        canApply = false
        blockBraces(start)
      case NEW =>
        canApply = false
        in.nextToken()
        newTemplate() match {
          case Template(Nil, List(init), None, None) =>
            TermNew(init)
          case Template(earlies, inits, selfDecl, stats) =>
            TermNewAnonymous(earlies, inits, selfDecl, stats)
        }
      case INTID =>
        canApply = true
        val value = in.idValue
        in.nextToken()
        val id = atPos(start)(TermId(value))
        accept(INTSTART)
        val parts = List.newBuilder[TermLit]
        val args = List.newBuilder[Term]
        var expected = INTPART
        while (in.token != INTEND) {
          if (expected == INTPART) {
            val start = in.offset
            val value = in.value.asInstanceOf[String]
            accept(INTPART)
            parts += atPos(start)(TermLit(value))
            expected = INTSPLICE
          } else if (expected == INTSPLICE) {
            accept(INTSPLICE)
            in.token match {
              case LBRACE =>
                inBraces {
                  args += term()
                }
              case THIS =>
                accept(THIS)
                args += TermThis(anonId())
              case _ => args += termId()
            }
            expected = INTPART
          } else {
            crash(expected)
          }
        }
        accept(INTEND)
        atPos(start)(TermInterpolate(id, parts.result(), args.result()))
      case XML =>
        // FIXME: https://github.com/twitter/rsc/issues/81
        val raw = in.value
        in.nextToken()
        atPos(start)(TermXml(raw))
      case _ =>
        if (in.token.isLit) {
          canApply = true
          TermLit(literal())
        } else {
          canApply = true
          val errOffset = in.offset
          reportOffset(errOffset, IllegalStartOfSimpleTerm)
          atPos(errOffset)(errorTerm())
        }
    }
    simpleTermRest(start, unfinished, canApply = canApply)
  }