Class TokenStream


  • public class TokenStream
    extends java.lang.Object
    This class implements the JavaScript scanner.

    It is based on the C source files jsscan.c and jsscan.h in the jsref package.

    IMPORTANT: As of 2018-03-09 it is still not possible to use Java 8 features in this file due to limitations on some internal Google projects that depend on it.

    • Constructor Summary

      Constructors 
      Constructor Description
      TokenStream()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isJSIdentifier​(java.lang.String s)  
      static boolean isKeyword​(java.lang.String name)
      Is the string an ES3 keyword?
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TokenStream

        public TokenStream()
    • Method Detail

      • isKeyword

        public static boolean isKeyword​(java.lang.String name)
        Is the string an ES3 keyword?

        Keywords for versions of JavaScript after ES3 are not included, because the parser would reject valid ES3 code that happened to newer keywords if we did that.

        Since isKeyword() is used repeatedly in scanning, for performance reasons, it is implemented to do the minimum number of character comparisons to ascertain whether the given name is a keyword, instead of doing string search of the name against JS keywords.

      • isJSIdentifier

        public static boolean isJSIdentifier​(java.lang.String s)