MCPcopy Create free account
hub / github.com/dynjs/dynjs / identifierOrReservedWord

Method identifierOrReservedWord

src/main/java/org/dynjs/parser/js/Lexer.java:592–630  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

590 }
591
592 protected Token identifierOrReservedWord() {
593 StringBuilder text = new StringBuilder();
594
595 if (isIdentifierStart(la())) {
596 if (isUnicodeEscapeSequence(la())) {
597 text.append(unicodeEscapeSequence());
598 } else {
599 text.append((char) consume());
600 }
601 }
602
603 while (isIdentifierPart(la())) {
604 if (isUnicodeEscapeSequence(la())) {
605 text.append(unicodeEscapeSequence());
606 } else {
607 text.append((char) consume());
608 }
609 }
610
611 if (text.length() == 0) {
612 isNonEscapeSequence(la());
613 consume();
614 consume();
615 consume();
616 consume();
617 consume();
618 consume();
619 // return null;
620 throw new SyntaxError("unicode escapes not allowed here");
621 }
622
623 String str = text.toString();
624
625 if (KEYWORDS.contains(str)) {
626 return newToken(TokenType.valueOf(str.toUpperCase()), str);
627 }
628
629 return newToken(IDENTIFIER, text.toString());
630 }
631
632 protected boolean isLineTerminator(char c) {
633 return c == '\n' || c == '\r' || c == '\u2028' || c == '\u2029';

Callers 1

nextTokenMethod · 0.95

Calls 12

isIdentifierStartMethod · 0.95
laMethod · 0.95
unicodeEscapeSequenceMethod · 0.95
consumeMethod · 0.95
isIdentifierPartMethod · 0.95
isNonEscapeSequenceMethod · 0.95
newTokenMethod · 0.95
appendMethod · 0.80
lengthMethod · 0.80
containsMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected