makePropertyName method

Node makePropertyName(
  1. Token tok
)

Implementation

Node makePropertyName(Token tok) {
  int? start = tok.startOffset;
  int end = tok.endOffset;
  int? line = tok.line;
  switch (tok.type) {
    case Token.NAME:
      return Name(tok.text!)
        ..start = start
        ..end = end
        ..line = line;
    case Token.STRING:
      return LiteralExpression(tok.value)
        ..raw = tok.text
        ..start = start
        ..end = end
        ..line = line;
    case Token.NUMBER:
      return LiteralExpression(double.parse(tok.text!))
        ..raw = tok.text
        ..start = start
        ..end = end
        ..line = line;
    default:
      throw fail(tok: tok, expected: 'property name');
  }
}