gitee.com/quant1x/pkg@v0.2.8/goja/token/README.markdown (about)

     1  # token
     2  --
     3  
     4      import "github.com/dop251/goja/token"
     5  
     6  Package token defines constants representing the lexical tokens of JavaScript
     7  (ECMA5).
     8  
     9  ## Usage
    10  
    11  ```go
    12  const (
    13  ILLEGAL
    14  EOF
    15  COMMENT
    16  KEYWORD
    17  
    18  STRING
    19  BOOLEAN
    20  NULL
    21  NUMBER
    22  IDENTIFIER
    23  
    24  PLUS      // +
    25  MINUS     // -
    26  MULTIPLY  // *
    27  SLASH     // /
    28  REMAINDER // %
    29  
    30  AND                  // &
    31  OR                   // |
    32  EXCLUSIVE_OR         // ^
    33  SHIFT_LEFT           // <<
    34  SHIFT_RIGHT          // >>
    35  UNSIGNED_SHIFT_RIGHT // >>>
    36  AND_NOT              // &^
    37  
    38  ADD_ASSIGN      // +=
    39  SUBTRACT_ASSIGN // -=
    40  MULTIPLY_ASSIGN // *=
    41  QUOTIENT_ASSIGN  // /=
    42  REMAINDER_ASSIGN // %=
    43  
    44  AND_ASSIGN          // &=
    45  OR_ASSIGN           // |=
    46  EXCLUSIVE_OR_ASSIGN // ^=
    47  SHIFT_LEFT_ASSIGN           // <<=
    48  SHIFT_RIGHT_ASSIGN          // >>=
    49  UNSIGNED_SHIFT_RIGHT_ASSIGN // >>>=
    50  AND_NOT_ASSIGN              // &^=
    51  
    52  LOGICAL_AND // &&
    53  LOGICAL_OR  // ||
    54  INCREMENT   // ++
    55  DECREMENT   // --
    56  
    57  EQUAL        // ==
    58  STRICT_EQUAL // ===
    59  LESS         // <
    60  GREATER      // >
    61  ASSIGN       // =
    62  NOT          // !
    63  
    64  BITWISE_NOT // ~
    65  
    66  NOT_EQUAL        // !=
    67  STRICT_NOT_EQUAL // !==
    68  LESS_OR_EQUAL    // <=
    69  GREATER_OR_EQUAL // >=
    70  
    71  LEFT_PARENTHESIS // (
    72  LEFT_BRACKET     // [
    73  LEFT_BRACE       // {
    74  COMMA            // ,
    75  PERIOD           // .
    76  
    77  RIGHT_PARENTHESIS // )
    78  RIGHT_BRACKET     // ]
    79  RIGHT_BRACE       // }
    80  SEMICOLON         // ;
    81  COLON             // :
    82  QUESTION_MARK     // ?
    83  
    84  IF
    85  IN
    86  DO
    87  
    88  VAR
    89  FOR
    90  NEW
    91  TRY
    92  
    93  THIS
    94  ELSE
    95  CASE
    96  VOID
    97  WITH
    98  
    99  WHILE
   100  BREAK
   101  CATCH
   102  THROW
   103  
   104  RETURN
   105  TYPEOF
   106  DELETE
   107  SWITCH
   108  
   109  DEFAULT
   110  FINALLY
   111  
   112  FUNCTION
   113  CONTINUE
   114  DEBUGGER
   115  
   116  INSTANCEOF
   117  )
   118  ```
   119  
   120  #### type Token
   121  
   122  ```go
   123  type Token int
   124  ```
   125  
   126  Token is the set of lexical tokens in JavaScript (ECMA5).
   127  
   128  #### func  IsKeyword
   129  
   130  ```go
   131  func IsKeyword(literal string) (Token, bool)
   132  ```
   133  
   134  IsKeyword returns the keyword token if literal is a keyword, a KEYWORD token if
   135  the literal is a future keyword (const, let, class, super, ...), or 0 if the
   136  literal is not a keyword.
   137  
   138  If the literal is a keyword, IsKeyword returns a second value indicating if the
   139  literal is considered a future keyword in strict-mode only.
   140  
   141  7.6.1.2 Future Reserved Words:
   142  
   143      const
   144      class
   145      enum
   146      export
   147      extends
   148      import
   149      super
   150  
   151  7.6.1.2 Future Reserved Words (strict):
   152  
   153      implements
   154      interface
   155      let
   156      package
   157      private
   158      protected
   159      public
   160      static
   161  
   162  #### func (Token) String
   163  
   164  ```go
   165  func (tkn Token) String() string
   166  ```
   167  
   168  String returns the string corresponding to the token. For operators, delimiters,
   169  and keywords the string is the actual token string (e.g., for the token PLUS,
   170  the String() is "+"). For all other tokens the string corresponds to the token
   171  name (e.g. for the token IDENTIFIER, the string is "IDENTIFIER").
   172  
   173  --
   174  **godocdown** http://github.com/robertkrimen/godocdown