sbin/res/jslint.js
author hamidouk
Tue, 29 Nov 2011 11:09:08 +0100
branchpopcorn-port
changeset 345 8a088f7daa66
parent 97 62612c69699f
permissions -rw-r--r--
rollover over the interface buttons now works as expected. Also changed the width of the buttons to the correct size. Resized the width and height of the sprites to be the same as the boxes we display them in.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
97
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     1
// jslint.js
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     2
// 2011-10-17
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     3
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     4
// Copyright (c) 2002 Douglas Crockford  (www.JSLint.com)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     5
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     6
// Permission is hereby granted, free of charge, to any person obtaining a copy
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     7
// of this software and associated documentation files (the "Software"), to deal
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     8
// in the Software without restriction, including without limitation the rights
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
     9
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    10
// copies of the Software, and to permit persons to whom the Software is
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    11
// furnished to do so, subject to the following conditions:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    12
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    13
// The above copyright notice and this permission notice shall be included in
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    14
// all copies or substantial portions of the Software.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    15
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    16
// The Software shall be used for Good, not Evil.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    17
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    24
// SOFTWARE.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    25
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    26
// WARNING: JSLint will hurt your feelings.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    27
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    28
// JSLINT is a global function. It takes two parameters.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    29
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    30
//     var myResult = JSLINT(source, option);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    31
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    32
// The first parameter is either a string or an array of strings. If it is a
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    33
// string, it will be split on '\n' or '\r'. If it is an array of strings, it
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    34
// is assumed that each string represents one line. The source can be a
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    35
// JavaScript text, or HTML text, or a JSON text, or a CSS text.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    36
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    37
// The second parameter is an optional object of options that control the
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    38
// operation of JSLINT. Most of the options are booleans: They are all
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    39
// optional and have a default value of false. One of the options, predef,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    40
// can be an array of names, which will be used to declare global variables,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    41
// or an object whose keys are used as global names, with a boolean value
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    42
// that determines if they are assignable.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    43
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    44
// If it checks out, JSLINT returns true. Otherwise, it returns false.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    45
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    46
// If false, you can inspect JSLINT.errors to find out the problems.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    47
// JSLINT.errors is an array of objects containing these properties:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    48
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    49
//  {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    50
//      line      : The line (relative to 0) at which the lint was found
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    51
//      character : The character (relative to 0) at which the lint was found
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    52
//      reason    : The problem
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    53
//      evidence  : The text line in which the problem occurred
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    54
//      raw       : The raw message before the details were inserted
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    55
//      a         : The first detail
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    56
//      b         : The second detail
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    57
//      c         : The third detail
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    58
//      d         : The fourth detail
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    59
//  }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    60
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    61
// If a stopping error was found, a null will be the last element of the
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    62
// JSLINT.errors array. A stopping error means that JSLint was not confident
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    63
// enough to continue. It does not necessarily mean that the error was
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    64
// especially heinous.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    65
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    66
// You can request a Function Report, which shows all of the functions
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    67
// and the parameters and vars that they use. This can be used to find
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    68
// implied global variables and other problems. The report is in HTML and
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    69
// can be inserted in an HTML <body>.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    70
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    71
//     var myReport = JSLINT.report(errors_only);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    72
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    73
// If errors_only is true, then the report will be limited to only errors.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    74
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    75
// You can request a data structure that contains JSLint's results.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    76
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    77
//     var myData = JSLINT.data();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    78
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    79
// It returns a structure with this form:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    80
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    81
//     {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    82
//         errors: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    83
//             {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    84
//                 line: NUMBER,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    85
//                 character: NUMBER,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    86
//                 reason: STRING,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    87
//                 evidence: STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    88
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    89
//         ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    90
//         functions: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    91
//             {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    92
//                 name: STRING,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    93
//                 line: NUMBER,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    94
//                 last: NUMBER,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    95
//                 params: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    96
//                     {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    97
//                         string: STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    98
//                     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
    99
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   100
//                 closure: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   101
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   102
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   103
//                 var: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   104
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   105
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   106
//                 exception: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   107
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   108
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   109
//                 outer: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   110
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   111
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   112
//                 unused: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   113
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   114
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   115
//                 undef: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   116
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   117
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   118
//                 global: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   119
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   120
//                 ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   121
//                 label: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   122
//                     STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   123
//                 ]
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   124
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   125
//         ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   126
//         globals: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   127
//             STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   128
//         ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   129
//         member: {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   130
//             STRING: NUMBER
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   131
//         },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   132
//         urls: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   133
//             STRING
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   134
//         ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   135
//         json: BOOLEAN
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   136
//     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   137
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   138
// Empty arrays will not be included.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   139
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   140
// You can obtain the parse tree that JSLint constructed while parsing. The
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   141
// latest tree is kept in JSLINT.tree. A nice stringication can be produced
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   142
// with
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   143
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   144
//     JSON.stringify(JSLINT.tree, [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   145
//         'string',  'arity', 'name',  'first',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   146
//         'second', 'third', 'block', 'else'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   147
//     ], 4));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   148
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   149
// JSLint provides three directives. They look like slashstar comments, and
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   150
// allow for setting options, declaring global variables, and establishing a
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   151
// set of allowed property names.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   152
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   153
// These directives respect function scope.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   154
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   155
// The jslint directive is a special comment that can set one or more options.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   156
// The current option set is
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   157
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   158
//     adsafe     true, if ADsafe rules should be enforced
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   159
//     bitwise    true, if bitwise operators should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   160
//     browser    true, if the standard browser globals should be predefined
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   161
//     cap        true, if upper case HTML should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   162
//     confusion  true, if types can be used inconsistently
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   163
//     'continue' true, if the continuation statement should be tolerated
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   164
//     css        true, if CSS workarounds should be tolerated
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   165
//     debug      true, if debugger statements should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   166
//     devel      true, if logging should be allowed (console, alert, etc.)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   167
//     eqeq       true, if == should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   168
//     es5        true, if ES5 syntax should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   169
//     evil       true, if eval should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   170
//     forin      true, if for in statements need not filter
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   171
//     fragment   true, if HTML fragments should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   172
//     indent     the indentation factor
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   173
//     maxerr     the maximum number of errors to allow
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   174
//     maxlen     the maximum length of a source line
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   175
//     newcap     true, if constructor names capitalization is ignored
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   176
//     node       true, if Node.js globals should be predefined
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   177
//     nomen      true, if names may have dangling _
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   178
//     on         true, if HTML event handlers should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   179
//     passfail   true, if the scan should stop on first error
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   180
//     plusplus   true, if increment/decrement should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   181
//     properties true, if all property names must be declared with /*properties*/
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   182
//     regexp     true, if the . should be allowed in regexp literals
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   183
//     rhino      true, if the Rhino environment globals should be predefined
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   184
//     undef      true, if variables can be declared out of order
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   185
//     unparam    true, if unused parameters should be tolerated
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   186
//     safe       true, if use of some browser features should be restricted
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   187
//     sloppy     true, if the 'use strict'; pragma is optional
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   188
//     sub        true, if all forms of subscript notation are tolerated
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   189
//     vars       true, if multiple var statements per function should be allowed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   190
//     white      true, if sloppy whitespace is tolerated
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   191
//     widget     true  if the Yahoo Widgets globals should be predefined
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   192
//     windows    true, if MS Windows-specific globals should be predefined
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   193
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   194
// For example:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   195
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   196
/*jslint
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   197
    evil: true, nomen: true, regexp: true
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   198
*/
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   199
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   200
// The properties directive declares an exclusive list of property names.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   201
// Any properties named in the program that are not in the list will
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   202
// produce a warning.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   203
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   204
// For example:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   205
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   206
/*properties
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   207
    '\b': string, '\t': string, '\n': string, '\f': string, '\r': string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   208
    '!=': boolean, '!==': boolean, '"': string, '%': boolean, '\'': string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   209
    '(begin)', '(breakage)': number, '(complexity)', '(confusion)': boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   210
    '(context)': object, '(error)', '(identifier)', '(line)': number,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   211
    '(loopage)': number, '(name)', '(old_property_type)', '(params)',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   212
    '(scope)': object, '(token)', '(vars)', '(verb)', '*': boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   213
    '+': boolean, '-': boolean, '/': *, '<': boolean, '<=': boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   214
    '==': boolean, '===': boolean, '>': boolean, '>=': boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   215
    ADSAFE: boolean, Array, Date, E: string, Function, LN10: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   216
    LN2: string, LOG10E: string, LOG2E: string, MAX_VALUE: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   217
    MIN_VALUE: string, NEGATIVE_INFINITY: string, Object, PI: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   218
    POSITIVE_INFINITY: string, SQRT1_2: string, SQRT2: string, '\\': string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   219
    a: object, a_label: string, a_not_allowed: string, a_not_defined: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   220
    a_scope: string, abbr: object, acronym: object, address: object, adsafe,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   221
    adsafe_a: string, adsafe_autocomplete: string, adsafe_bad_id: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   222
    adsafe_div: string, adsafe_fragment: string, adsafe_go: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   223
    adsafe_html: string, adsafe_id: string, adsafe_id_go: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   224
    adsafe_lib: string, adsafe_lib_second: string, adsafe_missing_id: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   225
    adsafe_name_a: string, adsafe_placement: string, adsafe_prefix_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   226
    adsafe_script: string, adsafe_source: string, adsafe_subscript_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   227
    adsafe_tag: string, all: boolean, already_defined: string, and: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   228
    applet: object, apply: string, approved: array, area: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   229
    arity: string, article: object, aside: object, assign: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   230
    assign_exception: string, assignment_function_expression: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   231
    at: number, attribute_case_a: string, audio: object, autocomplete: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   232
    avoid_a: string, b: *, background: array, 'background-attachment': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   233
    'background-color': array, 'background-image': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   234
    'background-position': array, 'background-repeat': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   235
    bad_assignment: string, bad_color_a: string, bad_constructor: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   236
    bad_entity: string, bad_html: string, bad_id_a: string, bad_in_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   237
    bad_invocation: string, bad_name_a: string, bad_new: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   238
    bad_number: string, bad_operand: string, bad_style: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   239
    bad_type: string, bad_url_a: string, bad_wrap: string, base: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   240
    bdo: object, big: object, bind: string, bitwise: boolean, block: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   241
    blockquote: object, body: object, border: array, 'border-bottom': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   242
    'border-bottom-color', 'border-bottom-left-radius',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   243
    'border-bottom-right-radius', 'border-bottom-style': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   244
    'border-bottom-width', 'border-collapse': array, 'border-color': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   245
    'border-left': array, 'border-left-color', 'border-left-style': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   246
    'border-left-width', 'border-radius', 'border-right': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   247
    'border-right-color', 'border-right-style': array, 'border-right-width',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   248
    'border-spacing': array, 'border-style': array, 'border-top': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   249
    'border-top-color', 'border-top-left-radius', 'border-top-right-radius',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   250
    'border-top-style': array, 'border-top-width', 'border-width': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   251
    bottom: array, br: object, braille: boolean, browser: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   252
    button: object, c, call: string, canvas: object, cap, caption: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   253
    'caption-side': array, ceil: string, center: object, charAt: *,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   254
    charCodeAt: *, character, cite: object, clear: array, clip: array, closure,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   255
    cm: boolean, code: object, col: object, colgroup: object, color,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   256
    combine_var: string, command: object, concat: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   257
    conditional_assignment: string, confusing_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   258
    confusing_regexp: string, confusion: boolean, constructor: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   259
    constructor_name_a: string, content: array, continue, control_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   260
    'counter-increment': array, 'counter-reset': array, create: *, css: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   261
    cursor: array, d, dangerous_comment: string, dangling_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   262
    data: function object, datalist: object, dd: object, debug,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   263
    defineProperties: string, defineProperty: string, del: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   264
    deleted: string, details: object, devel: boolean, dfn: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   265
    dialog: object, dir: object, direction: array, display: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   266
    disrupt: boolean, div: object, dl: object, dt: object, duplicate_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   267
    edge: string, edition: string, else, em: *, embed: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   268
    embossed: boolean, empty: boolean, 'empty-cells': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   269
    empty_block: string, empty_case: string, empty_class: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   270
    entityify: function, eqeq, errors: array, es5: string, eval, every: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   271
    evidence, evil: string, ex: boolean, exception, exec: *,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   272
    expected_a: string, expected_a_at_b_c: string, expected_a_b: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   273
    expected_a_b_from_c_d: string, expected_at_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   274
    expected_attribute_a: string, expected_attribute_value_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   275
    expected_class_a: string, expected_fraction_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   276
    expected_id_a: string, expected_identifier_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   277
    expected_identifier_a_reserved: string, expected_lang_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   278
    expected_linear_a: string, expected_media_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   279
    expected_name_a: string, expected_nonstandard_style_attribute: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   280
    expected_number_a: string, expected_operator_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   281
    expected_percent_a: string, expected_positive_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   282
    expected_pseudo_a: string, expected_selector_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   283
    expected_small_a: string, expected_space_a_b: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   284
    expected_string_a: string, expected_style_attribute: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   285
    expected_style_pattern: string, expected_tagname_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   286
    expected_type_a: string, f: string, fieldset: object, figure: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   287
    filter: *, first: *, flag, float: array, floor: *, font: *, 'font-family',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   288
    'font-size': array, 'font-size-adjust': array, 'font-stretch': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   289
    'font-style': array, 'font-variant': array, 'font-weight': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   290
    footer: object, for, forEach: *, for_if: string, forin, form: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   291
    fragment, frame: object, frameset: object, freeze: string, from: number,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   292
    fromCharCode: function, fud: function, funct: object, function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   293
    function_block: string, function_eval: string, function_loop: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   294
    function_statement: string, function_strict: string, functions: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   295
    getDate: string, getDay: string, getFullYear: string, getHours: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   296
    getMilliseconds: string, getMinutes: string, getMonth: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   297
    getOwnPropertyDescriptor: string, getOwnPropertyNames: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   298
    getPrototypeOf: string, getSeconds: string, getTime: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   299
    getTimezoneOffset: string, getUTCDate: string, getUTCDay: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   300
    getUTCFullYear: string, getUTCHours: string, getUTCMilliseconds: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   301
    getUTCMinutes: string, getUTCMonth: string, getUTCSeconds: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   302
    getYear: string, global, globals, h1: object, h2: object, h3: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   303
    h4: object, h5: object, h6: object, handheld: boolean, hasOwnProperty: *,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   304
    head: object, header: object, height: array, hgroup: object, hr: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   305
    'hta:application': object, html: *, html_confusion_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   306
    html_handlers: string, i: object, id: string, identifier: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   307
    identifier_function: string, iframe: object, img: object, immed: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   308
    implied_evil: string, in, indent: number, indexOf: *, infix_in: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   309
    init: function, input: object, ins: object, insecure_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   310
    isAlpha: function, isArray: function boolean, isDigit: function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   311
    isExtensible: string, isFrozen: string, isNaN: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   312
    isPrototypeOf: string, isSealed: string, join: *, jslint: function boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   313
    json: boolean, kbd: object, keygen: object, keys: *, label: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   314
    label_a_b: string, labeled: boolean, lang: string, lastIndex: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   315
    lastIndexOf: *, lbp: number, leading_decimal_a: string, led: function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   316
    left: array, legend: object, length: *, 'letter-spacing': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   317
    li: object, lib: boolean, line: number, 'line-height': array, link: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   318
    'list-style': array, 'list-style-image': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   319
    'list-style-position': array, 'list-style-type': array, map: *,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   320
    margin: array, 'margin-bottom', 'margin-left', 'margin-right',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   321
    'margin-top', mark: object, 'marker-offset': array, match: function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   322
    'max-height': array, 'max-width': array, maxerr: number,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   323
    maxlen: number, member: object, menu: object, message, meta: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   324
    meter: object, 'min-height': function, 'min-width': function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   325
    missing_a: string, missing_a_after_b: string, missing_option: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   326
    missing_property: string, missing_space_a_b: string, missing_url: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   327
    missing_use_strict: string, mixed: string, mm: boolean, mode: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   328
    move_invocation: string, move_var: string, n: string, name: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   329
    name_function: string, nav: object, nested_comment: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   330
    newcap: boolean, node: boolean, noframes: object, nomen, noscript: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   331
    not: string, not_a_constructor: string, not_a_defined: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   332
    not_a_function: string, not_a_label: string, not_a_scope: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   333
    not_greater: string, now: string, nud: function, number: number,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   334
    object: object, ol: object, on, opacity, open: boolean, optgroup: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   335
    option: object, outer: regexp, outline: array, 'outline-color': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   336
    'outline-style': array, 'outline-width', output: object, overflow: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   337
    'overflow-x': array, 'overflow-y': array, p: object, padding: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   338
    'padding-bottom': function, 'padding-left': function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   339
    'padding-right': function, 'padding-top': function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   340
    'page-break-after': array, 'page-break-before': array, param: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   341
    parameter_a_get_b: string, parameter_set_a: string, params: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   342
    paren: boolean, parent: string, parse: string, passfail, pc: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   343
    plusplus, pop: *, position: array, postscript: boolean, pre: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   344
    predef, preventExtensions: string, print: boolean, progress: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   345
    projection: boolean, properties: boolean, propertyIsEnumerable: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   346
    prototype: string, pt: boolean, push: *, px: boolean, q: object, quote,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   347
    quotes: array, r: string, radix: string, range: function, raw,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   348
    read_only: string, reason, redefinition_a: string, reduce: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   349
    reduceRight: string, regexp, replace: function, report: function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   350
    reserved: boolean, reserved_a: string, reverse: string, rhino: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   351
    right: array, rp: object, rt: object, ruby: object, safe: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   352
    samp: object, scanned_a_b: string, screen: boolean, script: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   353
    seal: string, search: function, second: *, section: object, select: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   354
    setDate: string, setDay: string, setFullYear: string, setHours: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   355
    setMilliseconds: string, setMinutes: string, setMonth: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   356
    setSeconds: string, setTime: string, setTimezoneOffset: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   357
    setUTCDate: string, setUTCDay: string, setUTCFullYear: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   358
    setUTCHours: string, setUTCMilliseconds: string, setUTCMinutes: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   359
    setUTCMonth: string, setUTCSeconds: string, setYear: string, shift: *,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   360
    slash_equal: string, slice: string, sloppy, small: object, some: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   361
    sort: *, source: object, span: object, speech: boolean, splice: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   362
    split: function, src, statement_block: string, stopping: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   363
    strange_loop: string, strict: string, string: string, stringify: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   364
    strong: object, style: *, styleproperty: regexp, sub: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   365
    subscript: string, substr: *, substring: string, sup: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   366
    supplant: function, t: string, table: object, 'table-layout': array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   367
    tag_a_in_b: string, tbody: object, td: object, test: *,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   368
    'text-align': array, 'text-decoration': array, 'text-indent': function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   369
    'text-shadow': array, 'text-transform': array, textarea: object,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   370
    tfoot: object, th: object, thead: object, third: array, thru: number,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   371
    time: object, title: object, toDateString: string, toExponential: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   372
    toFixed: string, toISOString: string, toJSON: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   373
    toLocaleDateString: string, toLocaleLowerCase: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   374
    toLocaleString: string, toLocaleTimeString: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   375
    toLocaleUpperCase: string, toLowerCase: *, toPrecision: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   376
    toString: function, toTimeString: string, toUTCString: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   377
    toUpperCase: *, token: function, too_long: string, too_many: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   378
    top: array, tr: object, trailing_decimal_a: string, tree: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   379
    trim: string, tt: object, tty: boolean, tv: boolean, type: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   380
    type_confusion_a_b: string, u: object, ul: object, unclosed: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   381
    unclosed_comment: string, unclosed_regexp: string, undef: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   382
    undefined, unescaped_a: string, unexpected_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   383
    unexpected_char_a_b: string, unexpected_comment: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   384
    unexpected_property_a: string, unexpected_space_a_b: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   385
    'unicode-bidi': array, unnecessary_initialize: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   386
    unnecessary_use: string, unparam, unreachable_a_b: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   387
    unrecognized_style_attribute_a: string, unrecognized_tag_a: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   388
    unsafe: string, unshift: string, unused: array, url: string, urls: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   389
    use_array: string, use_braces: string, use_charAt: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   390
    use_object: string, use_or: string, use_param: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   391
    used_before_a: string, valueOf: string, var: object, var_a_not: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   392
    vars, 'vertical-align': array, video: object, visibility: array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   393
    warn: boolean, was: object, weird_assignment: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   394
    weird_condition: string, weird_new: string, weird_program: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   395
    weird_relation: string, weird_ternary: string, white: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   396
    'white-space': array, widget: boolean, width: array, windows: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   397
    'word-spacing': array, 'word-wrap': array, wrap: boolean,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   398
    wrap_immediate: string, wrap_regexp: string, write_is_wrong: string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   399
    writeable: boolean, 'z-index': array
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   400
*/
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   401
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   402
// The global directive is used to declare global variables that can
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   403
// be accessed by the program. If a declaration is true, then the variable
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   404
// is writeable. Otherwise, it is read-only.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   405
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   406
// We build the application inside a function so that we produce only a single
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   407
// global variable. That function will be invoked immediately, and its return
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   408
// value is the JSLINT function itself. That function is also an object that
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   409
// can contain data and other functions.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   410
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   411
var JSLINT = (function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   412
    'use strict';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   413
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   414
    function array_to_object(array, value) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   415
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   416
// Make an object from an array of keys and a common value.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   417
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   418
        var i, length = array.length, object = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   419
        for (i = 0; i < length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   420
            object[array[i]] = value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   421
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   422
        return object;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   423
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   424
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   425
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   426
    var adsafe_id,      // The widget's ADsafe id.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   427
        adsafe_may,     // The widget may load approved scripts.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   428
        adsafe_top,     // At the top of the widget script.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   429
        adsafe_went,    // ADSAFE.go has been called.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   430
        anonname,       // The guessed name for anonymous functions.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   431
        approved,       // ADsafe approved urls.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   432
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   433
// These are operators that should not be used with the ! operator.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   434
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   435
        bang = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   436
            '<'  : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   437
            '<=' : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   438
            '==' : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   439
            '===': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   440
            '!==': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   441
            '!=' : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   442
            '>'  : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   443
            '>=' : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   444
            '+'  : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   445
            '-'  : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   446
            '*'  : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   447
            '/'  : true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   448
            '%'  : true
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   449
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   450
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   451
// These are property names that should not be permitted in the safe subset.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   452
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   453
        banned = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   454
            'arguments', 'callee', 'caller', 'constructor', 'eval', 'prototype',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   455
            'stack', 'unwatch', 'valueOf', 'watch'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   456
        ], true),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   457
        begin,          // The root token
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   458
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   459
// browser contains a set of global names that are commonly provided by a
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   460
// web browser environment.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   461
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   462
        browser = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   463
            'clearInterval', 'clearTimeout', 'document', 'event', 'frames',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   464
            'history', 'Image', 'localStorage', 'location', 'name', 'navigator',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   465
            'Option', 'parent', 'screen', 'sessionStorage', 'setInterval',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   466
            'setTimeout', 'Storage', 'window', 'XMLHttpRequest'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   467
        ], false),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   468
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   469
// bundle contains the text messages.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   470
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   471
        bundle = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   472
            a_label: "'{a}' is a statement label.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   473
            a_not_allowed: "'{a}' is not allowed.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   474
            a_not_defined: "'{a}' is not defined.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   475
            a_scope: "'{a}' used out of scope.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   476
            adsafe_a: "ADsafe violation: '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   477
            adsafe_autocomplete: "ADsafe autocomplete violation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   478
            adsafe_bad_id: "ADSAFE violation: bad id.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   479
            adsafe_div: "ADsafe violation: Wrap the widget in a div.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   480
            adsafe_fragment: "ADSAFE: Use the fragment option.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   481
            adsafe_go: "ADsafe violation: Misformed ADSAFE.go.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   482
            adsafe_html: "Currently, ADsafe does not operate on whole HTML " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   483
                "documents. It operates on <div> fragments and .js files.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   484
            adsafe_id: "ADsafe violation: id does not match.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   485
            adsafe_id_go: "ADsafe violation: Missing ADSAFE.id or ADSAFE.go.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   486
            adsafe_lib: "ADsafe lib violation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   487
            adsafe_lib_second: "ADsafe: The second argument to lib must be a function.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   488
            adsafe_missing_id: "ADSAFE violation: missing ID_.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   489
            adsafe_name_a: "ADsafe name violation: '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   490
            adsafe_placement: "ADsafe script placement violation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   491
            adsafe_prefix_a: "ADsafe violation: An id must have a '{a}' prefix",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   492
            adsafe_script: "ADsafe script violation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   493
            adsafe_source: "ADsafe unapproved script source.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   494
            adsafe_subscript_a: "ADsafe subscript '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   495
            adsafe_tag: "ADsafe violation: Disallowed tag '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   496
            already_defined: "'{a}' is already defined.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   497
            and: "The '&&' subexpression should be wrapped in parens.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   498
            assign_exception: "Do not assign to the exception parameter.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   499
            assignment_function_expression: "Expected an assignment or " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   500
                "function call and instead saw an expression.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   501
            attribute_case_a: "Attribute '{a}' not all lower case.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   502
            avoid_a: "Avoid '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   503
            bad_assignment: "Bad assignment.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   504
            bad_color_a: "Bad hex color '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   505
            bad_constructor: "Bad constructor.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   506
            bad_entity: "Bad entity.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   507
            bad_html: "Bad HTML string",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   508
            bad_id_a: "Bad id: '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   509
            bad_in_a: "Bad for in variable '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   510
            bad_invocation: "Bad invocation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   511
            bad_name_a: "Bad name: '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   512
            bad_new: "Do not use 'new' for side effects.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   513
            bad_number: "Bad number '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   514
            bad_operand: "Bad operand.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   515
            bad_style: "Bad style.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   516
            bad_type: "Bad type.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   517
            bad_url_a: "Bad url '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   518
            bad_wrap: "Do not wrap function literals in parens unless they " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   519
                "are to be immediately invoked.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   520
            combine_var: "Combine this with the previous 'var' statement.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   521
            conditional_assignment: "Expected a conditional expression and " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   522
                "instead saw an assignment.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   523
            confusing_a: "Confusing use of '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   524
            confusing_regexp: "Confusing regular expression.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   525
            constructor_name_a: "A constructor name '{a}' should start with " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   526
                "an uppercase letter.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   527
            control_a: "Unexpected control character '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   528
            css: "A css file should begin with @charset 'UTF-8';",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   529
            dangling_a: "Unexpected dangling '_' in '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   530
            dangerous_comment: "Dangerous comment.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   531
            deleted: "Only properties should be deleted.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   532
            duplicate_a: "Duplicate '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   533
            empty_block: "Empty block.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   534
            empty_case: "Empty case.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   535
            empty_class: "Empty class.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   536
            es5: "This is an ES5 feature.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   537
            evil: "eval is evil.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   538
            expected_a: "Expected '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   539
            expected_a_b: "Expected '{a}' and instead saw '{b}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   540
            expected_a_b_from_c_d: "Expected '{a}' to match '{b}' from line " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   541
                "{c} and instead saw '{d}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   542
            expected_at_a: "Expected an at-rule, and instead saw @{a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   543
            expected_a_at_b_c: "Expected '{a}' at column {b}, not column {c}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   544
            expected_attribute_a: "Expected an attribute, and instead saw [{a}].",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   545
            expected_attribute_value_a: "Expected an attribute value and " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   546
                "instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   547
            expected_class_a: "Expected a class, and instead saw .{a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   548
            expected_fraction_a: "Expected a number between 0 and 1 and " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   549
                "instead saw '{a}'",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   550
            expected_id_a: "Expected an id, and instead saw #{a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   551
            expected_identifier_a: "Expected an identifier and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   552
            expected_identifier_a_reserved: "Expected an identifier and " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   553
                "instead saw '{a}' (a reserved word).",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   554
            expected_linear_a: "Expected a linear unit and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   555
            expected_lang_a: "Expected a lang code, and instead saw :{a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   556
            expected_media_a: "Expected a CSS media type, and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   557
            expected_name_a: "Expected a name and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   558
            expected_nonstandard_style_attribute: "Expected a non-standard " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   559
                "style attribute and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   560
            expected_number_a: "Expected a number and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   561
            expected_operator_a: "Expected an operator and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   562
            expected_percent_a: "Expected a percentage and instead saw '{a}'",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   563
            expected_positive_a: "Expected a positive number and instead saw '{a}'",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   564
            expected_pseudo_a: "Expected a pseudo, and instead saw :{a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   565
            expected_selector_a: "Expected a CSS selector, and instead saw {a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   566
            expected_small_a: "Expected a small positive integer and instead saw '{a}'",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   567
            expected_space_a_b: "Expected exactly one space between '{a}' and '{b}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   568
            expected_string_a: "Expected a string and instead saw {a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   569
            expected_style_attribute: "Excepted a style attribute, and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   570
            expected_style_pattern: "Expected a style pattern, and instead saw '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   571
            expected_tagname_a: "Expected a tagName, and instead saw {a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   572
            expected_type_a: "Expected a type, and instead saw {a}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   573
            for_if: "The body of a for in should be wrapped in an if " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   574
                "statement to filter unwanted properties from the prototype.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   575
            function_block: "Function statements should not be placed in blocks. " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   576
                "Use a function expression or move the statement to the top of " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   577
                "the outer function.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   578
            function_eval: "The Function constructor is eval.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   579
            function_loop: "Don't make functions within a loop.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   580
            function_statement: "Function statements are not invocable. " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   581
                "Wrap the whole function invocation in parens.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   582
            function_strict: "Use the function form of 'use strict'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   583
            html_confusion_a: "HTML confusion in regular expression '<{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   584
            html_handlers: "Avoid HTML event handlers.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   585
            identifier_function: "Expected an identifier in an assignment " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   586
                "and instead saw a function invocation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   587
            implied_evil: "Implied eval is evil. Pass a function instead of a string.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   588
            infix_in: "Unexpected 'in'. Compare with undefined, or use the " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   589
                "hasOwnProperty method instead.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   590
            insecure_a: "Insecure '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   591
            isNaN: "Use the isNaN function to compare with NaN.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   592
            label_a_b: "Label '{a}' on '{b}' statement.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   593
            lang: "lang is deprecated.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   594
            leading_decimal_a: "A leading decimal point can be confused with a dot: '.{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   595
            missing_a: "Missing '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   596
            missing_a_after_b: "Missing '{a}' after '{b}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   597
            missing_option: "Missing option value.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   598
            missing_property: "Missing property name.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   599
            missing_space_a_b: "Missing space between '{a}' and '{b}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   600
            missing_url: "Missing url.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   601
            missing_use_strict: "Missing 'use strict' statement.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   602
            mixed: "Mixed spaces and tabs.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   603
            move_invocation: "Move the invocation into the parens that " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   604
                "contain the function.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   605
            move_var: "Move 'var' declarations to the top of the function.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   606
            name_function: "Missing name in function statement.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   607
            nested_comment: "Nested comment.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   608
            not: "Nested not.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   609
            not_a_constructor: "Do not use {a} as a constructor.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   610
            not_a_defined: "'{a}' has not been fully defined yet.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   611
            not_a_function: "'{a}' is not a function.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   612
            not_a_label: "'{a}' is not a label.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   613
            not_a_scope: "'{a}' is out of scope.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   614
            not_greater: "'{a}' should not be greater than '{b}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   615
            parameter_a_get_b: "Unexpected parameter '{a}' in get {b} function.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   616
            parameter_set_a: "Expected parameter (value) in set {a} function.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   617
            radix: "Missing radix parameter.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   618
            read_only: "Read only.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   619
            redefinition_a: "Redefinition of '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   620
            reserved_a: "Reserved name '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   621
            scanned_a_b: "{a} ({b}% scanned).",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   622
            slash_equal: "A regular expression literal can be confused with '/='.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   623
            statement_block: "Expected to see a statement and instead saw a block.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   624
            stopping: "Stopping. ",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   625
            strange_loop: "Strange loop.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   626
            strict: "Strict violation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   627
            subscript: "['{a}'] is better written in dot notation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   628
            tag_a_in_b: "A '<{a}>' must be within '<{b}>'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   629
            too_long: "Line too long.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   630
            too_many: "Too many errors.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   631
            trailing_decimal_a: "A trailing decimal point can be confused " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   632
                "with a dot: '.{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   633
            type: "type is unnecessary.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   634
            type_confusion_a_b: "Type confusion: {a} and {b}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   635
            unclosed: "Unclosed string.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   636
            unclosed_comment: "Unclosed comment.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   637
            unclosed_regexp: "Unclosed regular expression.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   638
            unescaped_a: "Unescaped '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   639
            unexpected_a: "Unexpected '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   640
            unexpected_char_a_b: "Unexpected character '{a}' in {b}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   641
            unexpected_comment: "Unexpected comment.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   642
            unexpected_property_a: "Unexpected /*property*/ '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   643
            unexpected_space_a_b: "Unexpected space between '{a}' and '{b}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   644
            unnecessary_initialize: "It is not necessary to initialize '{a}' " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   645
                "to 'undefined'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   646
            unnecessary_use: "Unnecessary 'use strict'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   647
            unreachable_a_b: "Unreachable '{a}' after '{b}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   648
            unrecognized_style_attribute_a: "Unrecognized style attribute '{a}'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   649
            unrecognized_tag_a: "Unrecognized tag '<{a}>'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   650
            unsafe: "Unsafe character.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   651
            url: "JavaScript URL.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   652
            use_array: "Use the array literal notation [].",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   653
            use_braces: "Spaces are hard to count. Use {{a}}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   654
            use_charAt: "Use the charAt method.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   655
            use_object: "Use the object literal notation {}.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   656
            use_or: "Use the || operator.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   657
            use_param: "Use a named parameter.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   658
            used_before_a: "'{a}' was used before it was defined.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   659
            var_a_not: "Variable {a} was not declared correctly.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   660
            weird_assignment: "Weird assignment.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   661
            weird_condition: "Weird condition.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   662
            weird_new: "Weird construction. Delete 'new'.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   663
            weird_program: "Weird program.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   664
            weird_relation: "Weird relation.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   665
            weird_ternary: "Weird ternary.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   666
            wrap_immediate: "Wrap an immediate function invocation in parentheses " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   667
                "to assist the reader in understanding that the expression " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   668
                "is the result of a function, and not the function itself.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   669
            wrap_regexp: "Wrap the /regexp/ literal in parens to " +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   670
                "disambiguate the slash operator.",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   671
            write_is_wrong: "document.write can be a form of eval."
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   672
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   673
        comments_off,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   674
        css_attribute_data,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   675
        css_any,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   676
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   677
        css_colorData = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   678
            "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   679
            "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   680
            "burlywood", "cadetblue", "chartreuse", "chocolate", "coral",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   681
            "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   682
            "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   683
            "darkmagenta", "darkolivegreen", "darkorange", "darkorchid",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   684
            "darkred", "darksalmon", "darkseagreen", "darkslateblue",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   685
            "darkslategray", "darkturquoise", "darkviolet", "deeppink",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   686
            "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   687
            "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   688
            "goldenrod", "gray", "green", "greenyellow", "honeydew", "hotpink",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   689
            "indianred", "indigo", "ivory", "khaki", "lavender",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   690
            "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   691
            "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgreen",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   692
            "lightpink", "lightsalmon", "lightseagreen", "lightskyblue",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   693
            "lightslategray", "lightsteelblue", "lightyellow", "lime",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   694
            "limegreen", "linen", "magenta", "maroon", "mediumaquamarine",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   695
            "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   696
            "mediumslateblue", "mediumspringgreen", "mediumturquoise",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   697
            "mediumvioletred", "midnightblue", "mintcream", "mistyrose",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   698
            "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   699
            "orange", "orangered", "orchid", "palegoldenrod", "palegreen",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   700
            "paleturquoise", "palevioletred", "papayawhip", "peachpuff",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   701
            "peru", "pink", "plum", "powderblue", "purple", "red", "rosybrown",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   702
            "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   703
            "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   704
            "snow", "springgreen", "steelblue", "tan", "teal", "thistle",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   705
            "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   706
            "yellow", "yellowgreen",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   707
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   708
            "activeborder", "activecaption", "appworkspace", "background",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   709
            "buttonface", "buttonhighlight", "buttonshadow", "buttontext",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   710
            "captiontext", "graytext", "highlight", "highlighttext",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   711
            "inactiveborder", "inactivecaption", "inactivecaptiontext",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   712
            "infobackground", "infotext", "menu", "menutext", "scrollbar",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   713
            "threeddarkshadow", "threedface", "threedhighlight",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   714
            "threedlightshadow", "threedshadow", "window", "windowframe",
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   715
            "windowtext"
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   716
        ], true),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   717
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   718
        css_border_style,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   719
        css_break,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   720
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   721
        css_lengthData = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   722
            '%': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   723
            'cm': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   724
            'em': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   725
            'ex': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   726
            'in': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   727
            'mm': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   728
            'pc': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   729
            'pt': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   730
            'px': true
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   731
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   732
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   733
        css_media,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   734
        css_overflow,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   735
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   736
        descapes = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   737
            'b': '\b',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   738
            't': '\t',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   739
            'n': '\n',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   740
            'f': '\f',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   741
            'r': '\r',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   742
            '"': '"',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   743
            '/': '/',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   744
            '\\': '\\'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   745
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   746
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   747
        devel = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   748
            'alert', 'confirm', 'console', 'Debug', 'opera', 'prompt', 'WSH'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   749
        ], false),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   750
        directive,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   751
        escapes = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   752
            '\b': '\\b',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   753
            '\t': '\\t',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   754
            '\n': '\\n',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   755
            '\f': '\\f',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   756
            '\r': '\\r',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   757
            '\'': '\\\'',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   758
            '"' : '\\"',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   759
            '/' : '\\/',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   760
            '\\': '\\\\'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   761
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   762
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   763
        funct,          // The current function, including the labels used in
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   764
                        // the function, as well as (breakage), (complexity),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   765
                        // (context), (loopage), (name), (params), (token),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   766
                        // (vars), (verb)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   767
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   768
        functionicity = [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   769
            'closure', 'exception', 'global', 'label', 'outer', 'undef',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   770
            'unused', 'var'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   771
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   772
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   773
        functions,      // All of the functions
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   774
        global_funct,   // The global body
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   775
        global_scope,   // The global scope
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   776
        html_tag = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   777
            a:        {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   778
            abbr:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   779
            acronym:  {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   780
            address:  {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   781
            applet:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   782
            area:     {empty: true, parent: ' map '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   783
            article:  {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   784
            aside:    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   785
            audio:    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   786
            b:        {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   787
            base:     {empty: true, parent: ' head '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   788
            bdo:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   789
            big:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   790
            blockquote: {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   791
            body:     {parent: ' html noframes '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   792
            br:       {empty: true},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   793
            button:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   794
            canvas:   {parent: ' body p div th td '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   795
            caption:  {parent: ' table '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   796
            center:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   797
            cite:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   798
            code:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   799
            col:      {empty: true, parent: ' table colgroup '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   800
            colgroup: {parent: ' table '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   801
            command:  {parent: ' menu '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   802
            datalist: {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   803
            dd:       {parent: ' dl '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   804
            del:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   805
            details:  {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   806
            dialog:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   807
            dfn:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   808
            dir:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   809
            div:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   810
            dl:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   811
            dt:       {parent: ' dl '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   812
            em:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   813
            embed:    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   814
            fieldset: {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   815
            figure:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   816
            font:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   817
            footer:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   818
            form:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   819
            frame:    {empty: true, parent: ' frameset '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   820
            frameset: {parent: ' html frameset '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   821
            h1:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   822
            h2:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   823
            h3:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   824
            h4:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   825
            h5:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   826
            h6:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   827
            head:     {parent: ' html '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   828
            header:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   829
            hgroup:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   830
            hr:       {empty: true},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   831
            'hta:application':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   832
                      {empty: true, parent: ' head '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   833
            html:     {parent: '*'},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   834
            i:        {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   835
            iframe:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   836
            img:      {empty: true},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   837
            input:    {empty: true},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   838
            ins:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   839
            kbd:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   840
            keygen:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   841
            label:    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   842
            legend:   {parent: ' details fieldset figure '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   843
            li:       {parent: ' dir menu ol ul '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   844
            link:     {empty: true, parent: ' head '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   845
            map:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   846
            mark:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   847
            menu:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   848
            meta:     {empty: true, parent: ' head noframes noscript '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   849
            meter:    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   850
            nav:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   851
            noframes: {parent: ' html body '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   852
            noscript: {parent: ' body head noframes '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   853
            object:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   854
            ol:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   855
            optgroup: {parent: ' select '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   856
            option:   {parent: ' optgroup select '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   857
            output:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   858
            p:        {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   859
            param:    {empty: true, parent: ' applet object '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   860
            pre:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   861
            progress: {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   862
            q:        {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   863
            rp:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   864
            rt:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   865
            ruby:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   866
            samp:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   867
            script:   {empty: true, parent: ' body div frame head iframe p pre span '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   868
            section:  {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   869
            select:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   870
            small:    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   871
            span:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   872
            source:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   873
            strong:   {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   874
            style:    {parent: ' head ', empty: true},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   875
            sub:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   876
            sup:      {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   877
            table:    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   878
            tbody:    {parent: ' table '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   879
            td:       {parent: ' tr '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   880
            textarea: {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   881
            tfoot:    {parent: ' table '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   882
            th:       {parent: ' tr '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   883
            thead:    {parent: ' table '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   884
            time:     {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   885
            title:    {parent: ' head '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   886
            tr:       {parent: ' table tbody thead tfoot '},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   887
            tt:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   888
            u:        {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   889
            ul:       {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   890
            'var':    {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   891
            video:    {}
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   892
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   893
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   894
        ids,            // HTML ids
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   895
        in_block,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   896
        indent,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   897
//         infer_statement,// Inference rules for statements
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   898
        is_type = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   899
            '*', 'array', 'boolean', 'function', 'number', 'object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   900
            'regexp', 'string'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   901
        ], true),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   902
        itself,         // JSLint itself
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   903
        jslint_limit = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   904
            indent: 10,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   905
            maxerr: 1000,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   906
            maxlen: 256
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   907
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   908
        json_mode,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   909
        lex,            // the tokenizer
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   910
        lines,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   911
        lookahead,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   912
        member,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   913
        node = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   914
            'Buffer', 'clearInterval', 'clearTimeout', 'console', 'exports',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   915
            'global', 'module', 'process', 'querystring', 'require',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   916
            'setInterval', 'setTimeout', '__dirname', '__filename'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   917
        ], false),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   918
        node_js,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   919
        numbery = array_to_object(['indexOf', 'lastIndexOf', 'search'], true),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   920
        next_token,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   921
        option,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   922
        predefined,     // Global variables defined by option
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   923
        prereg,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   924
        prev_token,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   925
        property_type,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   926
        regexp_flag = array_to_object(['g', 'i', 'm'], true),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   927
        return_this = function return_this() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   928
            return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   929
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   930
        rhino = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   931
            'defineClass', 'deserialize', 'gc', 'help', 'load', 'loadClass',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   932
            'print', 'quit', 'readFile', 'readUrl', 'runCommand', 'seal',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   933
            'serialize', 'spawn', 'sync', 'toint32', 'version'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   934
        ], false),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   935
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   936
        scope,      // An object containing an object for each variable in scope
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   937
        semicolon_coda = array_to_object([';', '"', '\'', ')'], true),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   938
        src,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   939
        stack,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   940
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   941
// standard contains the global names that are provided by the
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   942
// ECMAScript standard.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   943
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   944
        standard = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   945
            'Array', 'Boolean', 'Date', 'decodeURI', 'decodeURIComponent',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   946
            'encodeURI', 'encodeURIComponent', 'Error', 'eval', 'EvalError',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   947
            'Function', 'isFinite', 'isNaN', 'JSON', 'Math', 'Number', 'Object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   948
            'parseInt', 'parseFloat', 'RangeError', 'ReferenceError', 'RegExp',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   949
            'String', 'SyntaxError', 'TypeError', 'URIError'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   950
        ], false),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   951
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   952
        standard_property_type = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   953
            E                   : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   954
            LN2                 : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   955
            LN10                : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   956
            LOG2E               : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   957
            LOG10E              : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   958
            MAX_VALUE           : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   959
            MIN_VALUE           : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   960
            NEGATIVE_INFINITY   : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   961
            PI                  : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   962
            POSITIVE_INFINITY   : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   963
            SQRT1_2             : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   964
            SQRT2               : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   965
            apply               : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   966
            bind                : 'function function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   967
            call                : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   968
            ceil                : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   969
            charAt              : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   970
            concat              : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   971
            constructor         : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   972
            create              : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   973
            defineProperty      : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   974
            defineProperties    : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   975
            every               : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   976
            exec                : 'function array',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   977
            filter              : 'function array',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   978
            floor               : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   979
            forEach             : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   980
            freeze              : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   981
            getDate             : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   982
            getDay              : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   983
            getFullYear         : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   984
            getHours            : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   985
            getMilliseconds     : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   986
            getMinutes          : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   987
            getMonth            : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   988
            getOwnPropertyDescriptor
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   989
                                : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   990
            getOwnPropertyNames : 'function array',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   991
            getPrototypeOf      : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   992
            getSeconds          : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   993
            getTime             : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   994
            getTimezoneOffset   : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   995
            getUTCDate          : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   996
            getUTCDay           : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   997
            getUTCFullYear      : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   998
            getUTCHours         : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
   999
            getUTCMilliseconds  : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1000
            getUTCMinutes       : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1001
            getUTCMonth         : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1002
            getUTCSeconds       : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1003
            getYear             : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1004
            hasOwnProperty      : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1005
            indexOf             : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1006
            isExtensible        : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1007
            isFrozen            : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1008
            isPrototypeOf       : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1009
            isSealed            : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1010
            join                : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1011
            keys                : 'function array',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1012
            lastIndexOf         : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1013
            lastIndex           : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1014
            length              : 'number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1015
            map                 : 'function array',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1016
            now                 : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1017
            parse               : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1018
            pop                 : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1019
            preventExtensions   : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1020
            propertyIsEnumerable: 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1021
            prototype           : 'object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1022
            push                : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1023
            reduce              : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1024
            reduceRight         : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1025
            reverse             : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1026
            seal                : 'function object',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1027
            setDate             : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1028
            setDay              : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1029
            setFullYear         : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1030
            setHours            : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1031
            setMilliseconds     : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1032
            setMinutes          : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1033
            setMonth            : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1034
            setSeconds          : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1035
            setTime             : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1036
            setTimezoneOffset   : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1037
            setUTCDate          : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1038
            setUTCDay           : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1039
            setUTCFullYear      : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1040
            setUTCHours         : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1041
            setUTCMilliseconds  : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1042
            setUTCMinutes       : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1043
            setUTCMonth         : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1044
            setUTCSeconds       : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1045
            setYear             : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1046
            shift               : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1047
            slice               : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1048
            some                : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1049
            sort                : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1050
            splice              : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1051
            stringify           : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1052
            substr              : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1053
            substring           : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1054
            test                : 'function boolean',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1055
            toDateString        : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1056
            toExponential       : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1057
            toFixed             : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1058
            toJSON              : 'function',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1059
            toISOString         : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1060
            toLocaleDateString  : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1061
            toLocaleLowerCase   : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1062
            toLocaleUpperCase   : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1063
            toLocaleString      : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1064
            toLocaleTimeString  : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1065
            toLowerCase         : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1066
            toPrecision         : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1067
            toTimeString        : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1068
            toUpperCase         : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1069
            toUTCString         : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1070
            trim                : 'function string',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1071
            unshift             : 'function number',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1072
            valueOf             : 'function'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1073
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1074
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1075
        strict_mode,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1076
        syntax = {},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1077
        tab,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1078
        token,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1079
//         type_state_change,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1080
        urls,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1081
        var_mode,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1082
        warnings,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1083
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1084
// widget contains the global names which are provided to a Yahoo
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1085
// (fna Konfabulator) widget.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1086
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1087
        widget = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1088
            'alert', 'animator', 'appleScript', 'beep', 'bytesToUIString',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1089
            'Canvas', 'chooseColor', 'chooseFile', 'chooseFolder',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1090
            'closeWidget', 'COM', 'convertPathToHFS', 'convertPathToPlatform',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1091
            'CustomAnimation', 'escape', 'FadeAnimation', 'filesystem', 'Flash',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1092
            'focusWidget', 'form', 'FormField', 'Frame', 'HotKey', 'Image',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1093
            'include', 'isApplicationRunning', 'iTunes', 'konfabulatorVersion',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1094
            'log', 'md5', 'MenuItem', 'MoveAnimation', 'openURL', 'play',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1095
            'Point', 'popupMenu', 'preferenceGroups', 'preferences', 'print',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1096
            'prompt', 'random', 'Rectangle', 'reloadWidget', 'ResizeAnimation',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1097
            'resolvePath', 'resumeUpdates', 'RotateAnimation', 'runCommand',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1098
            'runCommandInBg', 'saveAs', 'savePreferences', 'screen',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1099
            'ScrollBar', 'showWidgetPreferences', 'sleep', 'speak', 'Style',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1100
            'suppressUpdates', 'system', 'tellWidget', 'Text', 'TextArea',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1101
            'Timer', 'unescape', 'updateNow', 'URL', 'Web', 'widget', 'Window',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1102
            'XMLDOM', 'XMLHttpRequest', 'yahooCheckLogin', 'yahooLogin',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1103
            'yahooLogout'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1104
        ], true),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1105
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1106
        windows = array_to_object([
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1107
            'ActiveXObject', 'CScript', 'Debug', 'Enumerator', 'System',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1108
            'VBArray', 'WScript', 'WSH'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1109
        ], false),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1110
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1111
//  xmode is used to adapt to the exceptions in html parsing.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1112
//  It can have these states:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1113
//      ''      .js script file
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1114
//      'html'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1115
//      'outer'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1116
//      'script'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1117
//      'style'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1118
//      'scriptstring'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1119
//      'styleproperty'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1120
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1121
        xmode,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1122
        xquote,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1123
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1124
// Regular expressions. Some of these are stupidly long.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1125
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1126
// unsafe comment or string
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1127
        ax = /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1128
// carriage return, or carriage return linefeed
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1129
        crx = /\r/g,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1130
        crlfx = /\r\n/g,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1131
// unsafe characters that are silently deleted by one or more browsers
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1132
        cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1133
// query characters for ids
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1134
        dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1135
// html token
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1136
        hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1137
// identifier
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1138
        ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1139
// javascript url
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1140
        jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1141
// star slash
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1142
        lx = /\*\/|\/\*/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1143
// characters in strings that need escapement
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1144
        nx = /[\u0000-\u001f'\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1145
// outer html token
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1146
        ox = /[>&]|<[\/!]?|--/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1147
// attributes characters
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1148
        qx = /[^a-zA-Z0-9+\-_\/ ]/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1149
// style
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1150
        sx = /^\s*([{}:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1151
        ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1152
// token
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1153
        tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|properties|property|members?|globals?)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1154
// url badness
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1155
        ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto|script/i,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1156
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1157
        rx = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1158
            outer: hx,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1159
            html: hx,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1160
            style: sx,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1161
            styleproperty: ssx
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1162
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1163
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1164
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1165
    function F() {}     // Used by Object.create
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1166
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1167
// Provide critical ES5 functions to ES3.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1168
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1169
    if (typeof Array.prototype.filter !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1170
        Array.prototype.filter = function (f) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1171
            var i, length = this.length, result = [], value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1172
            for (i = 0; i < length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1173
                try {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1174
                    value = this[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1175
                    if (f(value)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1176
                        result.push(value);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1177
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1178
                } catch (ignore) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1179
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1180
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1181
            return result;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1182
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1183
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1184
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1185
    if (typeof Array.prototype.forEach !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1186
        Array.prototype.forEach = function (f) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1187
            var i, length = this.length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1188
            for (i = 0; i < length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1189
                try {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1190
                    f(this[i]);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1191
                } catch (ignore) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1192
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1193
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1194
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1195
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1196
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1197
    if (typeof Array.isArray !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1198
        Array.isArray = function (o) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1199
            return Object.prototype.toString.apply(o) === '[object Array]';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1200
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1201
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1202
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1203
    if (!Object.prototype.hasOwnProperty.call(Object, 'create')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1204
        Object.create = function (o) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1205
            F.prototype = o;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1206
            return new F();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1207
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1208
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1209
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1210
    if (typeof Object.keys !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1211
        Object.keys = function (o) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1212
            var array = [], key;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1213
            for (key in o) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1214
                if (Object.prototype.hasOwnProperty.call(o, key)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1215
                    array.push(key);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1216
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1217
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1218
            return array;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1219
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1220
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1221
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1222
    if (typeof String.prototype.entityify !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1223
        String.prototype.entityify = function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1224
            return this
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1225
                .replace(/&/g, '&amp;')
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1226
                .replace(/</g, '&lt;')
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1227
                .replace(/>/g, '&gt;');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1228
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1229
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1230
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1231
    if (typeof String.prototype.isAlpha !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1232
        String.prototype.isAlpha = function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1233
            return (this >= 'a' && this <= 'z\uffff') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1234
                (this >= 'A' && this <= 'Z\uffff');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1235
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1236
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1237
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1238
    if (typeof String.prototype.isDigit !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1239
        String.prototype.isDigit = function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1240
            return (this >= '0' && this <= '9');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1241
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1242
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1243
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1244
    if (typeof String.prototype.supplant !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1245
        String.prototype.supplant = function (o) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1246
            return this.replace(/\{([^{}]*)\}/g, function (a, b) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1247
                var replacement = o[b];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1248
                return typeof replacement === 'string' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1249
                    typeof replacement === 'number' ? replacement : a;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1250
            });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1251
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1252
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1253
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1254
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1255
    function sanitize(a) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1256
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1257
//  Escapify a troublesome character.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1258
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1259
        return escapes[a] ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1260
            '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1261
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1262
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1263
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1264
    function add_to_predefined(group) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1265
        Object.keys(group).forEach(function (name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1266
            predefined[name] = group[name];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1267
        });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1268
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1269
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1270
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1271
    function assume() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1272
        if (!option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1273
            if (option.rhino) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1274
                add_to_predefined(rhino);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1275
                option.rhino = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1276
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1277
            if (option.devel) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1278
                add_to_predefined(devel);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1279
                option.devel = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1280
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1281
            if (option.browser) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1282
                add_to_predefined(browser);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1283
                option.browser = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1284
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1285
            if (option.windows) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1286
                add_to_predefined(windows);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1287
                option.windows = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1288
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1289
            if (option.node) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1290
                add_to_predefined(node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1291
                option.node = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1292
                node_js = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1293
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1294
            if (option.widget) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1295
                add_to_predefined(widget);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1296
                option.widget = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1297
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1298
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1299
        if (option.type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1300
            option.confusion = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1301
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1302
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1303
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1304
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1305
// Produce an error warning.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1306
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1307
    function artifact(tok) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1308
        if (!tok) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1309
            tok = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1310
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1311
        return tok.number || tok.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1312
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1313
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1314
    function quit(message, line, character) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1315
        throw {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1316
            name: 'JSLintError',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1317
            line: line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1318
            character: character,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1319
            message: bundle.scanned_a_b.supplant({
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1320
                a: message,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1321
                b: Math.floor((line / lines.length) * 100)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1322
            })
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1323
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1324
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1325
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1326
    function warn(message, offender, a, b, c, d) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1327
        var character, line, warning;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1328
        offender = offender || next_token;  // `~
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1329
        line = offender.line || 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1330
        character = offender.from || 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1331
        warning = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1332
            id: '(error)',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1333
            raw: bundle[message] || message,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1334
            evidence: lines[line - 1] || '',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1335
            line: line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1336
            character: character,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1337
            a: a || (offender.id === '(number)'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1338
                ? String(offender.number)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1339
                : offender.string),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1340
            b: b,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1341
            c: c,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1342
            d: d
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1343
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1344
        warning.reason = warning.raw.supplant(warning);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1345
        JSLINT.errors.push(warning);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1346
        if (option.passfail) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1347
            quit(bundle.stopping, line, character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1348
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1349
        warnings += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1350
        if (warnings >= option.maxerr) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1351
            quit(bundle.too_many, line, character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1352
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1353
        return warning;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1354
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1355
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1356
    function warn_at(message, line, character, a, b, c, d) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1357
        return warn(message, {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1358
            line: line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1359
            from: character
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1360
        }, a, b, c, d);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1361
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1362
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1363
    function stop(message, offender, a, b, c, d) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1364
        var warning = warn(message, offender, a, b, c, d);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1365
        quit(bundle.stopping, warning.line, warning.character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1366
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1367
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1368
    function stop_at(message, line, character, a, b, c, d) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1369
        return stop(message, {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1370
            line: line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1371
            from: character
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1372
        }, a, b, c, d);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1373
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1374
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1375
    function expected_at(at) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1376
        if (!option.white && next_token.from !== at) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1377
            warn('expected_a_at_b_c', next_token, '', at,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1378
                next_token.from);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1379
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1380
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1381
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1382
    function aint(it, name, expected) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1383
        if (it[name] !== expected) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1384
            warn('expected_a_b', it, expected, it[name]);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1385
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1386
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1387
            return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1388
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1389
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1390
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1391
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1392
// lexical analysis and token construction
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1393
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1394
    lex = (function lex() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1395
        var character, c, from, length, line, pos, source_row;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1396
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1397
// Private lex methods
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1398
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1399
        function next_line() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1400
            var at;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1401
            if (line >= lines.length) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1402
                return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1403
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1404
            character = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1405
            source_row = lines[line];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1406
            line += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1407
            at = source_row.search(/ \t/);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1408
            if (at >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1409
                warn_at('mixed', line, at + 1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1410
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1411
            source_row = source_row.replace(/\t/g, tab);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1412
            at = source_row.search(cx);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1413
            if (at >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1414
                warn_at('unsafe', line, at);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1415
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1416
            if (option.maxlen && option.maxlen < source_row.length) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1417
                warn_at('too_long', line, source_row.length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1418
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1419
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1420
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1421
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1422
// Produce a token object.  The token inherits from a syntax symbol.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1423
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1424
        function it(type, value) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1425
            var id, the_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1426
            if (type === '(string)' || type === '(range)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1427
                if (jx.test(value)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1428
                    warn_at('url', line, from);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1429
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1430
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1431
            the_token = Object.create(syntax[(
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1432
                type === '(punctuator)' || (type === '(identifier)' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1433
                        Object.prototype.hasOwnProperty.call(syntax, value))
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1434
                    ? value
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1435
                    : type
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1436
            )] || syntax['(error)']);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1437
            if (type === '(identifier)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1438
                the_token.identifier = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1439
                if (value === '__iterator__' || value === '__proto__') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1440
                    stop_at('reserved_a', line, from, value);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1441
                } else if (!option.nomen &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1442
                        (value.charAt(0) === '_' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1443
                        value.charAt(value.length - 1) === '_')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1444
                    warn_at('dangling_a', line, from, value);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1445
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1446
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1447
            if (type === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1448
                the_token.number = +value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1449
            } else if (value !== undefined) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1450
                the_token.string = String(value);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1451
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1452
            the_token.line = line;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1453
            the_token.from = from;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1454
            the_token.thru = character;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1455
            id = the_token.id;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1456
            prereg = id && (
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1457
                ('(,=:[!&|?{};'.indexOf(id.charAt(id.length - 1)) >= 0) ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1458
                id === 'return' || id === 'case'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1459
            );
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1460
            return the_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1461
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1462
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1463
        function match(x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1464
            var exec = x.exec(source_row), first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1465
            if (exec) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1466
                length = exec[0].length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1467
                first = exec[1];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1468
                c = first.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1469
                source_row = source_row.slice(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1470
                from = character + length - first.length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1471
                character += length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1472
                return first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1473
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1474
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1475
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1476
        function string(x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1477
            var c, pos = 0, r = '', result;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1478
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1479
            function hex(n) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1480
                var i = parseInt(source_row.substr(pos + 1, n), 16);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1481
                pos += n;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1482
                if (i >= 32 && i <= 126 &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1483
                        i !== 34 && i !== 92 && i !== 39) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1484
                    warn_at('unexpected_a', line, character, '\\');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1485
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1486
                character += n;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1487
                c = String.fromCharCode(i);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1488
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1489
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1490
            if (json_mode && x !== '"') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1491
                warn_at('expected_a', line, character, '"');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1492
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1493
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1494
            if (xquote === x || (xmode === 'scriptstring' && !xquote)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1495
                return it('(punctuator)', x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1496
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1497
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1498
            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1499
                while (pos >= source_row.length) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1500
                    pos = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1501
                    if (xmode !== 'html' || !next_line()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1502
                        stop_at('unclosed', line, from);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1503
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1504
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1505
                c = source_row.charAt(pos);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1506
                if (c === x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1507
                    character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1508
                    source_row = source_row.slice(pos + 1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1509
                    result = it('(string)', r);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1510
                    result.quote = x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1511
                    return result;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1512
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1513
                if (c < ' ') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1514
                    if (c === '\n' || c === '\r') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1515
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1516
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1517
                    warn_at('control_a', line, character + pos,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1518
                        source_row.slice(0, pos));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1519
                } else if (c === xquote) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1520
                    warn_at('bad_html', line, character + pos);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1521
                } else if (c === '<') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1522
                    if (option.safe && xmode === 'html') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1523
                        warn_at('adsafe_a', line, character + pos, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1524
                    } else if (source_row.charAt(pos + 1) === '/' && (xmode || option.safe)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1525
                        warn_at('expected_a_b', line, character,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1526
                            '<\\/', '</');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1527
                    } else if (source_row.charAt(pos + 1) === '!' && (xmode || option.safe)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1528
                        warn_at('unexpected_a', line, character, '<!');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1529
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1530
                } else if (c === '\\') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1531
                    if (xmode === 'html') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1532
                        if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1533
                            warn_at('adsafe_a', line, character + pos, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1534
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1535
                    } else if (xmode === 'styleproperty') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1536
                        pos += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1537
                        character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1538
                        c = source_row.charAt(pos);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1539
                        if (c !== x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1540
                            warn_at('unexpected_a', line, character, '\\');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1541
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1542
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1543
                        pos += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1544
                        character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1545
                        c = source_row.charAt(pos);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1546
                        switch (c) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1547
                        case '':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1548
                            if (!option.es5) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1549
                                warn_at('es5', line, character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1550
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1551
                            next_line();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1552
                            pos = -1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1553
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1554
                        case xquote:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1555
                            warn_at('bad_html', line, character + pos);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1556
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1557
                        case '\'':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1558
                            if (json_mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1559
                                warn_at('unexpected_a', line, character, '\\\'');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1560
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1561
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1562
                        case 'u':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1563
                            hex(4);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1564
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1565
                        case 'v':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1566
                            if (json_mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1567
                                warn_at('unexpected_a', line, character, '\\v');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1568
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1569
                            c = '\v';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1570
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1571
                        case 'x':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1572
                            if (json_mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1573
                                warn_at('unexpected_a', line, character, '\\x');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1574
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1575
                            hex(2);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1576
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1577
                        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1578
                            c = descapes[c];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1579
                            if (typeof c !== 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1580
                                warn_at('unexpected_a', line, character, '\\');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1581
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1582
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1583
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1584
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1585
                r += c;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1586
                character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1587
                pos += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1588
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1589
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1590
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1591
        function number(snippet) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1592
            var digit;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1593
            if (xmode !== 'style' && xmode !== 'styleproperty' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1594
                    source_row.charAt(0).isAlpha()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1595
                warn_at('expected_space_a_b',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1596
                    line, character, c, source_row.charAt(0));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1597
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1598
            if (c === '0') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1599
                digit = snippet.charAt(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1600
                if (digit.isDigit()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1601
                    if (token.id !== '.' && xmode !== 'styleproperty') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1602
                        warn_at('unexpected_a', line, character, snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1603
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1604
                } else if (json_mode && (digit === 'x' || digit === 'X')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1605
                    warn_at('unexpected_a', line, character, '0x');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1606
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1607
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1608
            if (snippet.slice(snippet.length - 1) === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1609
                warn_at('trailing_decimal_a', line, character, snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1610
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1611
            if (xmode !== 'style') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1612
                digit = +snippet;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1613
                if (!isFinite(digit)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1614
                    warn_at('bad_number', line, character, snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1615
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1616
                snippet = digit;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1617
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1618
            return it('(number)', snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1619
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1620
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1621
        function comment(snippet) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1622
            if (comments_off || src || (xmode && xmode !== 'script' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1623
                    xmode !== 'style' && xmode !== 'styleproperty')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1624
                warn_at('unexpected_comment', line, character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1625
            } else if (xmode === 'script' && /<\//i.test(source_row)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1626
                warn_at('unexpected_a', line, character, '<\/');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1627
            } else if (option.safe && ax.test(snippet)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1628
                warn_at('dangerous_comment', line, character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1629
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1630
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1631
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1632
        function regexp() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1633
            var b,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1634
                bit,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1635
                captures = 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1636
                depth = 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1637
                flag = '',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1638
                high,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1639
                letter,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1640
                length = 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1641
                low,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1642
                potential,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1643
                quote,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1644
                result;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1645
            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1646
                b = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1647
                c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1648
                length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1649
                switch (c) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1650
                case '':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1651
                    stop_at('unclosed_regexp', line, from);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1652
                    return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1653
                case '/':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1654
                    if (depth > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1655
                        warn_at('unescaped_a', line, from + length, '/');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1656
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1657
                    c = source_row.slice(0, length - 1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1658
                    potential = Object.create(regexp_flag);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1659
                    for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1660
                        letter = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1661
                        if (potential[letter] !== true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1662
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1663
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1664
                        potential[letter] = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1665
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1666
                        flag += letter;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1667
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1668
                    if (source_row.charAt(length).isAlpha()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1669
                        stop_at('unexpected_a', line, from, source_row.charAt(length));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1670
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1671
                    character += length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1672
                    source_row = source_row.slice(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1673
                    quote = source_row.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1674
                    if (quote === '/' || quote === '*') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1675
                        stop_at('confusing_regexp', line, from);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1676
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1677
                    result = it('(regexp)', c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1678
                    result.flag = flag;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1679
                    return result;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1680
                case '\\':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1681
                    c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1682
                    if (c < ' ') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1683
                        warn_at('control_a', line, from + length, String(c));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1684
                    } else if (c === '<') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1685
                        warn_at(bundle.unexpected_a, line, from + length, '\\');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1686
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1687
                    length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1688
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1689
                case '(':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1690
                    depth += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1691
                    b = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1692
                    if (source_row.charAt(length) === '?') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1693
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1694
                        switch (source_row.charAt(length)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1695
                        case ':':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1696
                        case '=':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1697
                        case '!':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1698
                            length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1699
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1700
                        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1701
                            warn_at(bundle.expected_a_b, line, from + length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1702
                                ':', source_row.charAt(length));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1703
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1704
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1705
                        captures += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1706
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1707
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1708
                case '|':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1709
                    b = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1710
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1711
                case ')':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1712
                    if (depth === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1713
                        warn_at('unescaped_a', line, from + length, ')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1714
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1715
                        depth -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1716
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1717
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1718
                case ' ':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1719
                    pos = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1720
                    while (source_row.charAt(length) === ' ') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1721
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1722
                        pos += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1723
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1724
                    if (pos > 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1725
                        warn_at('use_braces', line, from + length, pos);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1726
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1727
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1728
                case '[':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1729
                    c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1730
                    if (c === '^') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1731
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1732
                        if (!option.regexp) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1733
                            warn_at('insecure_a', line, from + length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1734
                        } else if (source_row.charAt(length) === ']') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1735
                            stop_at('unescaped_a', line, from + length, '^');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1736
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1737
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1738
                    bit = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1739
                    if (c === ']') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1740
                        warn_at('empty_class', line, from + length - 1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1741
                        bit = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1742
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1743
klass:              do {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1744
                        c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1745
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1746
                        switch (c) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1747
                        case '[':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1748
                        case '^':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1749
                            warn_at('unescaped_a', line, from + length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1750
                            bit = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1751
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1752
                        case '-':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1753
                            if (bit) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1754
                                bit = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1755
                            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1756
                                warn_at('unescaped_a', line, from + length, '-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1757
                                bit = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1758
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1759
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1760
                        case ']':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1761
                            if (!bit) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1762
                                warn_at('unescaped_a', line, from + length - 1, '-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1763
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1764
                            break klass;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1765
                        case '\\':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1766
                            c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1767
                            if (c < ' ') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1768
                                warn_at(bundle.control_a, line, from + length, String(c));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1769
                            } else if (c === '<') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1770
                                warn_at(bundle.unexpected_a, line, from + length, '\\');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1771
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1772
                            length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1773
                            bit = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1774
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1775
                        case '/':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1776
                            warn_at('unescaped_a', line, from + length - 1, '/');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1777
                            bit = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1778
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1779
                        case '<':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1780
                            if (xmode === 'script') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1781
                                c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1782
                                if (c === '!' || c === '/') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1783
                                    warn_at(bundle.html_confusion_a, line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1784
                                        from + length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1785
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1786
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1787
                            bit = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1788
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1789
                        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1790
                            bit = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1791
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1792
                    } while (c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1793
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1794
                case '.':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1795
                    if (!option.regexp) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1796
                        warn_at('insecure_a', line, from + length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1797
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1798
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1799
                case ']':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1800
                case '?':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1801
                case '{':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1802
                case '}':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1803
                case '+':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1804
                case '*':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1805
                    warn_at('unescaped_a', line, from + length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1806
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1807
                case '<':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1808
                    if (xmode === 'script') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1809
                        c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1810
                        if (c === '!' || c === '/') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1811
                            warn_at(bundle.html_confusion_a, line, from + length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1812
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1813
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1814
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1815
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1816
                if (b) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1817
                    switch (source_row.charAt(length)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1818
                    case '?':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1819
                    case '+':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1820
                    case '*':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1821
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1822
                        if (source_row.charAt(length) === '?') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1823
                            length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1824
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1825
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1826
                    case '{':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1827
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1828
                        c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1829
                        if (c < '0' || c > '9') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1830
                            warn_at(bundle.expected_number_a, line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1831
                                from + length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1832
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1833
                        length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1834
                        low = +c;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1835
                        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1836
                            c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1837
                            if (c < '0' || c > '9') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1838
                                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1839
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1840
                            length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1841
                            low = +c + (low * 10);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1842
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1843
                        high = low;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1844
                        if (c === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1845
                            length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1846
                            high = Infinity;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1847
                            c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1848
                            if (c >= '0' && c <= '9') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1849
                                length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1850
                                high = +c;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1851
                                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1852
                                    c = source_row.charAt(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1853
                                    if (c < '0' || c > '9') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1854
                                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1855
                                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1856
                                    length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1857
                                    high = +c + (high * 10);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1858
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1859
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1860
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1861
                        if (source_row.charAt(length) !== '}') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1862
                            warn_at(bundle.expected_a_b, line, from + length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1863
                                '}', c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1864
                        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1865
                            length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1866
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1867
                        if (source_row.charAt(length) === '?') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1868
                            length += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1869
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1870
                        if (low > high) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1871
                            warn_at(bundle.not_greater, line, from + length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1872
                                low, high);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1873
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1874
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1875
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1876
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1877
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1878
            c = source_row.slice(0, length - 1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1879
            character += length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1880
            source_row = source_row.slice(length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1881
            return it('(regexp)', c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1882
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1883
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1884
// Public lex methods
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1885
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1886
        return {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1887
            init: function (source) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1888
                if (typeof source === 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1889
                    lines = source
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1890
                        .replace(crlfx, '\n')
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1891
                        .replace(crx, '\n')
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1892
                        .split('\n');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1893
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1894
                    lines = source;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1895
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1896
                line = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1897
                next_line();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1898
                from = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1899
            },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1900
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1901
            range: function (begin, end) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1902
                var c, value = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1903
                from = character;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1904
                if (source_row.charAt(0) !== begin) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1905
                    stop_at('expected_a_b', line, character, begin,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1906
                        source_row.charAt(0));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1907
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1908
                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1909
                    source_row = source_row.slice(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1910
                    character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1911
                    c = source_row.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1912
                    switch (c) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1913
                    case '':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1914
                        stop_at('missing_a', line, character, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1915
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1916
                    case end:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1917
                        source_row = source_row.slice(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1918
                        character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1919
                        return it('(range)', value);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1920
                    case xquote:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1921
                    case '\\':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1922
                        warn_at('unexpected_a', line, character, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1923
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1924
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1925
                    value += c;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1926
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1927
            },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1928
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1929
// token -- this is called by advance to get the next token.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1930
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1931
            token: function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1932
                var c, i, snippet;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1933
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1934
                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1935
                    while (!source_row) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1936
                        if (!next_line()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1937
                            return it('(end)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1938
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1939
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1940
                    while (xmode === 'outer') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1941
                        i = source_row.search(ox);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1942
                        if (i === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1943
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1944
                        } else if (i > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1945
                            character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1946
                            source_row = source_row.slice(i);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1947
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1948
                        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1949
                            if (!next_line()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1950
                                return it('(end)', '');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1951
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1952
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1953
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1954
                    snippet = match(rx[xmode] || tx);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1955
                    if (!snippet) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1956
                        if (source_row) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1957
                            if (source_row.charAt(0) === ' ') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1958
                                if (!option.white) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1959
                                    warn_at('unexpected_a', line, character,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1960
                                        '(space)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1961
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1962
                                character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1963
                                source_row = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1964
                            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1965
                                stop_at('unexpected_a', line, character,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1966
                                    source_row.charAt(0));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1967
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1968
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1969
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1970
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1971
//      identifier
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1972
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1973
                        c = snippet.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1974
                        if (c.isAlpha() || c === '_' || c === '$') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1975
                            return it('(identifier)', snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1976
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1977
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1978
//      number
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1979
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1980
                        if (c.isDigit()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1981
                            return number(snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1982
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1983
                        switch (snippet) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1984
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1985
//      string
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1986
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1987
                        case '"':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1988
                        case "'":
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1989
                            return string(snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1990
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1991
//      // comment
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1992
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1993
                        case '//':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1994
                            comment(source_row);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1995
                            source_row = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1996
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1997
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1998
//      /* comment
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  1999
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2000
                        case '/*':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2001
                            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2002
                                i = source_row.search(lx);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2003
                                if (i >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2004
                                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2005
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2006
                                comment(source_row);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2007
                                if (!next_line()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2008
                                    stop_at('unclosed_comment', line, character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2009
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2010
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2011
                            comment(source_row.slice(0, i));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2012
                            character += i + 2;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2013
                            if (source_row.charAt(i) === '/') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2014
                                stop_at('nested_comment', line, character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2015
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2016
                            source_row = source_row.slice(i + 2);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2017
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2018
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2019
                        case '':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2020
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2021
//      /
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2022
                        case '/':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2023
                            if (token.id === '/=') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2024
                                stop_at(
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2025
                                    bundle.slash_equal,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2026
                                    line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2027
                                    from
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2028
                                );
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2029
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2030
                            return prereg
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2031
                                ? regexp()
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2032
                                : it('(punctuator)', snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2033
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2034
//      punctuator
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2035
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2036
                        case '<!--':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2037
                            length = line;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2038
//                            c = character;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2039
                            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2040
                                i = source_row.indexOf('--');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2041
                                if (i >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2042
                                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2043
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2044
                                i = source_row.indexOf('<!');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2045
                                if (i >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2046
                                    stop_at('nested_comment',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2047
                                        line, character + i);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2048
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2049
                                if (!next_line()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2050
                                    stop_at('unclosed_comment', length, c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2051
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2052
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2053
                            length = source_row.indexOf('<!');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2054
                            if (length >= 0 && length < i) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2055
                                stop_at('nested_comment',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2056
                                    line, character + length);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2057
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2058
                            character += i;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2059
                            if (source_row.charAt(i + 2) !== '>') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2060
                                stop_at('expected_a', line, character, '-->');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2061
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2062
                            character += 3;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2063
                            source_row = source_row.slice(i + 3);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2064
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2065
                        case '#':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2066
                            if (xmode === 'html' || xmode === 'styleproperty') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2067
                                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2068
                                    c = source_row.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2069
                                    if ((c < '0' || c > '9') &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2070
                                            (c < 'a' || c > 'f') &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2071
                                            (c < 'A' || c > 'F')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2072
                                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2073
                                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2074
                                    character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2075
                                    source_row = source_row.slice(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2076
                                    snippet += c;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2077
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2078
                                if (snippet.length !== 4 && snippet.length !== 7) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2079
                                    warn_at('bad_color_a', line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2080
                                        from + length, snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2081
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2082
                                return it('(color)', snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2083
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2084
                            return it('(punctuator)', snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2085
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2086
                        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2087
                            if (xmode === 'outer' && c === '&') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2088
                                character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2089
                                source_row = source_row.slice(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2090
                                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2091
                                    c = source_row.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2092
                                    character += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2093
                                    source_row = source_row.slice(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2094
                                    if (c === ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2095
                                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2096
                                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2097
                                    if (!((c >= '0' && c <= '9') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2098
                                            (c >= 'a' && c <= 'z') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2099
                                            c === '#')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2100
                                        stop_at('bad_entity', line, from + length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2101
                                            character);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2102
                                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2103
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2104
                                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2105
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2106
                            return it('(punctuator)', snippet);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2107
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2108
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2109
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2110
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2111
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2112
    }());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2113
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2114
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2115
    function add_label(token, kind, name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2116
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2117
// Define the symbol in the current function in the current scope.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2118
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2119
        name = name || token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2120
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2121
// Global variables cannot be created in the safe subset. If a global variable
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2122
// already exists, do nothing. If it is predefined, define it.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2123
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2124
        if (funct === global_funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2125
            if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2126
                warn('adsafe_a', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2127
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2128
            if (typeof global_funct[name] !== 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2129
                token.writeable = typeof predefined[name] === 'boolean'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2130
                    ? predefined[name]
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2131
                    : true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2132
                token.funct = funct;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2133
                global_scope[name] = token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2134
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2135
            if (kind === 'becoming') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2136
                kind = 'var';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2137
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2138
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2139
// Ordinary variables.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2140
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2141
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2142
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2143
// Warn if the variable already exists.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2144
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2145
            if (typeof funct[name] === 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2146
                if (funct[name] === 'undef') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2147
                    if (!option.undef) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2148
                        warn('used_before_a', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2149
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2150
                    kind = 'var';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2151
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2152
                    warn('already_defined', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2153
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2154
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2155
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2156
// Add the symbol to the current function.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2157
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2158
                token.funct = funct;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2159
                token.writeable = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2160
                scope[name] = token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2161
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2162
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2163
        funct[name] = kind;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2164
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2165
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2166
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2167
    function peek(distance) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2168
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2169
// Peek ahead to a future token. The distance is how far ahead to look. The
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2170
// default is the next token.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2171
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2172
        var found, slot = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2173
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2174
        distance = distance || 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2175
        while (slot <= distance) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2176
            found = lookahead[slot];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2177
            if (!found) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2178
                found = lookahead[slot] = lex.token();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2179
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2180
            slot += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2181
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2182
        return found;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2183
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2184
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2185
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2186
    function advance(id, match) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2187
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2188
// Produce the next token, also looking for programming errors.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2189
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2190
        if (indent) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2191
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2192
// If indentation checking was requested, then inspect all of the line breakings.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2193
// The var statement is tricky because the names might be aligned or not. We
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2194
// look at the first line break after the var to determine the programmer's
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2195
// intention.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2196
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2197
            if (var_mode && next_token.line !== token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2198
                if ((var_mode !== indent || !next_token.edge) &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2199
                        next_token.from === indent.at -
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2200
                        (next_token.edge ? option.indent : 0)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2201
                    var dent = indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2202
                    for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2203
                        dent.at -= option.indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2204
                        if (dent === var_mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2205
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2206
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2207
                        dent = dent.was;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2208
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2209
                    dent.open = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2210
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2211
                var_mode = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2212
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2213
            if (next_token.id === '?' && indent.mode === ':' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2214
                    token.line !== next_token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2215
                indent.at -= option.indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2216
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2217
            if (indent.open) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2218
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2219
// If the token is an edge.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2220
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2221
                if (next_token.edge) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2222
                    if (next_token.edge === 'label') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2223
                        expected_at(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2224
                    } else if (next_token.edge === 'case') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2225
                        expected_at(indent.at - option.indent);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2226
                    } else if (indent.mode !== 'array' || next_token.line !== token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2227
                        expected_at(indent.at);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2228
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2229
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2230
// If the token is not an edge, but is the first token on the line.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2231
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2232
                } else if (next_token.line !== token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2233
                    if (next_token.from < indent.at + (indent.mode ===
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2234
                            'expression' ? 0 : option.indent)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2235
                        expected_at(indent.at + option.indent);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2236
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2237
                    indent.wrap = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2238
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2239
            } else if (next_token.line !== token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2240
                if (next_token.edge) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2241
                    expected_at(indent.at);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2242
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2243
                    indent.wrap = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2244
                    if (indent.mode === 'statement' || indent.mode === 'var') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2245
                        expected_at(indent.at + option.indent);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2246
                    } else if (next_token.from < indent.at + (indent.mode ===
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2247
                            'expression' ? 0 : option.indent)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2248
                        expected_at(indent.at + option.indent);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2249
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2250
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2251
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2252
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2253
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2254
        switch (token.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2255
        case '(number)':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2256
            if (next_token.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2257
                warn('trailing_decimal_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2258
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2259
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2260
        case '-':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2261
            if (next_token.id === '-' || next_token.id === '--') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2262
                warn('confusing_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2263
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2264
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2265
        case '+':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2266
            if (next_token.id === '+' || next_token.id === '++') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2267
                warn('confusing_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2268
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2269
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2270
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2271
        if (token.id === '(string)' || token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2272
            anonname = token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2273
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2274
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2275
        if (id && next_token.id !== id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2276
            if (match) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2277
                warn('expected_a_b_from_c_d', next_token, id,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2278
                    match.id, match.line, artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2279
            } else if (!next_token.identifier || next_token.string !== id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2280
                warn('expected_a_b', next_token, id, artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2281
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2282
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2283
        prev_token = token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2284
        token = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2285
        next_token = lookahead.shift() || lex.token();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2286
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2287
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2288
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2289
    function advance_identifier(string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2290
        if (next_token.identifier && next_token.string === string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2291
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2292
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2293
            warn('expected_a_b', next_token, string, artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2294
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2295
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2296
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2297
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2298
    function do_safe() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2299
        if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2300
            option.safe = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2301
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2302
        if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2303
            option.browser     =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2304
                option['continue'] =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2305
                option.css     =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2306
                option.debug   =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2307
                option.devel   =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2308
                option.evil    =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2309
                option.forin   =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2310
                option.newcap  =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2311
                option.nomen   =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2312
                option.on      =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2313
                option.rhino   =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2314
                option.sloppy  =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2315
                option.sub     =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2316
                option.undef   =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2317
                option.widget  =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2318
                option.windows = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2319
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2320
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2321
            delete predefined.Array;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2322
            delete predefined.Date;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2323
            delete predefined.Function;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2324
            delete predefined.Object;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2325
            delete predefined['eval'];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2326
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2327
            add_to_predefined({
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2328
                ADSAFE: false,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2329
                lib: false
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2330
            });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2331
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2332
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2333
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2334
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2335
    function do_globals() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2336
        var name, writeable;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2337
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2338
            if (next_token.id !== '(string)' && !next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2339
                return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2340
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2341
            name = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2342
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2343
            writeable = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2344
            if (next_token.id === ':') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2345
                advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2346
                switch (next_token.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2347
                case 'true':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2348
                    writeable = predefined[name] !== false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2349
                    advance('true');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2350
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2351
                case 'false':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2352
                    advance('false');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2353
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2354
                default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2355
                    stop('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2356
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2357
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2358
            predefined[name] = writeable;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2359
            if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2360
                return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2361
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2362
            advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2363
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2364
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2365
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2366
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2367
    function do_jslint() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2368
        var name, value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2369
        while (next_token.id === '(string)' || next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2370
            name = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2371
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2372
            if (next_token.id !== ':') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2373
                stop('expected_a_b', next_token, ':', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2374
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2375
            advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2376
            if (typeof jslint_limit[name] === 'number') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2377
                value = next_token.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2378
                if (value > jslint_limit[name] || value <= 0 ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2379
                        Math.floor(value) !== value) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2380
                    stop('expected_small_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2381
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2382
                option[name] = value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2383
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2384
                if (next_token.id === 'true') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2385
                    option[name] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2386
                } else if (next_token.id === 'false') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2387
                    option[name] = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2388
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2389
                    stop('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2390
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2391
                switch (name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2392
                case 'adsafe':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2393
                    option.safe = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2394
                    do_safe();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2395
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2396
                case 'safe':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2397
                    do_safe();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2398
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2399
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2400
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2401
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2402
            if (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2403
                advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2404
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2405
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2406
        assume();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2407
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2408
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2409
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2410
    function do_properties() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2411
        var name, type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2412
        option.properties = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2413
        if (!funct['(old_property_type)']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2414
            funct['(old_property_type)'] = property_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2415
            property_type = Object.create(property_type);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2416
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2417
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2418
            if (next_token.id !== '(string)' && !next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2419
                return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2420
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2421
            name = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2422
            type = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2423
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2424
            if (next_token.id === ':') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2425
                advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2426
                if (next_token.id === 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2427
                    advance('function');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2428
                    if (is_type[next_token.string] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2429
                        type = 'function ' + next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2430
                        advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2431
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2432
                        type = 'function';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2433
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2434
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2435
                    type = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2436
                    if (is_type[type] !== true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2437
                        warn('expected_type_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2438
                        type = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2439
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2440
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2441
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2442
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2443
            property_type[name] = type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2444
            if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2445
                return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2446
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2447
            advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2448
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2449
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2450
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2451
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2452
    directive = function directive() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2453
        var command = this.id,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2454
            old_comments_off = comments_off,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2455
            old_indent = indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2456
        comments_off = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2457
        indent = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2458
        if (next_token.line === token.line && next_token.from === token.thru) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2459
            warn('missing_space_a_b', next_token, artifact(token), artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2460
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2461
        if (lookahead.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2462
            warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2463
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2464
        switch (command) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2465
        case '/*properties':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2466
        case '/*property':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2467
        case '/*members':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2468
        case '/*member':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2469
            do_properties();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2470
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2471
        case '/*jslint':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2472
            if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2473
                warn('adsafe_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2474
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2475
            do_jslint();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2476
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2477
        case '/*globals':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2478
        case '/*global':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2479
            if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2480
                warn('adsafe_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2481
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2482
            do_globals();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2483
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2484
        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2485
            stop('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2486
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2487
        comments_off = old_comments_off;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2488
        advance('*/');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2489
        indent = old_indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2490
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2491
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2492
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2493
// Indentation intention
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2494
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2495
    function edge(mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2496
        next_token.edge = indent ? indent.open && (mode || 'edge') : '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2497
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2498
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2499
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2500
    function step_in(mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2501
        var open;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2502
        if (typeof mode === 'number') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2503
            indent = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2504
                at: +mode,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2505
                open: true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2506
                was: indent
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2507
            };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2508
        } else if (!indent) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2509
            indent = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2510
                at: 1,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2511
                mode: 'statement',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2512
                open: true
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2513
            };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2514
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2515
            open = mode === 'var' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2516
                (next_token.line !== token.line && mode !== 'statement');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2517
            indent = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2518
                at: (open || mode === 'control'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2519
                    ? indent.at + option.indent
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2520
                    : indent.at) + (indent.wrap ? option.indent : 0),
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2521
                mode: mode,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2522
                open: open,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2523
                was: indent
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2524
            };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2525
            if (mode === 'var' && open) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2526
                var_mode = indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2527
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2528
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2529
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2530
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2531
    function step_out(id, symbol) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2532
        if (id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2533
            if (indent && indent.open) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2534
                indent.at -= option.indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2535
                edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2536
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2537
            advance(id, symbol);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2538
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2539
        if (indent) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2540
            indent = indent.was;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2541
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2542
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2543
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2544
// Functions for conformance of whitespace.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2545
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2546
    function one_space(left, right) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2547
        left = left || token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2548
        right = right || next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2549
        if (right.id !== '(end)' && !option.white &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2550
                (token.line !== right.line ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2551
                token.thru + 1 !== right.from)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2552
            warn('expected_space_a_b', right, artifact(token), artifact(right));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2553
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2554
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2555
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2556
    function one_space_only(left, right) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2557
        left = left || token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2558
        right = right || next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2559
        if (right.id !== '(end)' && (left.line !== right.line ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2560
                (!option.white && left.thru + 1 !== right.from))) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2561
            warn('expected_space_a_b', right, artifact(left), artifact(right));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2562
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2563
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2564
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2565
    function no_space(left, right) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2566
        left = left || token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2567
        right = right || next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2568
        if ((!option.white || xmode === 'styleproperty' || xmode === 'style') &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2569
                left.thru !== right.from && left.line === right.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2570
            warn('unexpected_space_a_b', right, artifact(left), artifact(right));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2571
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2572
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2573
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2574
    function no_space_only(left, right) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2575
        left = left || token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2576
        right = right || next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2577
        if (right.id !== '(end)' && (left.line !== right.line ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2578
                (!option.white && left.thru !== right.from))) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2579
            warn('unexpected_space_a_b', right, artifact(left), artifact(right));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2580
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2581
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2582
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2583
    function spaces(left, right) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2584
        if (!option.white) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2585
            left = left || token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2586
            right = right || next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2587
            if (left.thru === right.from && left.line === right.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2588
                warn('missing_space_a_b', right, artifact(left), artifact(right));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2589
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2590
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2591
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2592
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2593
    function comma() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2594
        if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2595
            warn_at('expected_a_b', token.line, token.thru, ',', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2596
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2597
            if (!option.white) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2598
                no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2599
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2600
            advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2601
            spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2602
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2603
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2604
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2605
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2606
    function semicolon() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2607
        if (next_token.id !== ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2608
            warn_at('expected_a_b', token.line, token.thru, ';', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2609
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2610
            if (!option.white) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2611
                no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2612
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2613
            advance(';');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2614
            if (semicolon_coda[next_token.id] !== true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2615
                spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2616
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2617
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2618
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2619
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2620
    function use_strict() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2621
        if (next_token.string === 'use strict') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2622
            if (strict_mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2623
                warn('unnecessary_use');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2624
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2625
            edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2626
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2627
            semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2628
            strict_mode = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2629
            option.newcap = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2630
            option.undef = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2631
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2632
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2633
            return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2634
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2635
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2636
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2637
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2638
    function are_similar(a, b) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2639
        if (a === b) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2640
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2641
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2642
        if (Array.isArray(a)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2643
            if (Array.isArray(b) && a.length === b.length) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2644
                var i;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2645
                for (i = 0; i < a.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2646
                    if (!are_similar(a[i], b[i])) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2647
                        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2648
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2649
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2650
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2651
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2652
            return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2653
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2654
        if (Array.isArray(b)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2655
            return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2656
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2657
        if (a.id === '(number)' && b.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2658
            return a.number === b.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2659
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2660
        if (a.arity === b.arity && a.string === b.string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2661
            switch (a.arity) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2662
            case 'prefix':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2663
            case 'suffix':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2664
            case undefined:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2665
                return a.id === b.id && are_similar(a.first, b.first);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2666
            case 'infix':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2667
                return are_similar(a.first, b.first) &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2668
                    are_similar(a.second, b.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2669
            case 'ternary':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2670
                return are_similar(a.first, b.first) &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2671
                    are_similar(a.second, b.second) &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2672
                    are_similar(a.third, b.third);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2673
            case 'function':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2674
            case 'regexp':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2675
                return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2676
            default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2677
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2678
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2679
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2680
            if (a.id === '.' && b.id === '[' && b.arity === 'infix') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2681
                return a.second.string === b.second.string && b.second.id === '(string)';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2682
            } else if (a.id === '[' && a.arity === 'infix' && b.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2683
                return a.second.string === b.second.string && a.second.id === '(string)';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2684
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2685
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2686
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2687
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2688
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2689
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2690
// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2691
// is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2692
// like .nud except that it is only used on the first token of a statement.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2693
// Having .fud makes it much easier to define statement-oriented languages like
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2694
// JavaScript. I retained Pratt's nomenclature.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2695
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2696
// .nud     Null denotation
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2697
// .fud     First null denotation
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2698
// .led     Left denotation
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2699
//  lbp     Left binding power
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2700
//  rbp     Right binding power
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2701
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2702
// They are elements of the parsing method called Top Down Operator Precedence.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2703
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2704
    function expression(rbp, initial) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2705
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2706
// rbp is the right binding power.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2707
// initial indicates that this is the first expression of a statement.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2708
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2709
        var left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2710
        if (next_token.id === '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2711
            stop('unexpected_a', token, next_token.id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2712
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2713
        advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2714
        if (option.safe && scope[token.string] &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2715
                scope[token.string] === global_scope[token.string] &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2716
                (next_token.id !== '(' && next_token.id !== '.')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2717
            warn('adsafe_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2718
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2719
        if (initial) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2720
            anonname = 'anonymous';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2721
            funct['(verb)'] = token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2722
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2723
        if (initial === true && token.fud) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2724
            left = token.fud();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2725
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2726
            if (token.nud) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2727
                left = token.nud();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2728
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2729
                if (next_token.id === '(number)' && token.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2730
                    warn('leading_decimal_a', token, artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2731
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2732
                    return token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2733
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2734
                    stop('expected_identifier_a', token, token.id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2735
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2736
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2737
            while (rbp < next_token.lbp) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2738
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2739
                if (token.led) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2740
                    left = token.led(left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2741
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2742
                    stop('expected_operator_a', token, token.id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2743
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2744
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2745
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2746
        return left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2747
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2748
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2749
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2750
// Functional constructors for making the symbols that will be inherited by
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2751
// tokens.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2752
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2753
    function symbol(s, p) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2754
        var x = syntax[s];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2755
        if (!x || typeof x !== 'object') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2756
            syntax[s] = x = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2757
                id: s,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2758
                lbp: p || 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2759
                string: s
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2760
            };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2761
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2762
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2763
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2764
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2765
    function postscript(x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2766
        x.postscript = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2767
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2768
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2769
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2770
    function ultimate(s) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2771
        var x = symbol(s, 0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2772
        x.from = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2773
        x.thru = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2774
        x.line = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2775
        x.edge = 'edge';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2776
        s.string = s;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2777
        return postscript(x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2778
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2779
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2780
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2781
    function stmt(s, f) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2782
        var x = symbol(s);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2783
        x.identifier = x.reserved = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2784
        x.fud = f;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2785
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2786
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2787
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2788
    function labeled_stmt(s, f) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2789
        var x = stmt(s, f);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2790
        x.labeled = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2791
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2792
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2793
    function disrupt_stmt(s, f) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2794
        var x = stmt(s, f);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2795
        x.disrupt = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2796
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2797
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2798
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2799
    function reserve_name(x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2800
        var c = x.id.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2801
        if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2802
            x.identifier = x.reserved = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2803
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2804
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2805
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2806
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2807
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2808
    function prefix(s, f, type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2809
        var x = symbol(s, 150);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2810
        reserve_name(x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2811
        x.nud = typeof f === 'function'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2812
            ? f
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2813
            : function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2814
                if (s === 'typeof') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2815
                    one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2816
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2817
                    no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2818
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2819
                this.first = expression(150);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2820
                this.arity = 'prefix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2821
                if (this.id === '++' || this.id === '--') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2822
                    if (!option.plusplus) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2823
                        warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2824
                    } else if ((!this.first.identifier || this.first.reserved) &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2825
                            this.first.id !== '.' && this.first.id !== '[') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2826
                        warn('bad_operand', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2827
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2828
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2829
                this.type = type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2830
                return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2831
            };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2832
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2833
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2834
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2835
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2836
    function type(s, t, nud) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2837
        var x = symbol(s);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2838
        x.arity = x.type = t;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2839
        if (nud) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2840
            x.nud = nud;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2841
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2842
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2843
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2844
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2845
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2846
    function reserve(s, f) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2847
        var x = symbol(s);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2848
        x.identifier = x.reserved = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2849
        if (typeof f === 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2850
            x.nud = f;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2851
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2852
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2853
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2854
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2855
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2856
    function constant(name, type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2857
        var x = reserve(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2858
        x.type = type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2859
        x.string = name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2860
        x.nud = return_this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2861
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2862
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2863
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2864
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2865
    function reservevar(s, v) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2866
        return reserve(s, function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2867
            if (typeof v === 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2868
                v(this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2869
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2870
            return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2871
        });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2872
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2873
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2874
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2875
    function infix(s, p, f, type, w) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2876
        var x = symbol(s, p);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2877
        reserve_name(x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2878
        x.led = function (left) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2879
            this.arity = 'infix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2880
            if (!w) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2881
                spaces(prev_token, token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2882
                spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2883
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2884
            if (!option.bitwise && this.bitwise) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2885
                warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2886
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2887
            if (typeof f === 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2888
                return f(left, this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2889
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2890
                this.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2891
                this.second = expression(p);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2892
                return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2893
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2894
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2895
        if (type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2896
            x.type = type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2897
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2898
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2899
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2900
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2901
    function expected_relation(node, message) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2902
        if (node.assign) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2903
            warn(message || bundle.conditional_assignment, node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2904
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2905
        return node;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2906
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2907
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2908
    function expected_condition(node, message) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2909
        switch (node.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2910
        case '[':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2911
        case '-':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2912
            if (node.arity !== 'infix') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2913
                warn(message || bundle.weird_condition, node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2914
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2915
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2916
        case 'false':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2917
        case 'function':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2918
        case 'Infinity':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2919
        case 'NaN':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2920
        case 'null':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2921
        case 'true':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2922
        case 'undefined':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2923
        case 'void':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2924
        case '(number)':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2925
        case '(regexp)':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2926
        case '(string)':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2927
        case '{':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2928
            warn(message || bundle.weird_condition, node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2929
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2930
        case '(':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2931
            if (node.first.id === '.' && numbery[node.first.second.string] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2932
                warn(message || bundle.weird_condition, node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2933
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2934
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2935
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2936
        return node;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2937
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2938
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2939
    function check_relation(node) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2940
        switch (node.arity) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2941
        case 'prefix':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2942
            switch (node.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2943
            case '{':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2944
            case '[':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2945
                warn('unexpected_a', node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2946
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2947
            case '!':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2948
                warn('confusing_a', node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2949
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2950
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2951
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2952
        case 'function':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2953
        case 'regexp':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2954
            warn('unexpected_a', node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2955
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2956
        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2957
            if (node.id  === 'NaN') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2958
                warn('isnan', node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2959
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2960
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2961
        return node;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2962
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2963
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2964
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2965
    function relation(s, eqeq) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2966
        return infix(s, 100, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2967
            check_relation(left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2968
            if (eqeq && !option.eqeq) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2969
                warn('expected_a_b', that, eqeq, that.id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2970
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2971
            var right = expression(100);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2972
            if (are_similar(left, right) ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2973
                    ((left.id === '(string)' || left.id === '(number)') &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2974
                    (right.id === '(string)' || right.id === '(number)'))) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2975
                warn('weird_relation', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2976
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2977
            that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2978
            that.second = check_relation(right);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2979
            return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2980
        }, 'boolean');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2981
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2982
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2983
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2984
    function assignop(s, op) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2985
        var x = infix(s, 20, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2986
            var l;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2987
            that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2988
            if (left.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2989
                if (scope[left.string]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2990
                    if (scope[left.string].writeable === false) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2991
                        warn('read_only', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2992
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2993
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2994
                    stop('read_only');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2995
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2996
            } else if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2997
                l = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2998
                do {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  2999
                    if (typeof predefined[l.string] === 'boolean') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3000
                        warn('adsafe_a', l);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3001
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3002
                    l = l.first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3003
                } while (l);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3004
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3005
            if (left === syntax['function']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3006
                warn('identifier_function', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3007
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3008
            if (left.id === '.' || left.id === '[') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3009
                if (!left.first || left.first.string === 'arguments') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3010
                    warn('bad_assignment', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3011
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3012
            } else if (left.identifier && !left.reserved) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3013
                if (funct[left.string] === 'exception') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3014
                    warn('assign_exception', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3015
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3016
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3017
            that.second = expression(19);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3018
            if (that.id === '=' && are_similar(that.first, that.second)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3019
                warn('weird_assignment', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3020
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3021
            return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3022
        });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3023
        x.assign = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3024
        if (op) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3025
            if (syntax[op].type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3026
                x.type = syntax[op].type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3027
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3028
            if (syntax[op].bitwise) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3029
                x.bitwise = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3030
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3031
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3032
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3033
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3034
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3035
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3036
    function bitwise(s, p) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3037
        var x = infix(s, p, 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3038
        x.bitwise = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3039
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3040
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3041
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3042
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3043
    function suffix(s) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3044
        var x = symbol(s, 150);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3045
        x.led = function (left) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3046
            no_space_only(prev_token, token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3047
            if (!option.plusplus) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3048
                warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3049
            } else if ((!left.identifier || left.reserved) &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3050
                    left.id !== '.' && left.id !== '[') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3051
                warn('bad_operand', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3052
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3053
            this.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3054
            this.arity = 'suffix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3055
            return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3056
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3057
        return x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3058
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3059
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3060
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3061
    function optional_identifier() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3062
        if (next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3063
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3064
            if (option.safe && banned[token.string]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3065
                warn('adsafe_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3066
            } else if (token.reserved && !option.es5) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3067
                warn('expected_identifier_a_reserved', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3068
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3069
            return token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3070
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3071
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3072
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3073
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3074
    function identifier() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3075
        var i = optional_identifier();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3076
        if (!i) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3077
            stop(token.id === 'function' && next_token.id === '('
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3078
                ? 'name_function'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3079
                : 'expected_identifier_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3080
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3081
        return i;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3082
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3083
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3084
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3085
    function statement() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3086
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3087
        var label, old_scope = scope, the_statement;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3088
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3089
// We don't like the empty statement.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3090
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3091
        if (next_token.id === ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3092
            warn('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3093
            semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3094
            return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3095
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3096
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3097
// Is this a labeled statement?
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3098
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3099
        if (next_token.identifier && !next_token.reserved && peek().id === ':') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3100
            edge('label');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3101
            label = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3102
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3103
            advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3104
            scope = Object.create(old_scope);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3105
            add_label(label, 'label');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3106
            if (next_token.labeled !== true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3107
                warn('label_a_b', next_token, label.string, artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3108
            } else if (jx.test(label.string + ':')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3109
                warn('url', label);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3110
            } else if (funct === global_funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3111
                stop('unexpected_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3112
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3113
            next_token.label = label;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3114
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3115
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3116
// Parse the statement.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3117
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3118
        edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3119
        step_in('statement');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3120
        the_statement = expression(0, true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3121
        if (the_statement) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3122
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3123
// Look for the final semicolon.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3124
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3125
            if (the_statement.arity === 'statement') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3126
                if (the_statement.id === 'switch' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3127
                        (the_statement.block && the_statement.id !== 'do')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3128
                    spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3129
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3130
                    semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3131
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3132
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3133
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3134
// If this is an expression statement, determine if it is acceptable.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3135
// We do not like
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3136
//      new Blah();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3137
// statments. If it is to be used at all, new should only be used to make
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3138
// objects, not side effects. The expression statements we do like do
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3139
// assignment or invocation or delete.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3140
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3141
                if (the_statement.id === '(') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3142
                    if (the_statement.first.id === 'new') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3143
                        warn('bad_new');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3144
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3145
                } else if (!the_statement.assign &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3146
                        the_statement.id !== 'delete' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3147
                        the_statement.id !== '++' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3148
                        the_statement.id !== '--') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3149
                    warn('assignment_function_expression', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3150
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3151
                semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3152
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3153
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3154
        step_out();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3155
        scope = old_scope;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3156
        return the_statement;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3157
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3158
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3159
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3160
    function statements() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3161
        var array = [], disruptor, the_statement;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3162
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3163
// A disrupt statement may not be followed by any other statement.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3164
// If the last statement is disrupt, then the sequence is disrupt.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3165
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3166
        while (next_token.postscript !== true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3167
            if (next_token.id === ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3168
                warn('unexpected_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3169
                semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3170
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3171
                if (next_token.string === 'use strict') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3172
                    if ((!node_js && xmode !== 'script') || funct !== global_funct || array.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3173
                        warn('function_strict');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3174
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3175
                    use_strict();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3176
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3177
                if (disruptor) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3178
                    warn('unreachable_a_b', next_token, next_token.string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3179
                        disruptor.string);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3180
                    disruptor = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3181
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3182
                the_statement = statement();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3183
                if (the_statement) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3184
                    array.push(the_statement);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3185
                    if (the_statement.disrupt) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3186
                        disruptor = the_statement;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3187
                        array.disrupt = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3188
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3189
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3190
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3191
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3192
        return array;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3193
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3194
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3195
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3196
    function block(ordinary) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3197
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3198
// array block is array sequence of statements wrapped in braces.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3199
// ordinary is false for function bodies and try blocks.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3200
// ordinary is true for if statements, while, etc.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3201
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3202
        var array,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3203
            curly = next_token,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3204
            old_in_block = in_block,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3205
            old_scope = scope,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3206
            old_strict_mode = strict_mode;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3207
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3208
        in_block = ordinary;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3209
        scope = Object.create(scope);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3210
        spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3211
        if (next_token.id === '{') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3212
            advance('{');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3213
            step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3214
            if (!ordinary && !use_strict() && !old_strict_mode &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3215
                    !option.sloppy && funct['(context)'] === global_funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3216
                warn('missing_use_strict');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3217
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3218
            array = statements();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3219
            strict_mode = old_strict_mode;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3220
            step_out('}', curly);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3221
        } else if (!ordinary) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3222
            stop('expected_a_b', next_token, '{', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3223
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3224
            warn('expected_a_b', next_token, '{', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3225
            array = [statement()];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3226
            array.disrupt = array[0].disrupt;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3227
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3228
        funct['(verb)'] = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3229
        scope = old_scope;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3230
        in_block = old_in_block;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3231
        if (ordinary && array.length === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3232
            warn('empty_block');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3233
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3234
        return array;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3235
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3236
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3237
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3238
    function tally_property(name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3239
        if (option.properties && typeof property_type[name] !== 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3240
            warn('unexpected_property_a', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3241
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3242
        if (typeof member[name] === 'number') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3243
            member[name] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3244
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3245
            member[name] = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3246
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3247
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3248
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3249
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3250
// ECMAScript parser
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3251
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3252
    syntax['(identifier)'] = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3253
        id: '(identifier)',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3254
        lbp: 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3255
        identifier: true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3256
        nud: function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3257
            var name = this.string,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3258
                variable = scope[name],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3259
                site,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3260
                writeable;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3261
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3262
// If the variable is not in scope, then we may have an undeclared variable.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3263
// Check the predefined list. If it was predefined, create the global
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3264
// variable.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3265
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3266
            if (typeof variable !== 'object') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3267
                writeable = predefined[name];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3268
                if (typeof writeable === 'boolean') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3269
                    global_scope[name] = variable = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3270
                        string:    name,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3271
                        writeable: writeable,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3272
                        funct:     global_funct
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3273
                    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3274
                    global_funct[name] = 'var';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3275
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3276
// But if the variable is not in scope, and is not predefined, and if we are not
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3277
// in the global scope, then we have an undefined variable error.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3278
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3279
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3280
                    if (!option.undef) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3281
                        warn('used_before_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3282
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3283
                    scope[name] = variable = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3284
                        string: name,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3285
                        writeable: true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3286
                        funct: funct
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3287
                    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3288
                    funct[name] = 'undef';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3289
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3290
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3291
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3292
            site = variable.funct;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3293
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3294
// The name is in scope and defined in the current function.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3295
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3296
            if (funct === site) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3297
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3298
//      Change 'unused' to 'var', and reject labels.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3299
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3300
                switch (funct[name]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3301
                case 'becoming':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3302
                    warn('unexpected_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3303
                    funct[name] = 'var';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3304
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3305
                case 'unused':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3306
                    funct[name] = 'var';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3307
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3308
                case 'unparam':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3309
                    funct[name] = 'parameter';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3310
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3311
                case 'unction':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3312
                    funct[name] = 'function';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3313
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3314
                case 'label':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3315
                    warn('a_label', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3316
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3317
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3318
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3319
// If the name is already defined in the current
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3320
// function, but not as outer, then there is a scope error.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3321
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3322
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3323
                switch (funct[name]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3324
                case 'closure':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3325
                case 'function':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3326
                case 'var':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3327
                case 'unused':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3328
                    warn('a_scope', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3329
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3330
                case 'label':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3331
                    warn('a_label', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3332
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3333
                case 'outer':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3334
                case 'global':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3335
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3336
                default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3337
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3338
// If the name is defined in an outer function, make an outer entry, and if
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3339
// it was unused, make it var.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3340
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3341
                    switch (site[name]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3342
                    case 'becoming':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3343
                    case 'closure':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3344
                    case 'function':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3345
                    case 'parameter':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3346
                    case 'unction':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3347
                    case 'unused':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3348
                    case 'var':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3349
                        site[name] = 'closure';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3350
                        funct[name] = site === global_funct
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3351
                            ? 'global'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3352
                            : 'outer';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3353
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3354
                    case 'unparam':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3355
                        site[name] = 'parameter';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3356
                        funct[name] = 'outer';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3357
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3358
                    case 'undef':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3359
                        funct[name] = 'undef';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3360
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3361
                    case 'label':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3362
                        warn('a_label', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3363
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3364
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3365
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3366
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3367
            return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3368
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3369
        led: function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3370
            stop('expected_operator_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3371
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3372
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3373
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3374
// Build the syntax table by declaring the syntactic elements.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3375
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3376
    type('(array)', 'array');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3377
    type('(color)', 'color');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3378
    type('(function)', 'function');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3379
    type('(number)', 'number', return_this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3380
    type('(object)', 'object');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3381
    type('(string)', 'string', return_this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3382
    type('(boolean)', 'boolean', return_this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3383
    type('(range)', 'range');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3384
    type('(regexp)', 'regexp', return_this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3385
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3386
    ultimate('(begin)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3387
    ultimate('(end)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3388
    ultimate('(error)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3389
    postscript(symbol('</'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3390
    symbol('<!');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3391
    symbol('<!--');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3392
    symbol('-->');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3393
    postscript(symbol('}'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3394
    symbol(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3395
    symbol(']');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3396
    postscript(symbol('"'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3397
    postscript(symbol('\''));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3398
    symbol(';');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3399
    symbol(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3400
    symbol(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3401
    symbol('#');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3402
    symbol('@');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3403
    symbol('*/');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3404
    postscript(reserve('case'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3405
    reserve('catch');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3406
    postscript(reserve('default'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3407
    reserve('else');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3408
    reserve('finally');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3409
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3410
    reservevar('arguments', function (x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3411
        if (strict_mode && funct === global_funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3412
            warn('strict', x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3413
        } else if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3414
            warn('adsafe_a', x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3415
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3416
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3417
    reservevar('eval', function (x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3418
        if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3419
            warn('adsafe_a', x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3420
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3421
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3422
    constant('false', 'boolean');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3423
    constant('Infinity', 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3424
    constant('NaN', 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3425
    constant('null', '');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3426
    reservevar('this', function (x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3427
        if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3428
            warn('adsafe_a', x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3429
        } else if (strict_mode && funct['(token)'].arity === 'statement' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3430
                funct['(name)'].charAt(0) > 'Z') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3431
            warn('strict', x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3432
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3433
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3434
    constant('true', 'boolean');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3435
    constant('undefined', '');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3436
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3437
    infix('?', 30, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3438
        step_in('?');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3439
        that.first = expected_condition(expected_relation(left));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3440
        that.second = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3441
        spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3442
        step_out();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3443
        var colon = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3444
        advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3445
        step_in(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3446
        spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3447
        that.third = expression(10);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3448
        that.arity = 'ternary';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3449
        if (are_similar(that.second, that.third)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3450
            warn('weird_ternary', colon);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3451
        } else if (are_similar(that.first, that.second)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3452
            warn('use_or', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3453
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3454
        step_out();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3455
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3456
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3457
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3458
    infix('||', 40, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3459
        function paren_check(that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3460
            if (that.id === '&&' && !that.paren) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3461
                warn('and', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3462
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3463
            return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3464
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3465
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3466
        that.first = paren_check(expected_condition(expected_relation(left)));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3467
        that.second = paren_check(expected_relation(expression(40)));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3468
        if (are_similar(that.first, that.second)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3469
            warn('weird_condition', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3470
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3471
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3472
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3473
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3474
    infix('&&', 50, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3475
        that.first = expected_condition(expected_relation(left));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3476
        that.second = expected_relation(expression(50));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3477
        if (are_similar(that.first, that.second)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3478
            warn('weird_condition', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3479
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3480
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3481
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3482
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3483
    prefix('void', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3484
        this.first = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3485
        this.arity = 'prefix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3486
        if (option.es5) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3487
            warn('expected_a_b', this, 'undefined', 'void');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3488
        } else if (this.first.number !== 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3489
            warn('expected_a_b', this.first, '0', artifact(this.first));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3490
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3491
        this.type = 'undefined';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3492
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3493
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3494
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3495
    bitwise('|', 70);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3496
    bitwise('^', 80);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3497
    bitwise('&', 90);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3498
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3499
    relation('==', '===');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3500
    relation('===');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3501
    relation('!=', '!==');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3502
    relation('!==');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3503
    relation('<');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3504
    relation('>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3505
    relation('<=');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3506
    relation('>=');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3507
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3508
    bitwise('<<', 120);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3509
    bitwise('>>', 120);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3510
    bitwise('>>>', 120);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3511
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3512
    infix('in', 120, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3513
        warn('infix_in', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3514
        that.left = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3515
        that.right = expression(130);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3516
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3517
    }, 'boolean');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3518
    infix('instanceof', 120, null, 'boolean');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3519
    infix('+', 130, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3520
        if (left.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3521
            if (left.number === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3522
                warn('unexpected_a', left, '0');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3523
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3524
        } else if (left.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3525
            if (left.string === '') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3526
                warn('expected_a_b', left, 'String', '\'\'');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3527
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3528
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3529
        var right = expression(130);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3530
        if (right.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3531
            if (right.number === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3532
                warn('unexpected_a', right, '0');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3533
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3534
        } else if (right.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3535
            if (right.string === '') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3536
                warn('expected_a_b', right, 'String', '\'\'');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3537
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3538
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3539
        if (left.id === right.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3540
            if (left.id === '(string)' || left.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3541
                if (left.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3542
                    left.string += right.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3543
                    if (jx.test(left.string)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3544
                        warn('url', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3545
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3546
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3547
                    left.number += right.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3548
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3549
                left.thru = right.thru;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3550
                return left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3551
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3552
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3553
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3554
        that.second = right;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3555
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3556
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3557
    prefix('+', 'num');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3558
    prefix('+++', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3559
        warn('confusing_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3560
        this.first = expression(150);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3561
        this.arity = 'prefix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3562
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3563
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3564
    infix('+++', 130, function (left) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3565
        warn('confusing_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3566
        this.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3567
        this.second = expression(130);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3568
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3569
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3570
    infix('-', 130, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3571
        if ((left.id === '(number)' && left.number === 0) || left.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3572
            warn('unexpected_a', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3573
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3574
        var right = expression(130);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3575
        if ((right.id === '(number)' && right.number === 0) || right.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3576
            warn('unexpected_a', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3577
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3578
        if (left.id === right.id && left.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3579
            left.number -= right.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3580
            left.thru = right.thru;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3581
            return left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3582
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3583
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3584
        that.second = right;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3585
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3586
    }, 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3587
    prefix('-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3588
    prefix('---', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3589
        warn('confusing_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3590
        this.first = expression(150);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3591
        this.arity = 'prefix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3592
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3593
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3594
    infix('---', 130, function (left) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3595
        warn('confusing_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3596
        this.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3597
        this.second = expression(130);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3598
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3599
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3600
    infix('*', 140, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3601
        if ((left.id === '(number)' && (left.number === 0 || left.number === 1)) || left.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3602
            warn('unexpected_a', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3603
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3604
        var right = expression(140);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3605
        if ((right.id === '(number)' && (right.number === 0 || right.number === 1)) || right.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3606
            warn('unexpected_a', right);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3607
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3608
        if (left.id === right.id && left.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3609
            left.number *= right.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3610
            left.thru = right.thru;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3611
            return left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3612
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3613
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3614
        that.second = right;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3615
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3616
    }, 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3617
    infix('/', 140, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3618
        if ((left.id === '(number)' && left.number === 0) || left.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3619
            warn('unexpected_a', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3620
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3621
        var right = expression(140);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3622
        if ((right.id === '(number)' && (right.number === 0 || right.number === 1)) || right.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3623
            warn('unexpected_a', right);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3624
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3625
        if (left.id === right.id && left.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3626
            left.number /= right.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3627
            left.thru = right.thru;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3628
            return left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3629
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3630
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3631
        that.second = right;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3632
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3633
    }, 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3634
    infix('%', 140, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3635
        if ((left.id === '(number)' && (left.number === 0 || left.number === 1)) || left.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3636
            warn('unexpected_a', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3637
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3638
        var right = expression(140);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3639
        if ((right.id === '(number)' && right.number === 0) || right.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3640
            warn('unexpected_a', right);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3641
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3642
        if (left.id === right.id && left.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3643
            left.number %= right.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3644
            left.thru = right.thru;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3645
            return left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3646
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3647
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3648
        that.second = right;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3649
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3650
    }, 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3651
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3652
    suffix('++');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3653
    prefix('++');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3654
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3655
    suffix('--');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3656
    prefix('--');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3657
    prefix('delete', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3658
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3659
        var p = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3660
        if (!p || (p.id !== '.' && p.id !== '[')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3661
            warn('deleted');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3662
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3663
        this.first = p;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3664
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3665
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3666
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3667
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3668
    prefix('~', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3669
        no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3670
        if (!option.bitwise) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3671
            warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3672
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3673
        expression(150);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3674
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3675
    }, 'number');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3676
    prefix('!', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3677
        no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3678
        this.first = expected_condition(expression(150));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3679
        this.arity = 'prefix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3680
        if (bang[this.first.id] === true || this.first.assign) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3681
            warn('confusing_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3682
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3683
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3684
    }, 'boolean');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3685
    prefix('typeof', null, 'string');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3686
    prefix('new', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3687
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3688
        var c = expression(160), n, p, v;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3689
        this.first = c;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3690
        if (c.id !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3691
            if (c.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3692
                switch (c.string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3693
                case 'Object':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3694
                    warn('use_object', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3695
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3696
                case 'Array':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3697
                    if (next_token.id === '(') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3698
                        p = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3699
                        p.first = this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3700
                        advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3701
                        if (next_token.id !== ')') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3702
                            n = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3703
                            p.second = [n];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3704
                            if (n.type !== 'number' || next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3705
                                warn('use_array', p);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3706
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3707
                            while (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3708
                                advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3709
                                p.second.push(expression(0));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3710
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3711
                        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3712
                            warn('use_array', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3713
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3714
                        advance(')', p);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3715
                        return p;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3716
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3717
                    warn('use_array', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3718
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3719
                case 'Number':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3720
                case 'String':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3721
                case 'Boolean':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3722
                case 'Math':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3723
                case 'JSON':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3724
                    warn('not_a_constructor', c);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3725
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3726
                case 'Function':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3727
                    if (!option.evil) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3728
                        warn('function_eval');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3729
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3730
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3731
                case 'Date':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3732
                case 'RegExp':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3733
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3734
                default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3735
                    if (c.id !== 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3736
                        v = c.string.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3737
                        if (!option.newcap && (v < 'A' || v > 'Z')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3738
                            warn('constructor_name_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3739
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3740
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3741
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3742
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3743
                if (c.id !== '.' && c.id !== '[' && c.id !== '(') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3744
                    warn('bad_constructor', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3745
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3746
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3747
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3748
            warn('weird_new', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3749
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3750
        if (next_token.id !== '(') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3751
            warn('missing_a', next_token, '()');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3752
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3753
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3754
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3755
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3756
    infix('(', 160, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3757
        var p;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3758
        if (indent && indent.mode === 'expression') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3759
            no_space(prev_token, token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3760
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3761
            no_space_only(prev_token, token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3762
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3763
        if (!left.immed && left.id === 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3764
            warn('wrap_immediate');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3765
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3766
        p = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3767
        if (left.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3768
            if (left.string.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3769
                if (left.string !== 'Number' && left.string !== 'String' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3770
                        left.string !== 'Boolean' && left.string !== 'Date') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3771
                    if (left.string === 'Math' || left.string === 'JSON') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3772
                        warn('not_a_function', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3773
                    } else if (left.string === 'Object') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3774
                        warn('use_object', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3775
                    } else if (left.string === 'Array' || !option.newcap) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3776
                        warn('missing_a', left, 'new');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3777
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3778
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3779
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3780
        } else if (left.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3781
            if (option.safe && left.first.string === 'Math' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3782
                    left.second === 'random') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3783
                warn('adsafe_a', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3784
            } else if (left.second.string === 'split' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3785
                    left.first.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3786
                warn('use_array', left.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3787
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3788
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3789
        step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3790
        if (next_token.id !== ')') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3791
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3792
            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3793
                edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3794
                p.push(expression(10));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3795
                if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3796
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3797
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3798
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3799
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3800
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3801
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3802
        step_out(')', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3803
        if (typeof left === 'object') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3804
            if (left.string === 'parseInt' && p.length === 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3805
                warn('radix', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3806
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3807
            if (!option.evil) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3808
                if (left.string === 'eval' || left.string === 'Function' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3809
                        left.string === 'execScript') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3810
                    warn('evil', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3811
                } else if (p[0] && p[0].id === '(string)' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3812
                        (left.string === 'setTimeout' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3813
                        left.string === 'setInterval')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3814
                    warn('implied_evil', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3815
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3816
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3817
            if (!left.identifier && left.id !== '.' && left.id !== '[' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3818
                    left.id !== '(' && left.id !== '&&' && left.id !== '||' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3819
                    left.id !== '?') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3820
                warn('bad_invocation', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3821
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3822
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3823
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3824
        that.second = p;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3825
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3826
    }, '', true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3827
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3828
    prefix('(', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3829
        step_in('expression');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3830
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3831
        edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3832
        if (next_token.id === 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3833
            next_token.immed = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3834
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3835
        var value = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3836
        value.paren = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3837
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3838
        step_out(')', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3839
        if (value.id === 'function') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3840
            if (next_token.id === '(') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3841
                warn('move_invocation');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3842
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3843
                warn('bad_wrap', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3844
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3845
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3846
        return value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3847
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3848
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3849
    infix('.', 170, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3850
        no_space(prev_token, token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3851
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3852
        var name = identifier(), type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3853
        if (typeof name === 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3854
            tally_property(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3855
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3856
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3857
        that.second = token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3858
        if (left && left.string === 'arguments' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3859
                (name === 'callee' || name === 'caller')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3860
            warn('avoid_a', left, 'arguments.' + name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3861
        } else if (!option.evil && left && left.string === 'document' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3862
                (name === 'write' || name === 'writeln')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3863
            warn('write_is_wrong', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3864
        } else if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3865
            if (!adsafe_top && left.string === 'ADSAFE') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3866
                if (name === 'id' || name === 'lib') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3867
                    warn('adsafe_a', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3868
                } else if (name === 'go') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3869
                    if (xmode !== 'script') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3870
                        warn('adsafe_a', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3871
                    } else if (adsafe_went || next_token.id !== '(' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3872
                            peek(0).id !== '(string)' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3873
                            peek(0).string !== adsafe_id ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3874
                            peek(1).id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3875
                        stop('adsafe_a', that, 'go');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3876
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3877
                    adsafe_went = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3878
                    adsafe_may = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3879
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3880
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3881
            adsafe_top = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3882
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3883
        if (!option.evil && (name === 'eval' || name === 'execScript')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3884
            warn('evil');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3885
        } else if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3886
            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3887
                if (banned[name] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3888
                    warn('adsafe_a', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3889
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3890
                if (typeof predefined[left.string] !== 'boolean' ||    //// check for writeable
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3891
                        next_token.id === '(') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3892
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3893
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3894
                if (next_token.id !== '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3895
                    warn('adsafe_a', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3896
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3897
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3898
                advance('.');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3899
                token.first = that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3900
                token.second = name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3901
                that = token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3902
                name = identifier();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3903
                if (typeof name === 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3904
                    tally_property(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3905
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3906
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3907
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3908
        type = property_type[name];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3909
        if (type && typeof type === 'string' && type !== '*') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3910
            that.type = type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3911
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3912
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3913
    }, '', true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3914
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3915
    infix('[', 170, function (left, that) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3916
        var e, s;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3917
        no_space_only(prev_token, token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3918
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3919
        step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3920
        edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3921
        e = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3922
        switch (e.type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3923
        case 'number':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3924
            if (e.id === '(number)' && left.id === 'arguments') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3925
                warn('use_param', left);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3926
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3927
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3928
        case 'string':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3929
            if (e.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3930
                if (option.safe && (banned[e.string] ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3931
                        e.string.charAt(0) === '_' || e.string.slice(-1) === '_')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3932
                    warn('adsafe_subscript_a', e);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3933
                } else if (!option.evil &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3934
                        (e.string === 'eval' || e.string === 'execScript')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3935
                    warn('evil', e);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3936
                } else if (!option.sub && ix.test(e.string)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3937
                    s = syntax[e.string];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3938
                    if (!s || !s.reserved) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3939
                        warn('subscript', e);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3940
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3941
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3942
                tally_property(e.string);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3943
            } else if (option.safe && e.id !== 'typeof') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3944
                warn('adsafe_subscript_a', e);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3945
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3946
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3947
        case undefined:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3948
            if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3949
                warn('adsafe_subscript_a', e);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3950
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3951
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3952
        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3953
            if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3954
                warn('adsafe_subscript_a', e);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3955
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3956
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3957
        step_out(']', that);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3958
        no_space(prev_token, token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3959
        that.first = left;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3960
        that.second = e;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3961
        return that;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3962
    }, '', true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3963
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3964
    prefix('[', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3965
        this.arity = 'prefix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3966
        this.first = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3967
        step_in('array');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3968
        while (next_token.id !== '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3969
            while (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3970
                warn('unexpected_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3971
                advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3972
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3973
            if (next_token.id === ']') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3974
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3975
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3976
            indent.wrap = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3977
            edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3978
            this.first.push(expression(10));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3979
            if (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3980
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3981
                if (next_token.id === ']' && !option.es5) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3982
                    warn('unexpected_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3983
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3984
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3985
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3986
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3987
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3988
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3989
        step_out(']', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3990
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3991
    }, 170);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3992
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3993
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3994
    function property_name() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3995
        var id = optional_identifier(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3996
        if (!id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3997
            if (next_token.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3998
                id = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  3999
                if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4000
                    if (banned[id]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4001
                        warn('adsafe_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4002
                    } else if (id.charAt(0) === '_' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4003
                            id.charAt(id.length - 1) === '_') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4004
                        warn('dangling_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4005
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4006
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4007
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4008
            } else if (next_token.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4009
                id = next_token.number.toString();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4010
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4011
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4012
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4013
        return id;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4014
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4015
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4016
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4017
    function function_params() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4018
        var id, paren = next_token, params = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4019
        advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4020
        step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4021
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4022
        if (next_token.id === ')') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4023
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4024
            step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4025
            return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4026
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4027
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4028
            edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4029
            id = identifier();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4030
            params.push(token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4031
            add_label(token, option.unparam ? 'parameter' : 'unparam');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4032
            if (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4033
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4034
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4035
                no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4036
                step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4037
                return params;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4038
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4039
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4040
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4041
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4042
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4043
    function complexity(exp) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4044
        var score = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4045
        if (exp) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4046
            if (Array.isArray(exp)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4047
                exp.forEach(function (tok) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4048
                    score += complexity(tok);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4049
                });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4050
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4051
                switch (exp.arity) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4052
                case 'statement':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4053
                    switch (exp.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4054
                    case 'if':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4055
                        score += complexity(exp.first) + complexity(exp.block) +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4056
                            complexity(exp['else']) + 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4057
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4058
                    case 'while':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4059
                    case 'do':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4060
                        if (exp.first.id !== 'true' && exp.first.number !== 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4061
                            score += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4062
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4063
                        score += complexity(exp.first) + complexity(exp.block);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4064
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4065
                    case 'for':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4066
                        if (exp.second !== undefined &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4067
                                exp.second.id !== 'true' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4068
                                exp.second.number !== 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4069
                            score += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4070
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4071
                        score += complexity(exp.first) + complexity(exp.second) +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4072
                            complexity(exp.third) + complexity(exp.block);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4073
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4074
                    case 'switch':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4075
                        score += complexity(exp.first) +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4076
                            complexity(exp.second) + exp.second.length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4077
                        if (exp.second[exp.second.length - 1].id === 'default') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4078
                            score -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4079
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4080
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4081
                    case 'try':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4082
                        if (exp.second) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4083
                            score += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4084
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4085
                        if (exp.third) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4086
                            score += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4087
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4088
                        score += complexity(exp.first) + complexity(exp.second) +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4089
                            complexity(exp.third) + complexity(exp.block);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4090
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4091
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4092
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4093
                case 'prefix':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4094
                    score += complexity(exp.first);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4095
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4096
                case 'case':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4097
                case 'infix':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4098
                    score += complexity(exp.first) + complexity(exp.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4099
                    if (exp.id === '&&' || exp.id === '||') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4100
                        score += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4101
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4102
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4103
                case 'ternary':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4104
                    score += complexity(exp.first) + complexity(exp.second) + complexity(exp.third);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4105
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4106
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4107
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4108
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4109
        return score;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4110
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4111
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4112
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4113
    function do_function(func, name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4114
        var old_funct      = funct,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4115
            old_option     = option,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4116
            old_scope      = scope;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4117
        funct = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4118
            '(name)'     : name || '\'' + (anonname || '').replace(nx, sanitize) + '\'',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4119
            '(line)'     : next_token.line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4120
            '(context)'  : old_funct,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4121
            '(breakage)' : 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4122
            '(loopage)'  : 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4123
            '(scope)'    : scope,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4124
            '(token)'    : func
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4125
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4126
        option = Object.create(old_option);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4127
        scope = Object.create(old_scope);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4128
        functions.push(funct);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4129
        func.name = name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4130
        if (name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4131
            add_label(func, 'function', name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4132
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4133
        func.writeable = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4134
        func.first = funct['(params)'] = function_params();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4135
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4136
        func.block = block(false);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4137
        if (funct['(old_property_type)']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4138
            property_type = funct['(old_property_type)'];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4139
            delete funct['(old_property_type)'];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4140
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4141
        funct['(complexity)'] = complexity(func.block) + 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4142
        if (option.confusion) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4143
            funct['(confusion)'] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4144
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4145
        funct      = old_funct;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4146
        option     = old_option;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4147
        scope      = old_scope;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4148
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4149
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4150
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4151
    assignop('=');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4152
    assignop('+=', '+');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4153
    assignop('-=', '-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4154
    assignop('*=', '*');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4155
    assignop('/=', '/').nud = function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4156
        stop('slash_equal');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4157
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4158
    assignop('%=', '%');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4159
    assignop('&=', '&');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4160
    assignop('|=', '|');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4161
    assignop('^=', '^');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4162
    assignop('<<=', '<<');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4163
    assignop('>>=', '>>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4164
    assignop('>>>=', '>>>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4165
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4166
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4167
    prefix('{', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4168
        var get, i, j, name, p, set, seen = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4169
        this.arity = 'prefix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4170
        this.first = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4171
        step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4172
        while (next_token.id !== '}') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4173
            indent.wrap = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4174
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4175
// JSLint recognizes the ES5 extension for get/set in object literals,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4176
// but requires that they be used in pairs.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4177
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4178
            edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4179
            if (next_token.string === 'get' && peek().id !== ':') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4180
                if (!option.es5) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4181
                    warn('es5');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4182
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4183
                get = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4184
                advance('get');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4185
                one_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4186
                name = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4187
                i = property_name();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4188
                if (!i) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4189
                    stop('missing_property');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4190
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4191
                get.string = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4192
                do_function(get);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4193
                if (funct['(loopage)']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4194
                    warn('function_loop', get);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4195
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4196
                p = get.first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4197
                if (p) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4198
                    warn('parameter_a_get_b', p[0], p[0].string, i);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4199
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4200
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4201
                set = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4202
                spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4203
                edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4204
                advance('set');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4205
                set.string = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4206
                one_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4207
                j = property_name();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4208
                if (i !== j) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4209
                    stop('expected_a_b', token, i, j || next_token.string);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4210
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4211
                do_function(set);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4212
                p = set.first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4213
                if (!p || p.length !== 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4214
                    stop('parameter_set_a', set, 'value');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4215
                } else if (p[0].string !== 'value') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4216
                    stop('expected_a_b', p[0], 'value', p[0].string);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4217
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4218
                name.first = [get, set];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4219
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4220
                name = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4221
                i = property_name();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4222
                if (typeof i !== 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4223
                    stop('missing_property');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4224
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4225
                advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4226
                spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4227
                name.first = expression(10);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4228
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4229
            this.first.push(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4230
            if (seen[i] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4231
                warn('duplicate_a', next_token, i);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4232
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4233
            seen[i] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4234
            tally_property(i);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4235
            if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4236
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4237
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4238
            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4239
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4240
                if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4241
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4242
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4243
                warn('unexpected_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4244
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4245
            if (next_token.id === '}' && !option.es5) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4246
                warn('unexpected_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4247
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4248
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4249
        step_out('}', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4250
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4251
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4252
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4253
    stmt('{', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4254
        warn('statement_block');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4255
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4256
        this.block = statements();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4257
        this.disrupt = this.block.disrupt;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4258
        advance('}', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4259
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4260
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4261
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4262
    stmt('/*global', directive);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4263
    stmt('/*globals', directive);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4264
    stmt('/*jslint', directive);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4265
    stmt('/*member', directive);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4266
    stmt('/*members', directive);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4267
    stmt('/*property', directive);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4268
    stmt('/*properties', directive);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4269
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4270
    stmt('var', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4271
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4272
// JavaScript does not have block scope. It only has function scope. So,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4273
// declaring a variable in a block can have unexpected consequences.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4274
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4275
// var.first will contain an array, the array containing name tokens
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4276
// and assignment tokens.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4277
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4278
        var assign, id, name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4279
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4280
        if (funct['(vars)'] && !option.vars) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4281
            warn('combine_var');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4282
        } else if (funct !== global_funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4283
            funct['(vars)'] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4284
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4285
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4286
        this.first = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4287
        step_in('var');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4288
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4289
            name = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4290
            id = identifier();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4291
            add_label(name, 'becoming');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4292
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4293
            if (next_token.id === '=') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4294
                assign = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4295
                assign.first = name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4296
                spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4297
                advance('=');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4298
                spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4299
                if (next_token.id === 'undefined') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4300
                    warn('unnecessary_initialize', token, id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4301
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4302
                if (peek(0).id === '=' && next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4303
                    stop('var_a_not');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4304
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4305
                assign.second = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4306
                assign.arity = 'infix';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4307
                this.first.push(assign);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4308
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4309
                this.first.push(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4310
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4311
            if (funct[id] === 'becoming') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4312
                funct[id] = 'unused';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4313
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4314
            if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4315
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4316
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4317
            comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4318
            indent.wrap = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4319
            if (var_mode && next_token.line === token.line &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4320
                    this.first.length === 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4321
                var_mode = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4322
                indent.open = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4323
                indent.at -= option.indent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4324
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4325
            spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4326
            edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4327
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4328
        var_mode = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4329
        step_out();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4330
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4331
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4332
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4333
    stmt('function', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4334
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4335
        if (in_block) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4336
            warn('function_block', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4337
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4338
        var name = next_token, id = identifier();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4339
        add_label(name, 'unction');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4340
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4341
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4342
        do_function(this, id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4343
        if (next_token.id === '(' && next_token.line === token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4344
            stop('function_statement');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4345
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4346
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4347
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4348
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4349
    prefix('function', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4350
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4351
        var id = optional_identifier();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4352
        if (id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4353
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4354
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4355
            id = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4356
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4357
        do_function(this, id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4358
        if (funct['(loopage)']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4359
            warn('function_loop');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4360
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4361
        this.arity = 'function';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4362
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4363
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4364
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4365
    stmt('if', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4366
        var paren = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4367
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4368
        advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4369
        step_in('control');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4370
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4371
        edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4372
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4373
        this.first = expected_condition(expected_relation(expression(0)));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4374
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4375
        step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4376
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4377
        this.block = block(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4378
        if (next_token.id === 'else') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4379
            one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4380
            advance('else');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4381
            one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4382
            this['else'] = next_token.id === 'if' || next_token.id === 'switch'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4383
                ? statement(true)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4384
                : block(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4385
            if (this['else'].disrupt && this.block.disrupt) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4386
                this.disrupt = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4387
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4388
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4389
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4390
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4391
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4392
    stmt('try', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4393
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4394
// try.first    The catch variable
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4395
// try.second   The catch clause
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4396
// try.third    The finally clause
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4397
// try.block    The try block
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4398
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4399
        var exception_variable, old_scope, paren;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4400
        if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4401
            warn('adsafe_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4402
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4403
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4404
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4405
        this.block = block(false);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4406
        if (next_token.id === 'catch') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4407
            one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4408
            advance('catch');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4409
            one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4410
            paren = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4411
            advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4412
            step_in('control');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4413
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4414
            edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4415
            old_scope = scope;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4416
            scope = Object.create(old_scope);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4417
            exception_variable = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4418
            this.first = exception_variable;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4419
            if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4420
                warn('expected_identifier_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4421
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4422
                add_label(next_token, 'exception');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4423
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4424
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4425
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4426
            step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4427
            one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4428
            this.second = block(false);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4429
            scope = old_scope;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4430
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4431
        if (next_token.id === 'finally') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4432
            one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4433
            advance('finally');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4434
            one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4435
            this.third = block(false);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4436
        } else if (!this.second) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4437
            stop('expected_a_b', next_token, 'catch', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4438
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4439
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4440
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4441
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4442
    labeled_stmt('while', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4443
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4444
        var paren = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4445
        funct['(breakage)'] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4446
        funct['(loopage)'] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4447
        advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4448
        step_in('control');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4449
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4450
        edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4451
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4452
        this.first = expected_relation(expression(0));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4453
        if (this.first.id !== 'true') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4454
            expected_condition(this.first, bundle.unexpected_a);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4455
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4456
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4457
        step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4458
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4459
        this.block = block(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4460
        if (this.block.disrupt) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4461
            warn('strange_loop', prev_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4462
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4463
        funct['(breakage)'] -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4464
        funct['(loopage)'] -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4465
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4466
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4467
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4468
    reserve('with');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4469
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4470
    labeled_stmt('switch', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4471
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4472
// switch.first         the switch expression
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4473
// switch.second        the array of cases. A case is 'case' or 'default' token:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4474
//    case.first        the array of case expressions
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4475
//    case.second       the array of statements
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4476
// If all of the arrays of statements are disrupt, then the switch is disrupt.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4477
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4478
        var cases = [],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4479
            old_in_block = in_block,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4480
            particular,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4481
            the_case = next_token,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4482
            unbroken = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4483
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4484
        function find_duplicate_case(value) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4485
            if (are_similar(particular, value)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4486
                warn('duplicate_a', value);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4487
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4488
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4489
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4490
        funct['(breakage)'] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4491
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4492
        advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4493
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4494
        step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4495
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4496
        this.first = expected_condition(expected_relation(expression(0)));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4497
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4498
        step_out(')', the_case);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4499
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4500
        advance('{');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4501
        step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4502
        in_block = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4503
        this.second = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4504
        while (next_token.id === 'case') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4505
            the_case = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4506
            cases.forEach(find_duplicate_case);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4507
            the_case.first = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4508
            the_case.arity = 'case';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4509
            spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4510
            edge('case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4511
            advance('case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4512
            for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4513
                one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4514
                particular = expression(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4515
                cases.forEach(find_duplicate_case);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4516
                cases.push(particular);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4517
                the_case.first.push(particular);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4518
                if (particular.id === 'NaN') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4519
                    warn('unexpected_a', particular);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4520
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4521
                no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4522
                advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4523
                if (next_token.id !== 'case') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4524
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4525
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4526
                spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4527
                edge('case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4528
                advance('case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4529
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4530
            spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4531
            the_case.second = statements();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4532
            if (the_case.second && the_case.second.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4533
                particular = the_case.second[the_case.second.length - 1];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4534
                if (particular.disrupt) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4535
                    if (particular.id === 'break') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4536
                        unbroken = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4537
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4538
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4539
                    warn('missing_a_after_b', next_token, 'break', 'case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4540
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4541
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4542
                warn('empty_case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4543
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4544
            this.second.push(the_case);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4545
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4546
        if (this.second.length === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4547
            warn('missing_a', next_token, 'case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4548
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4549
        if (next_token.id === 'default') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4550
            spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4551
            the_case = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4552
            the_case.arity = 'case';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4553
            edge('case');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4554
            advance('default');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4555
            no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4556
            advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4557
            spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4558
            the_case.second = statements();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4559
            if (the_case.second && the_case.second.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4560
                particular = the_case.second[the_case.second.length - 1];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4561
                if (unbroken && particular.disrupt && particular.id !== 'break') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4562
                    this.disrupt = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4563
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4564
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4565
            this.second.push(the_case);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4566
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4567
        funct['(breakage)'] -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4568
        spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4569
        step_out('}', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4570
        in_block = old_in_block;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4571
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4572
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4573
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4574
    stmt('debugger', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4575
        if (!option.debug) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4576
            warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4577
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4578
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4579
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4580
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4581
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4582
    labeled_stmt('do', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4583
        funct['(breakage)'] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4584
        funct['(loopage)'] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4585
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4586
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4587
        this.block = block(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4588
        if (this.block.disrupt) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4589
            warn('strange_loop', prev_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4590
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4591
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4592
        advance('while');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4593
        var paren = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4594
        one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4595
        advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4596
        step_in();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4597
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4598
        edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4599
        this.first = expected_condition(expected_relation(expression(0)), bundle.unexpected_a);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4600
        no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4601
        step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4602
        funct['(breakage)'] -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4603
        funct['(loopage)'] -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4604
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4605
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4606
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4607
    labeled_stmt('for', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4608
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4609
        var blok, filter, ok = false, paren = next_token, value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4610
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4611
        funct['(breakage)'] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4612
        funct['(loopage)'] += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4613
        advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4614
        if (next_token.id === ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4615
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4616
            advance(';');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4617
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4618
            advance(';');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4619
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4620
            advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4621
            blok = block(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4622
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4623
            step_in('control');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4624
            spaces(this, paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4625
            no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4626
            if (next_token.id === 'var') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4627
                stop('move_var');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4628
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4629
            edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4630
            if (peek(0).id === 'in') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4631
                this.forin = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4632
                value = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4633
                switch (funct[value.string]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4634
                case 'unused':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4635
                    funct[value.string] = 'var';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4636
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4637
                case 'closure':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4638
                case 'var':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4639
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4640
                default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4641
                    warn('bad_in_a', value);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4642
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4643
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4644
                advance('in');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4645
                this.first = value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4646
                this.second = expression(20);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4647
                step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4648
                blok = block(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4649
                if (!option.forin) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4650
                    if (blok.length === 1 && typeof blok[0] === 'object' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4651
                            blok[0].string === 'if' && !blok[0]['else']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4652
                        filter = blok[0].first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4653
                        while (filter.id === '&&') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4654
                            filter = filter.first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4655
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4656
                        switch (filter.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4657
                        case '===':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4658
                        case '!==':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4659
                            ok = filter.first.id === '['
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4660
                                ? filter.first.first.string === this.second.string &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4661
                                    filter.first.second.string === this.first.string
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4662
                                : filter.first.id === 'typeof' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4663
                                    filter.first.first.id === '[' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4664
                                    filter.first.first.first.string === this.second.string &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4665
                                    filter.first.first.second.string === this.first.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4666
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4667
                        case '(':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4668
                            ok = filter.first.id === '.' && ((
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4669
                                filter.first.first.string === this.second.string &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4670
                                filter.first.second.string === 'hasOwnProperty' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4671
                                filter.second[0].string === this.first.string
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4672
                            ) || (
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4673
                                filter.first.first.string === 'ADSAFE' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4674
                                filter.first.second.string === 'has' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4675
                                filter.second[0].string === this.second.string &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4676
                                filter.second[1].string === this.first.string
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4677
                            ) || (
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4678
                                filter.first.first.id === '.' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4679
                                filter.first.first.first.id === '.' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4680
                                filter.first.first.first.first.string === 'Object' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4681
                                filter.first.first.first.second.string === 'prototype' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4682
                                filter.first.first.second.string === 'hasOwnProperty' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4683
                                filter.first.second.string === 'call' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4684
                                filter.second[0].string === this.second.string &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4685
                                filter.second[1].string === this.first.string
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4686
                            ));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4687
                            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4688
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4689
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4690
                    if (!ok) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4691
                        warn('for_if', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4692
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4693
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4694
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4695
                edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4696
                this.first = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4697
                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4698
                    this.first.push(expression(0, 'for'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4699
                    if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4700
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4701
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4702
                    comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4703
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4704
                semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4705
                edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4706
                this.second = expected_relation(expression(0));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4707
                if (this.second.id !== 'true') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4708
                    expected_condition(this.second, bundle.unexpected_a);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4709
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4710
                semicolon(token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4711
                if (next_token.id === ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4712
                    stop('expected_a_b', next_token, ')', ';');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4713
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4714
                this.third = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4715
                edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4716
                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4717
                    this.third.push(expression(0, 'for'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4718
                    if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4719
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4720
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4721
                    comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4722
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4723
                no_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4724
                step_out(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4725
                one_space();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4726
                blok = block(true);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4727
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4728
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4729
        if (blok.disrupt) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4730
            warn('strange_loop', prev_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4731
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4732
        this.block = blok;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4733
        funct['(breakage)'] -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4734
        funct['(loopage)'] -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4735
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4736
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4737
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4738
    disrupt_stmt('break', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4739
        var label = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4740
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4741
        if (funct['(breakage)'] === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4742
            warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4743
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4744
        if (next_token.identifier && token.line === next_token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4745
            one_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4746
            if (funct[label] !== 'label') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4747
                warn('not_a_label', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4748
            } else if (scope[label].funct !== funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4749
                warn('not_a_scope', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4750
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4751
            this.first = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4752
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4753
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4754
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4755
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4756
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4757
    disrupt_stmt('continue', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4758
        if (!option['continue']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4759
            warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4760
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4761
        var label = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4762
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4763
        if (funct['(breakage)'] === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4764
            warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4765
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4766
        if (next_token.identifier && token.line === next_token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4767
            one_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4768
            if (funct[label] !== 'label') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4769
                warn('not_a_label', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4770
            } else if (scope[label].funct !== funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4771
                warn('not_a_scope', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4772
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4773
            this.first = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4774
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4775
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4776
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4777
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4778
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4779
    disrupt_stmt('return', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4780
        if (funct === global_funct) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4781
            warn('unexpected_a', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4782
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4783
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4784
        if (next_token.id !== ';' && next_token.line === token.line) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4785
            one_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4786
            if (next_token.id === '/' || next_token.id === '(regexp)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4787
                warn('wrap_regexp');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4788
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4789
            this.first = expression(20);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4790
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4791
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4792
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4793
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4794
    disrupt_stmt('throw', function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4795
        this.arity = 'statement';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4796
        one_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4797
        this.first = expression(20);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4798
        return this;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4799
    });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4800
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4801
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4802
//  Superfluous reserved words
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4803
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4804
    reserve('class');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4805
    reserve('const');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4806
    reserve('enum');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4807
    reserve('export');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4808
    reserve('extends');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4809
    reserve('import');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4810
    reserve('super');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4811
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4812
// Harmony reserved words
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4813
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4814
    reserve('implements');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4815
    reserve('interface');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4816
    reserve('let');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4817
    reserve('package');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4818
    reserve('private');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4819
    reserve('protected');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4820
    reserve('public');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4821
    reserve('static');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4822
    reserve('yield');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4823
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4824
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4825
// Type inference
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4826
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4827
//     function get_type(one) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4828
//         var type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4829
//         if (typeof one === 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4830
//             return one;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4831
//         } else if (one.type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4832
//             return one.type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4833
//         } else if (one.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4834
//             type = property_type[one.second.string];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4835
//             return typeof type === 'string' ? type : '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4836
//         } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4837
//             return ((one.identifier && scope[one.string]) || one).type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4838
//         }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4839
//     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4840
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4841
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4842
//     function match_type(one_type, two_type, one, two) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4843
//         if (one_type === two_type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4844
//             return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4845
//         } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4846
//             if (!funct.confusion && !two.warn) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4847
//                 if (typeof one !== 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4848
//                     if (one.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4849
//                         one_type = '.' + one.second.string + ': ' + one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4850
//                     } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4851
//                         one_type = one.string + ': ' + one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4852
//                     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4853
//                 }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4854
//                 if (two.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4855
//                     two_type = '.' + two.second.string + ': ' + one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4856
//                 } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4857
//                     two_type = two.string + ': ' + one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4858
//                 }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4859
//                 warn('type_confusion_a_b', two, one_type, two_type);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4860
//                 two.warn = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4861
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4862
//             return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4863
//         }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4864
//     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4865
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4866
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4867
//     function conform(one, two) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4868
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4869
// // The conform function takes a type string and a token, or two tokens.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4870
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4871
//         var one_type = typeof one === 'string' ? one : one.type,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4872
//             two_type = two.type,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4873
//             two_thing;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4874
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4875
// // If both tokens already have a type, and if they match, then we are done.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4876
// // Once a token has a type, it is locked. Neither token will change, but if
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4877
// // they do not match, there will be a warning.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4878
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4879
//         if (one_type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4880
//             if (two_type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4881
//                 match_type(one_type, two_type, one, two);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4882
//             } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4883
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4884
// // two does not have a type, so look deeper. If two is a variable or property,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4885
// // then use its type if it has one, and make the deep type one's type if it
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4886
// // doesn't. If the type was *, or if there was a mismatch, don't change the
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4887
// // deep type.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4888
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4889
//                 two_thing = two.id === '(identifier)'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4890
//                     ? scope[two.string]
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4891
//                     : two.id === '.'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4892
//                     ? property_type[two.second.string]
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4893
//                     : null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4894
//                 if (two_thing) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4895
//                     two_type = two_thing.type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4896
//                     if (two_type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4897
//                         if (two_type !== '*') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4898
//                             if (!match_type(one_type, two_type, one, two)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4899
//                                 return '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4900
//                             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4901
//                         }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4902
//                     } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4903
//                         two_thing.type = one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4904
//                     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4905
//                 }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4906
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4907
// // In any case, we give two a type.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4908
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4909
//                 two.type = one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4910
//                 type_state_change = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4911
//                 return one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4912
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4913
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4914
// // one does not have a type, but two does, so do the old switcheroo.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4915
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4916
//         } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4917
//             if (two_type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4918
//                 return conform(two, one);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4919
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4920
// // Neither token has a type yet. So we have to look deeper to see if either
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4921
// // is a variable or property.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4922
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4923
//             } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4924
//                 if (one.id === '(identifier)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4925
//                     one_type = scope[one.string].type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4926
//                     if (one_type && one_type !== '*') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4927
//                         one.type = one_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4928
//                         return conform(one, two);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4929
//                     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4930
//                 } else if (one.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4931
//                     one_type = property_type[one.second.string];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4932
//                     if (one_type && one_type !== '*') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4933
//                         one.type = scope[one.string].type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4934
//                         return conform(one, two);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4935
//                     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4936
//                 }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4937
//                 if (two.id === '(identifier)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4938
//                     two_type = scope[two.string].type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4939
//                     if (two_type && two_type !== '*') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4940
//                         two.type = two_type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4941
//                         return conform(two, one);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4942
//                     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4943
//                 } else if (two.id === '.') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4944
//                     two_type = property_type[two.second.string];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4945
//                     if (two_type && two_type !== '*') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4946
//                         two.type = scope[two.string].type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4947
//                         return conform(two, one);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4948
//                     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4949
//                 }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4950
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4951
//         }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4952
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4953
// // Return a falsy string if we were unable to determine the type of either token.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4954
//
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4955
//         return '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4956
//     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4957
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4958
//     function conform_array(type, array) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4959
//         array.forEach(function (item) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4960
//             return conform(type, item);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4961
//         }, type);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4962
//     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4963
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4964
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4965
//     function infer(node) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4966
//         if (Array.isArray(node)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4967
//             node.forEach(infer);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4968
//         } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4969
//             switch (node.arity) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4970
//             case 'statement':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4971
//                 infer_statement[node.id](node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4972
//                 break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4973
//             case 'infix':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4974
//                 infer(node.first);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4975
//                 infer(node.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4976
//                 switch (node.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4977
//                 case '(':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4978
//                     conform('function', node.first);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4979
//                     break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4980
//                 default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4981
//                     stop('unfinished');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4982
//                 }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4983
//                 break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4984
//             case 'number':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4985
//             case 'string':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4986
//             case 'boolean':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4987
//                 break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4988
//             default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4989
//                 stop('unfinished');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4990
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4991
//         }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4992
//     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4993
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4994
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4995
//     infer_statement = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4996
//         'var': function (node) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4997
//             var i, item, list = node.first;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4998
//             for (i = 0; i < list.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  4999
//                 item = list[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5000
//                 if (item.id === '=') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5001
//                     infer(item.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5002
//                     conform(item.first, item.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5003
//                     conform(item.first, item);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5004
//                 }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5005
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5006
//         },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5007
//         'for': function (node) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5008
//             infer(node.first);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5009
//             infer(node.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5010
//             if (node.forin) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5011
//                 conform('string', node.first);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5012
//                 conform('object', node.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5013
//             } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5014
//                 infer(node.third);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5015
//                 conform_array('number', node.first);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5016
//                 conform('boolean', node.second);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5017
//                 conform_array('number', node.third);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5018
//             }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5019
//             infer(node.block);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5020
//         }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5021
//     };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5022
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5023
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5024
//     function infer_types(node) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5025
//         do {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5026
//             funct = global_funct;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5027
//             scope = global_scope;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5028
//             type_state_change = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5029
//             infer(node);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5030
//         } while (type_state_change);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5031
//     }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5032
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5033
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5034
// Parse JSON
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5035
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5036
    function json_value() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5037
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5038
        function json_object() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5039
            var brace = next_token, object = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5040
            advance('{');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5041
            if (next_token.id !== '}') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5042
                while (next_token.id !== '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5043
                    while (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5044
                        warn('unexpected_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5045
                        advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5046
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5047
                    if (next_token.id !== '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5048
                        warn('expected_string_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5049
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5050
                    if (object[next_token.string] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5051
                        warn('duplicate_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5052
                    } else if (next_token.string === '__proto__') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5053
                        warn('dangling_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5054
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5055
                        object[next_token.string] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5056
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5057
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5058
                    advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5059
                    json_value();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5060
                    if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5061
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5062
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5063
                    advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5064
                    if (next_token.id === '}') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5065
                        warn('unexpected_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5066
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5067
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5068
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5069
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5070
            advance('}', brace);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5071
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5072
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5073
        function json_array() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5074
            var bracket = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5075
            advance('[');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5076
            if (next_token.id !== ']') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5077
                while (next_token.id !== '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5078
                    while (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5079
                        warn('unexpected_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5080
                        advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5081
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5082
                    json_value();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5083
                    if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5084
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5085
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5086
                    advance(',');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5087
                    if (next_token.id === ']') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5088
                        warn('unexpected_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5089
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5090
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5091
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5092
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5093
            advance(']', bracket);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5094
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5095
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5096
        switch (next_token.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5097
        case '{':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5098
            json_object();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5099
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5100
        case '[':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5101
            json_array();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5102
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5103
        case 'true':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5104
        case 'false':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5105
        case 'null':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5106
        case '(number)':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5107
        case '(string)':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5108
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5109
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5110
        case '-':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5111
            advance('-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5112
            no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5113
            advance('(number)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5114
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5115
        default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5116
            stop('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5117
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5118
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5119
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5120
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5121
// CSS parsing.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5122
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5123
    function css_name() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5124
        if (next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5125
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5126
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5127
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5128
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5129
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5130
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5131
    function css_number() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5132
        if (next_token.id === '-') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5133
            advance('-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5134
            no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5135
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5136
        if (next_token.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5137
            advance('(number)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5138
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5139
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5140
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5141
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5142
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5143
    function css_string() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5144
        if (next_token.id === '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5145
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5146
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5147
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5148
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5149
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5150
    function css_color() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5151
        var i, number, paren, value;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5152
        if (next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5153
            value = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5154
            if (value === 'rgb' || value === 'rgba') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5155
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5156
                paren = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5157
                advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5158
                for (i = 0; i < 3; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5159
                    if (i) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5160
                        comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5161
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5162
                    number = next_token.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5163
                    if (next_token.id !== '(number)' || number < 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5164
                        warn('expected_positive_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5165
                        advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5166
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5167
                        advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5168
                        if (next_token.id === '%') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5169
                            advance('%');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5170
                            if (number > 100) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5171
                                warn('expected_percent_a', token, number);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5172
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5173
                        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5174
                            if (number > 255) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5175
                                warn('expected_small_a', token, number);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5176
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5177
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5178
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5179
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5180
                if (value === 'rgba') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5181
                    comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5182
                    number = next_token.number;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5183
                    if (next_token.id !== '(number)' || number < 0 || number > 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5184
                        warn('expected_fraction_a', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5185
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5186
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5187
                    if (next_token.id === '%') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5188
                        warn('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5189
                        advance('%');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5190
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5191
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5192
                advance(')', paren);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5193
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5194
            } else if (css_colorData[next_token.string] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5195
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5196
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5197
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5198
        } else if (next_token.id === '(color)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5199
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5200
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5201
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5202
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5203
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5204
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5205
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5206
    function css_length() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5207
        if (next_token.id === '-') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5208
            advance('-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5209
            no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5210
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5211
        if (next_token.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5212
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5213
            if (next_token.id !== '(string)' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5214
                    css_lengthData[next_token.string] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5215
                no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5216
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5217
            } else if (+token.number !== 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5218
                warn('expected_linear_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5219
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5220
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5221
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5222
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5223
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5224
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5225
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5226
    function css_line_height() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5227
        if (next_token.id === '-') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5228
            advance('-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5229
            no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5230
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5231
        if (next_token.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5232
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5233
            if (next_token.id !== '(string)' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5234
                    css_lengthData[next_token.string] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5235
                no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5236
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5237
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5238
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5239
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5240
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5241
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5242
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5243
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5244
    function css_width() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5245
        if (next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5246
            switch (next_token.string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5247
            case 'thin':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5248
            case 'medium':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5249
            case 'thick':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5250
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5251
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5252
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5253
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5254
            return css_length();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5255
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5256
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5257
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5258
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5259
    function css_margin() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5260
        if (next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5261
            if (next_token.string === 'auto') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5262
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5263
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5264
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5265
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5266
            return css_length();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5267
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5268
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5269
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5270
    function css_attr() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5271
        if (next_token.identifier && next_token.string === 'attr') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5272
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5273
            advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5274
            if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5275
                warn('expected_name_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5276
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5277
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5278
            advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5279
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5280
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5281
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5282
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5283
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5284
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5285
    function css_comma_list() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5286
        while (next_token.id !== ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5287
            if (!css_name() && !css_string()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5288
                warn('expected_name_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5289
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5290
            if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5291
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5292
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5293
            comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5294
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5295
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5296
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5297
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5298
    function css_counter() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5299
        if (next_token.identifier && next_token.string === 'counter') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5300
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5301
            advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5302
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5303
            if (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5304
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5305
                if (next_token.id !== '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5306
                    warn('expected_string_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5307
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5308
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5309
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5310
            advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5311
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5312
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5313
        if (next_token.identifier && next_token.string === 'counters') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5314
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5315
            advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5316
            if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5317
                warn('expected_name_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5318
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5319
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5320
            if (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5321
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5322
                if (next_token.id !== '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5323
                    warn('expected_string_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5324
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5325
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5326
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5327
            if (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5328
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5329
                if (next_token.id !== '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5330
                    warn('expected_string_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5331
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5332
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5333
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5334
            advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5335
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5336
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5337
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5338
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5339
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5340
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5341
    function css_radius() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5342
        return css_length() && (next_token.id !== '(number)' || css_length());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5343
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5344
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5345
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5346
    function css_shape() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5347
        var i;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5348
        if (next_token.identifier && next_token.string === 'rect') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5349
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5350
            advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5351
            for (i = 0; i < 4; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5352
                if (!css_length()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5353
                    warn('expected_number_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5354
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5355
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5356
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5357
            advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5358
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5359
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5360
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5361
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5362
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5363
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5364
    function css_url() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5365
        var c, url;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5366
        if (next_token.identifier && next_token.string === 'url') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5367
            next_token = lex.range('(', ')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5368
            url = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5369
            c = url.charAt(0);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5370
            if (c === '"' || c === '\'') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5371
                if (url.slice(-1) !== c) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5372
                    warn('bad_url_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5373
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5374
                    url = url.slice(1, -1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5375
                    if (url.indexOf(c) >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5376
                        warn('bad_url_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5377
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5378
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5379
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5380
            if (!url) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5381
                warn('missing_url');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5382
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5383
            if (ux.test(url)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5384
                stop('bad_url_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5385
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5386
            urls.push(url);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5387
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5388
            return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5389
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5390
        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5391
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5392
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5393
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5394
    css_any = [css_url, function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5395
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5396
            if (next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5397
                switch (next_token.string.toLowerCase()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5398
                case 'url':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5399
                    css_url();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5400
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5401
                case 'expression':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5402
                    warn('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5403
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5404
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5405
                default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5406
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5407
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5408
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5409
                if (next_token.id === ';' || next_token.id === '!'  ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5410
                        next_token.id === '(end)' || next_token.id === '}') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5411
                    return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5412
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5413
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5414
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5415
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5416
    }];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5417
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5418
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5419
    function font_face() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5420
        advance_identifier('font-family');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5421
        advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5422
        if (!css_name() && !css_string()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5423
            stop('expected_name_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5424
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5425
        semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5426
        advance_identifier('src');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5427
        advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5428
        while (true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5429
            if (next_token.string === 'local') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5430
                advance_identifier('local');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5431
                advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5432
                if (ux.test(next_token.string)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5433
                    stop('bad_url_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5434
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5435
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5436
                if (!css_name() && !css_string()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5437
                    stop('expected_name_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5438
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5439
                advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5440
            } else if (!css_url()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5441
                stop('expected_a_b', next_token, 'url', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5442
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5443
            if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5444
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5445
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5446
            comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5447
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5448
        semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5449
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5450
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5451
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5452
    css_border_style = [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5453
        'none', 'dashed', 'dotted', 'double', 'groove',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5454
        'hidden', 'inset', 'outset', 'ridge', 'solid'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5455
    ];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5456
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5457
    css_break = [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5458
        'auto', 'always', 'avoid', 'left', 'right'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5459
    ];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5460
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5461
    css_media = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5462
        'all': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5463
        'braille': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5464
        'embossed': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5465
        'handheld': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5466
        'print': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5467
        'projection': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5468
        'screen': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5469
        'speech': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5470
        'tty': true,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5471
        'tv': true
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5472
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5473
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5474
    css_overflow = [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5475
        'auto', 'hidden', 'scroll', 'visible'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5476
    ];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5477
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5478
    css_attribute_data = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5479
        background: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5480
            true, 'background-attachment', 'background-color',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5481
            'background-image', 'background-position', 'background-repeat'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5482
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5483
        'background-attachment': ['scroll', 'fixed'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5484
        'background-color': ['transparent', css_color],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5485
        'background-image': ['none', css_url],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5486
        'background-position': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5487
            2, [css_length, 'top', 'bottom', 'left', 'right', 'center']
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5488
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5489
        'background-repeat': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5490
            'repeat', 'repeat-x', 'repeat-y', 'no-repeat'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5491
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5492
        'border': [true, 'border-color', 'border-style', 'border-width'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5493
        'border-bottom': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5494
            true, 'border-bottom-color', 'border-bottom-style',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5495
            'border-bottom-width'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5496
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5497
        'border-bottom-color': css_color,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5498
        'border-bottom-left-radius': css_radius,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5499
        'border-bottom-right-radius': css_radius,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5500
        'border-bottom-style': css_border_style,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5501
        'border-bottom-width': css_width,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5502
        'border-collapse': ['collapse', 'separate'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5503
        'border-color': ['transparent', 4, css_color],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5504
        'border-left': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5505
            true, 'border-left-color', 'border-left-style', 'border-left-width'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5506
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5507
        'border-left-color': css_color,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5508
        'border-left-style': css_border_style,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5509
        'border-left-width': css_width,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5510
        'border-radius': function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5511
            function count(separator) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5512
                var n = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5513
                if (separator) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5514
                    advance(separator);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5515
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5516
                if (!css_length()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5517
                    return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5518
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5519
                while (next_token.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5520
                    if (!css_length()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5521
                        return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5522
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5523
                    n += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5524
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5525
                if (n > 4) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5526
                    warn('bad_style');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5527
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5528
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5529
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5530
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5531
            return count() && (next_token.id !== '/' || count('/'));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5532
        },
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5533
        'border-right': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5534
            true, 'border-right-color', 'border-right-style',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5535
            'border-right-width'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5536
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5537
        'border-right-color': css_color,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5538
        'border-right-style': css_border_style,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5539
        'border-right-width': css_width,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5540
        'border-spacing': [2, css_length],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5541
        'border-style': [4, css_border_style],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5542
        'border-top': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5543
            true, 'border-top-color', 'border-top-style', 'border-top-width'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5544
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5545
        'border-top-color': css_color,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5546
        'border-top-left-radius': css_radius,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5547
        'border-top-right-radius': css_radius,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5548
        'border-top-style': css_border_style,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5549
        'border-top-width': css_width,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5550
        'border-width': [4, css_width],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5551
        bottom: [css_length, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5552
        'caption-side' : ['bottom', 'left', 'right', 'top'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5553
        clear: ['both', 'left', 'none', 'right'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5554
        clip: [css_shape, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5555
        color: css_color,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5556
        content: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5557
            'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5558
            css_string, css_url, css_counter, css_attr
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5559
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5560
        'counter-increment': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5561
            css_name, 'none'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5562
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5563
        'counter-reset': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5564
            css_name, 'none'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5565
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5566
        cursor: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5567
            css_url, 'auto', 'crosshair', 'default', 'e-resize', 'help', 'move',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5568
            'n-resize', 'ne-resize', 'nw-resize', 'pointer', 's-resize',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5569
            'se-resize', 'sw-resize', 'w-resize', 'text', 'wait'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5570
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5571
        direction: ['ltr', 'rtl'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5572
        display: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5573
            'block', 'compact', 'inline', 'inline-block', 'inline-table',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5574
            'list-item', 'marker', 'none', 'run-in', 'table', 'table-caption',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5575
            'table-cell', 'table-column', 'table-column-group',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5576
            'table-footer-group', 'table-header-group', 'table-row',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5577
            'table-row-group'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5578
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5579
        'empty-cells': ['show', 'hide'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5580
        'float': ['left', 'none', 'right'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5581
        font: [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5582
            'caption', 'icon', 'menu', 'message-box', 'small-caption',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5583
            'status-bar', true, 'font-size', 'font-style', 'font-weight',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5584
            'font-family'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5585
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5586
        'font-family': css_comma_list,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5587
        'font-size': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5588
            'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5589
            'xx-large', 'larger', 'smaller', css_length
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5590
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5591
        'font-size-adjust': ['none', css_number],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5592
        'font-stretch': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5593
            'normal', 'wider', 'narrower', 'ultra-condensed',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5594
            'extra-condensed', 'condensed', 'semi-condensed',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5595
            'semi-expanded', 'expanded', 'extra-expanded'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5596
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5597
        'font-style': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5598
            'normal', 'italic', 'oblique'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5599
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5600
        'font-variant': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5601
            'normal', 'small-caps'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5602
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5603
        'font-weight': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5604
            'normal', 'bold', 'bolder', 'lighter', css_number
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5605
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5606
        height: [css_length, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5607
        left: [css_length, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5608
        'letter-spacing': ['normal', css_length],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5609
        'line-height': ['normal', css_line_height],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5610
        'list-style': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5611
            true, 'list-style-image', 'list-style-position', 'list-style-type'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5612
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5613
        'list-style-image': ['none', css_url],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5614
        'list-style-position': ['inside', 'outside'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5615
        'list-style-type': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5616
            'circle', 'disc', 'square', 'decimal', 'decimal-leading-zero',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5617
            'lower-roman', 'upper-roman', 'lower-greek', 'lower-alpha',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5618
            'lower-latin', 'upper-alpha', 'upper-latin', 'hebrew', 'katakana',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5619
            'hiragana-iroha', 'katakana-oroha', 'none'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5620
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5621
        margin: [4, css_margin],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5622
        'margin-bottom': css_margin,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5623
        'margin-left': css_margin,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5624
        'margin-right': css_margin,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5625
        'margin-top': css_margin,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5626
        'marker-offset': [css_length, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5627
        'max-height': [css_length, 'none'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5628
        'max-width': [css_length, 'none'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5629
        'min-height': css_length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5630
        'min-width': css_length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5631
        opacity: css_number,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5632
        outline: [true, 'outline-color', 'outline-style', 'outline-width'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5633
        'outline-color': ['invert', css_color],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5634
        'outline-style': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5635
            'dashed', 'dotted', 'double', 'groove', 'inset', 'none',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5636
            'outset', 'ridge', 'solid'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5637
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5638
        'outline-width': css_width,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5639
        overflow: css_overflow,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5640
        'overflow-x': css_overflow,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5641
        'overflow-y': css_overflow,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5642
        padding: [4, css_length],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5643
        'padding-bottom': css_length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5644
        'padding-left': css_length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5645
        'padding-right': css_length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5646
        'padding-top': css_length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5647
        'page-break-after': css_break,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5648
        'page-break-before': css_break,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5649
        position: ['absolute', 'fixed', 'relative', 'static'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5650
        quotes: [8, css_string],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5651
        right: [css_length, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5652
        'table-layout': ['auto', 'fixed'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5653
        'text-align': ['center', 'justify', 'left', 'right'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5654
        'text-decoration': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5655
            'none', 'underline', 'overline', 'line-through', 'blink'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5656
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5657
        'text-indent': css_length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5658
        'text-shadow': ['none', 4, [css_color, css_length]],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5659
        'text-transform': ['capitalize', 'uppercase', 'lowercase', 'none'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5660
        top: [css_length, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5661
        'unicode-bidi': ['normal', 'embed', 'bidi-override'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5662
        'vertical-align': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5663
            'baseline', 'bottom', 'sub', 'super', 'top', 'text-top', 'middle',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5664
            'text-bottom', css_length
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5665
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5666
        visibility: ['visible', 'hidden', 'collapse'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5667
        'white-space': [
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5668
            'normal', 'nowrap', 'pre', 'pre-line', 'pre-wrap', 'inherit'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5669
        ],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5670
        width: [css_length, 'auto'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5671
        'word-spacing': ['normal', css_length],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5672
        'word-wrap': ['break-word', 'normal'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5673
        'z-index': ['auto', css_number]
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5674
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5675
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5676
    function style_attribute() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5677
        var v;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5678
        while (next_token.id === '*' || next_token.id === '#' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5679
                next_token.string === '_') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5680
            if (!option.css) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5681
                warn('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5682
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5683
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5684
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5685
        if (next_token.id === '-') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5686
            if (!option.css) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5687
                warn('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5688
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5689
            advance('-');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5690
            if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5691
                warn('expected_nonstandard_style_attribute');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5692
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5693
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5694
            return css_any;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5695
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5696
            if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5697
                warn('expected_style_attribute');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5698
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5699
                if (Object.prototype.hasOwnProperty.call(css_attribute_data,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5700
                        next_token.string)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5701
                    v = css_attribute_data[next_token.string];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5702
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5703
                    v = css_any;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5704
                    if (!option.css) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5705
                        warn('unrecognized_style_attribute_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5706
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5707
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5708
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5709
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5710
            return v;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5711
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5712
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5713
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5714
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5715
    function style_value(v) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5716
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5717
        /*jslint confusion: true */
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5718
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5719
        var i = 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5720
            n,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5721
            once,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5722
            match,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5723
            round,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5724
            start = 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5725
            vi;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5726
        switch (typeof v) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5727
        case 'function':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5728
            return v();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5729
        case 'string':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5730
            if (next_token.identifier && next_token.string === v) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5731
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5732
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5733
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5734
            return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5735
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5736
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5737
            if (i >= v.length) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5738
                return false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5739
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5740
            vi = v[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5741
            i += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5742
            if (typeof vi === 'boolean') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5743
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5744
            } else if (typeof vi === 'number') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5745
                n = vi;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5746
                vi = v[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5747
                i += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5748
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5749
                n = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5750
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5751
            match = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5752
            while (n > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5753
                if (style_value(vi)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5754
                    match = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5755
                    n -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5756
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5757
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5758
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5759
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5760
            if (match) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5761
                return true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5762
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5763
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5764
        start = i;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5765
        once = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5766
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5767
            round = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5768
            for (i = start; i < v.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5769
                if (!once[i]) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5770
                    if (style_value(css_attribute_data[v[i]])) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5771
                        match = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5772
                        round = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5773
                        once[i] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5774
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5775
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5776
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5777
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5778
            if (!round) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5779
                return match;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5780
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5781
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5782
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5783
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5784
    function style_child() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5785
        if (next_token.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5786
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5787
            if (next_token.string === 'n' && next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5788
                no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5789
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5790
                if (next_token.id === '+') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5791
                    no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5792
                    advance('+');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5793
                    no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5794
                    advance('(number)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5795
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5796
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5797
            return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5798
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5799
            if (next_token.identifier &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5800
                    (next_token.string === 'odd' || next_token.string === 'even')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5801
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5802
                return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5803
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5804
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5805
        warn('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5806
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5807
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5808
    function substyle() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5809
        var v;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5810
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5811
            if (next_token.id === '}' || next_token.id === '(end)' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5812
                    (xquote && next_token.id === xquote)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5813
                return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5814
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5815
            v = style_attribute();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5816
            advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5817
            if (next_token.identifier && next_token.string === 'inherit') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5818
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5819
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5820
                if (!style_value(v)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5821
                    warn('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5822
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5823
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5824
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5825
            if (next_token.id === '!') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5826
                advance('!');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5827
                no_space_only();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5828
                if (next_token.identifier && next_token.string === 'important') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5829
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5830
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5831
                    warn('expected_a_b',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5832
                        next_token, 'important', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5833
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5834
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5835
            if (next_token.id === '}' || next_token.id === xquote) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5836
                warn('expected_a_b', next_token, ';', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5837
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5838
                semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5839
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5840
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5841
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5842
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5843
    function style_selector() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5844
        if (next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5845
            if (!Object.prototype.hasOwnProperty.call(html_tag, option.cap
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5846
                    ? next_token.string.toLowerCase()
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5847
                    : next_token.string)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5848
                warn('expected_tagname_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5849
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5850
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5851
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5852
            switch (next_token.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5853
            case '>':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5854
            case '+':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5855
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5856
                style_selector();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5857
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5858
            case ':':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5859
                advance(':');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5860
                switch (next_token.string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5861
                case 'active':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5862
                case 'after':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5863
                case 'before':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5864
                case 'checked':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5865
                case 'disabled':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5866
                case 'empty':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5867
                case 'enabled':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5868
                case 'first-child':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5869
                case 'first-letter':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5870
                case 'first-line':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5871
                case 'first-of-type':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5872
                case 'focus':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5873
                case 'hover':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5874
                case 'last-child':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5875
                case 'last-of-type':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5876
                case 'link':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5877
                case 'only-of-type':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5878
                case 'root':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5879
                case 'target':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5880
                case 'visited':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5881
                    advance_identifier(next_token.string);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5882
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5883
                case 'lang':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5884
                    advance_identifier('lang');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5885
                    advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5886
                    if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5887
                        warn('expected_lang_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5888
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5889
                    advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5890
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5891
                case 'nth-child':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5892
                case 'nth-last-child':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5893
                case 'nth-last-of-type':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5894
                case 'nth-of-type':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5895
                    advance_identifier(next_token.string);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5896
                    advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5897
                    style_child();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5898
                    advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5899
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5900
                case 'not':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5901
                    advance_identifier('not');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5902
                    advance('(');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5903
                    if (next_token.id === ':' && peek(0).string === 'not') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5904
                        warn('not');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5905
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5906
                    style_selector();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5907
                    advance(')');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5908
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5909
                default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5910
                    warn('expected_pseudo_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5911
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5912
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5913
            case '#':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5914
                advance('#');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5915
                if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5916
                    warn('expected_id_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5917
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5918
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5919
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5920
            case '*':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5921
                advance('*');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5922
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5923
            case '.':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5924
                advance('.');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5925
                if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5926
                    warn('expected_class_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5927
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5928
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5929
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5930
            case '[':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5931
                advance('[');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5932
                if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5933
                    warn('expected_attribute_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5934
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5935
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5936
                if (next_token.id === '=' || next_token.string === '~=' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5937
                        next_token.string === '$=' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5938
                        next_token.string === '|=' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5939
                        next_token.id === '*=' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5940
                        next_token.id === '^=') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5941
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5942
                    if (next_token.id !== '(string)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5943
                        warn('expected_string_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5944
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5945
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5946
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5947
                advance(']');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5948
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5949
            default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5950
                stop('expected_selector_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5951
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5952
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5953
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5954
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5955
    function style_pattern() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5956
        if (next_token.id === '{') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5957
            warn('expected_style_pattern');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5958
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5959
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5960
            style_selector();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5961
            if (next_token.id === '</' || next_token.id === '{' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5962
                    next_token.id === '}' || next_token.id === '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5963
                return '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5964
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5965
            if (next_token.id === ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5966
                comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5967
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5968
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5969
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5970
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5971
    function style_list() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5972
        while (next_token.id !== '}' && next_token.id !== '</' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5973
                next_token.id !== '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5974
            style_pattern();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5975
            xmode = 'styleproperty';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5976
            if (next_token.id === ';') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5977
                semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5978
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5979
                advance('{');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5980
                substyle();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5981
                xmode = 'style';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5982
                advance('}');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5983
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5984
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5985
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5986
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5987
    function styles() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5988
        var i;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5989
        while (next_token.id === '@') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5990
            i = peek();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5991
            advance('@');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5992
            switch (next_token.string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5993
            case 'import':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5994
                advance_identifier('import');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5995
                if (!css_url()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5996
                    warn('expected_a_b',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5997
                        next_token, 'url', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5998
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  5999
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6000
                semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6001
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6002
            case 'media':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6003
                advance_identifier('media');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6004
                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6005
                    if (!next_token.identifier || css_media[next_token.string] !== true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6006
                        stop('expected_media_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6007
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6008
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6009
                    if (next_token.id !== ',') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6010
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6011
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6012
                    comma();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6013
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6014
                advance('{');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6015
                style_list();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6016
                advance('}');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6017
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6018
            case 'font-face':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6019
                advance_identifier('font-face');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6020
                advance('{');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6021
                font_face();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6022
                advance('}');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6023
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6024
            default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6025
                stop('expected_at_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6026
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6027
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6028
        style_list();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6029
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6030
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6031
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6032
// Parse HTML
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6033
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6034
    function do_begin(n) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6035
        if (n !== 'html' && !option.fragment) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6036
            if (n === 'div' && option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6037
                stop('adsafe_fragment');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6038
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6039
                stop('expected_a_b', token, 'html', n);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6040
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6041
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6042
        if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6043
            if (n === 'html') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6044
                stop('adsafe_html', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6045
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6046
            if (option.fragment) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6047
                if (n !== 'div') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6048
                    stop('adsafe_div', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6049
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6050
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6051
                stop('adsafe_fragment', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6052
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6053
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6054
        option.browser = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6055
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6056
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6057
    function do_attribute(a, v) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6058
        var u, x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6059
        if (a === 'id') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6060
            u = typeof v === 'string' ? v.toUpperCase() : '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6061
            if (ids[u] === true) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6062
                warn('duplicate_a', next_token, v);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6063
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6064
            if (!/^[A-Za-z][A-Za-z0-9._:\-]*$/.test(v)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6065
                warn('bad_id_a', next_token, v);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6066
            } else if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6067
                if (adsafe_id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6068
                    if (v.slice(0, adsafe_id.length) !== adsafe_id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6069
                        warn('adsafe_prefix_a', next_token, adsafe_id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6070
                    } else if (!/^[A-Z]+_[A-Z]+$/.test(v)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6071
                        warn('adsafe_bad_id');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6072
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6073
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6074
                    adsafe_id = v;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6075
                    if (!/^[A-Z]+_$/.test(v)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6076
                        warn('adsafe_bad_id');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6077
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6078
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6079
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6080
            x = v.search(dx);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6081
            if (x >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6082
                warn('unexpected_char_a_b', token, v.charAt(x), a);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6083
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6084
            ids[u] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6085
        } else if (a === 'class' || a === 'type' || a === 'name') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6086
            x = v.search(qx);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6087
            if (x >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6088
                warn('unexpected_char_a_b', token, v.charAt(x), a);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6089
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6090
            ids[u] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6091
        } else if (a === 'href' || a === 'background' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6092
                a === 'content' || a === 'data' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6093
                a.indexOf('src') >= 0 || a.indexOf('url') >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6094
            if (option.safe && ux.test(v)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6095
                stop('bad_url_a', next_token, v);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6096
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6097
            urls.push(v);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6098
        } else if (a === 'for') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6099
            if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6100
                if (adsafe_id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6101
                    if (v.slice(0, adsafe_id.length) !== adsafe_id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6102
                        warn('adsafe_prefix_a', next_token, adsafe_id);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6103
                    } else if (!/^[A-Z]+_[A-Z]+$/.test(v)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6104
                        warn('adsafe_bad_id');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6105
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6106
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6107
                    warn('adsafe_bad_id');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6108
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6109
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6110
        } else if (a === 'name') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6111
            if (option.adsafe && v.indexOf('_') >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6112
                warn('adsafe_name_a', next_token, v);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6113
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6114
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6115
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6116
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6117
    function do_tag(name, attribute) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6118
        var i, tag = html_tag[name], script, x;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6119
        src = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6120
        if (!tag) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6121
            stop(
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6122
                bundle.unrecognized_tag_a,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6123
                next_token,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6124
                name === name.toLowerCase()
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6125
                    ? name
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6126
                    : name + ' (capitalization error)'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6127
            );
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6128
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6129
        if (stack.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6130
            if (name === 'html') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6131
                stop('unexpected_a', token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6132
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6133
            x = tag.parent;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6134
            if (x) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6135
                if (x.indexOf(' ' + stack[stack.length - 1].name + ' ') < 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6136
                    stop('tag_a_in_b', token, name, x);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6137
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6138
            } else if (!option.adsafe && !option.fragment) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6139
                i = stack.length;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6140
                do {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6141
                    if (i <= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6142
                        stop('tag_a_in_b', token, name, 'body');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6143
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6144
                    i -= 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6145
                } while (stack[i].name !== 'body');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6146
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6147
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6148
        switch (name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6149
        case 'div':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6150
            if (option.adsafe && stack.length === 1 && !adsafe_id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6151
                warn('adsafe_missing_id');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6152
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6153
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6154
        case 'script':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6155
            xmode = 'script';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6156
            advance('>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6157
            if (attribute.lang) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6158
                warn('lang', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6159
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6160
            if (option.adsafe && stack.length !== 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6161
                warn('adsafe_placement', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6162
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6163
            if (attribute.src) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6164
                if (option.adsafe && (!adsafe_may || !approved[attribute.src])) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6165
                    warn('adsafe_source', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6166
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6167
                if (attribute.type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6168
                    warn('type', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6169
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6170
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6171
                step_in(next_token.from);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6172
                edge();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6173
                use_strict();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6174
                adsafe_top = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6175
                script = statements();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6176
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6177
// JSLint is also the static analyzer for ADsafe. See www.ADsafe.org.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6178
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6179
                if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6180
                    if (adsafe_went) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6181
                        stop('adsafe_script', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6182
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6183
                    if (script.length !== 1 ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6184
                            aint(script[0],             'id',     '(') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6185
                            aint(script[0].first,       'id',     '.') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6186
                            aint(script[0].first.first, 'string', 'ADSAFE') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6187
                            aint(script[0].second[0],   'string', adsafe_id)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6188
                        stop('adsafe_id_go');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6189
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6190
                    switch (script[0].first.second.string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6191
                    case 'id':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6192
                        if (adsafe_may || adsafe_went ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6193
                                script[0].second.length !== 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6194
                            stop('adsafe_id', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6195
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6196
                        adsafe_may = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6197
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6198
                    case 'go':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6199
                        if (adsafe_went) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6200
                            stop('adsafe_go');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6201
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6202
                        if (script[0].second.length !== 2 ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6203
                                aint(script[0].second[1], 'id', 'function') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6204
                                !script[0].second[1].first ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6205
                                script[0].second[1].first.length !== 2 ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6206
                                aint(script[0].second[1].first[0], 'string', 'dom') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6207
                                aint(script[0].second[1].first[1], 'string', 'lib')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6208
                            stop('adsafe_go', next_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6209
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6210
                        adsafe_went = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6211
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6212
                    default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6213
                        stop('adsafe_id_go');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6214
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6215
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6216
                indent = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6217
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6218
            xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6219
            advance('</');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6220
            advance_identifier('script');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6221
            xmode = 'outer';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6222
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6223
        case 'style':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6224
            xmode = 'style';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6225
            advance('>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6226
            styles();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6227
            xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6228
            advance('</');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6229
            advance_identifier('style');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6230
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6231
        case 'input':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6232
            switch (attribute.type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6233
            case 'button':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6234
            case 'checkbox':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6235
            case 'radio':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6236
            case 'reset':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6237
            case 'submit':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6238
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6239
            case 'file':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6240
            case 'hidden':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6241
            case 'image':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6242
            case 'password':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6243
            case 'text':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6244
                if (option.adsafe && attribute.autocomplete !== 'off') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6245
                    warn('adsafe_autocomplete');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6246
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6247
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6248
            default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6249
                warn('bad_type');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6250
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6251
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6252
        case 'applet':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6253
        case 'body':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6254
        case 'embed':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6255
        case 'frame':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6256
        case 'frameset':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6257
        case 'head':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6258
        case 'iframe':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6259
        case 'noembed':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6260
        case 'noframes':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6261
        case 'object':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6262
        case 'param':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6263
            if (option.adsafe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6264
                warn('adsafe_tag', next_token, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6265
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6266
            break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6267
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6268
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6269
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6270
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6271
    function closetag(name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6272
        return '</' + name + '>';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6273
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6274
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6275
    function html() {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6276
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6277
        /*jslint confusion: true */
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6278
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6279
        var attribute, attributes, is_empty, name, old_white = option.white,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6280
            quote, tag_name, tag, wmode;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6281
        xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6282
        xquote = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6283
        stack = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6284
        for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6285
            switch (next_token.string) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6286
            case '<':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6287
                xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6288
                advance('<');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6289
                attributes = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6290
                tag_name = next_token;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6291
                name = tag_name.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6292
                advance_identifier(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6293
                if (option.cap) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6294
                    name = name.toLowerCase();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6295
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6296
                tag_name.name = name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6297
                if (!stack) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6298
                    stack = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6299
                    do_begin(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6300
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6301
                tag = html_tag[name];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6302
                if (typeof tag !== 'object') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6303
                    stop('unrecognized_tag_a', tag_name, name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6304
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6305
                is_empty = tag.empty;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6306
                tag_name.type = name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6307
                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6308
                    if (next_token.id === '/') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6309
                        advance('/');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6310
                        if (next_token.id !== '>') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6311
                            warn('expected_a_b', next_token, '>', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6312
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6313
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6314
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6315
                    if (next_token.id && next_token.id.charAt(0) === '>') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6316
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6317
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6318
                    if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6319
                        if (next_token.id === '(end)' || next_token.id === '(error)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6320
                            warn('expected_a_b', next_token, '>', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6321
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6322
                        warn('bad_name_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6323
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6324
                    option.white = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6325
                    spaces();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6326
                    attribute = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6327
                    option.white = old_white;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6328
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6329
                    if (!option.cap && attribute !== attribute.toLowerCase()) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6330
                        warn('attribute_case_a', token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6331
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6332
                    attribute = attribute.toLowerCase();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6333
                    xquote = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6334
                    if (Object.prototype.hasOwnProperty.call(attributes, attribute)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6335
                        warn('duplicate_a', token, attribute);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6336
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6337
                    if (attribute.slice(0, 2) === 'on') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6338
                        if (!option.on) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6339
                            warn('html_handlers');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6340
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6341
                        xmode = 'scriptstring';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6342
                        advance('=');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6343
                        quote = next_token.id;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6344
                        if (quote !== '"' && quote !== '\'') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6345
                            stop('expected_a_b', next_token, '"', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6346
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6347
                        xquote = quote;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6348
                        wmode = option.white;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6349
                        option.white = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6350
                        advance(quote);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6351
                        use_strict();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6352
                        statements();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6353
                        option.white = wmode;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6354
                        if (next_token.id !== quote) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6355
                            stop('expected_a_b', next_token, quote, artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6356
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6357
                        xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6358
                        xquote = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6359
                        advance(quote);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6360
                        tag = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6361
                    } else if (attribute === 'style') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6362
                        xmode = 'scriptstring';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6363
                        advance('=');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6364
                        quote = next_token.id;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6365
                        if (quote !== '"' && quote !== '\'') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6366
                            stop('expected_a_b', next_token, '"', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6367
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6368
                        xmode = 'styleproperty';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6369
                        xquote = quote;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6370
                        advance(quote);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6371
                        substyle();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6372
                        xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6373
                        xquote = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6374
                        advance(quote);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6375
                        tag = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6376
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6377
                        if (next_token.id === '=') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6378
                            advance('=');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6379
                            tag = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6380
                            if (!next_token.identifier &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6381
                                    next_token.id !== '"' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6382
                                    next_token.id !== '\'' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6383
                                    next_token.id !== '(string)' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6384
                                    next_token.id !== '(string)' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6385
                                    next_token.id !== '(color)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6386
                                warn('expected_attribute_value_a', token, attribute);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6387
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6388
                            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6389
                        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6390
                            tag = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6391
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6392
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6393
                    attributes[attribute] = tag;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6394
                    do_attribute(attribute, tag);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6395
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6396
                do_tag(name, attributes);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6397
                if (!is_empty) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6398
                    stack.push(tag_name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6399
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6400
                xmode = 'outer';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6401
                advance('>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6402
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6403
            case '</':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6404
                xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6405
                advance('</');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6406
                if (!next_token.identifier) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6407
                    warn('bad_name_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6408
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6409
                name = next_token.string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6410
                if (option.cap) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6411
                    name = name.toLowerCase();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6412
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6413
                advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6414
                if (!stack) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6415
                    stop('unexpected_a', next_token, closetag(name));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6416
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6417
                tag_name = stack.pop();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6418
                if (!tag_name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6419
                    stop('unexpected_a', next_token, closetag(name));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6420
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6421
                if (tag_name.name !== name) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6422
                    stop('expected_a_b',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6423
                        next_token, closetag(tag_name.name), closetag(name));
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6424
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6425
                if (next_token.id !== '>') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6426
                    stop('expected_a_b', next_token, '>', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6427
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6428
                xmode = 'outer';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6429
                advance('>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6430
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6431
            case '<!':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6432
                if (option.safe) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6433
                    warn('adsafe_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6434
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6435
                xmode = 'html';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6436
                for (;;) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6437
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6438
                    if (next_token.id === '>' || next_token.id === '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6439
                        break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6440
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6441
                    if (next_token.string.indexOf('--') >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6442
                        stop('unexpected_a', next_token, '--');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6443
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6444
                    if (next_token.string.indexOf('<') >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6445
                        stop('unexpected_a', next_token, '<');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6446
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6447
                    if (next_token.string.indexOf('>') >= 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6448
                        stop('unexpected_a', next_token, '>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6449
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6450
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6451
                xmode = 'outer';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6452
                advance('>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6453
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6454
            case '(end)':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6455
                return;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6456
            default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6457
                if (next_token.id === '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6458
                    stop('missing_a', next_token,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6459
                        '</' + stack[stack.length - 1].string + '>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6460
                } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6461
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6462
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6463
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6464
            if (stack && stack.length === 0 && (option.adsafe ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6465
                    !option.fragment || next_token.id === '(end)')) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6466
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6467
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6468
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6469
        if (next_token.id !== '(end)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6470
            stop('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6471
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6472
    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6473
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6474
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6475
// The actual JSLINT function itself.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6476
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6477
    itself = function JSLint(the_source, the_option) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6478
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6479
        var i, predef, tree;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6480
        JSLINT.errors = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6481
        JSLINT.tree = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6482
        begin = prev_token = token = next_token =
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6483
            Object.create(syntax['(begin)']);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6484
        predefined = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6485
        add_to_predefined(standard);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6486
        property_type = Object.create(standard_property_type);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6487
        if (the_option) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6488
            option = Object.create(the_option);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6489
            predef = option.predef;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6490
            if (predef) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6491
                if (Array.isArray(predef)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6492
                    for (i = 0; i < predef.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6493
                        predefined[predef[i]] = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6494
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6495
                } else if (typeof predef === 'object') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6496
                    add_to_predefined(predef);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6497
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6498
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6499
            do_safe();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6500
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6501
            option = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6502
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6503
        option.indent = +option.indent || 4;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6504
        option.maxerr = +option.maxerr || 50;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6505
        adsafe_id = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6506
        adsafe_may = adsafe_top = adsafe_went = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6507
        approved = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6508
        if (option.approved) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6509
            for (i = 0; i < option.approved.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6510
                approved[option.approved[i]] = option.approved[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6511
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6512
        } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6513
            approved.test = 'test';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6514
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6515
        tab = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6516
        for (i = 0; i < option.indent; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6517
            tab += ' ';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6518
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6519
        global_scope = scope = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6520
        global_funct = funct = {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6521
            '(scope)': scope,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6522
            '(breakage)': 0,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6523
            '(loopage)': 0
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6524
        };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6525
        functions = [funct];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6526
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6527
        comments_off = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6528
        ids = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6529
        in_block = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6530
        indent = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6531
        json_mode = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6532
        lookahead = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6533
        member = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6534
        node_js = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6535
        prereg = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6536
        src = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6537
        stack = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6538
        strict_mode = false;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6539
        urls = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6540
        var_mode = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6541
        warnings = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6542
        xmode = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6543
        lex.init(the_source);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6544
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6545
        assume();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6546
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6547
        try {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6548
            advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6549
            if (next_token.id === '(number)') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6550
                stop('unexpected_a');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6551
            } else if (next_token.string.charAt(0) === '<') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6552
                html();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6553
                if (option.adsafe && !adsafe_went) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6554
                    warn('adsafe_go', this);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6555
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6556
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6557
                switch (next_token.id) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6558
                case '{':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6559
                case '[':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6560
                    json_mode = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6561
                    json_value();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6562
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6563
                case '@':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6564
                case '*':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6565
                case '#':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6566
                case '.':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6567
                case ':':
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6568
                    xmode = 'style';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6569
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6570
                    if (token.id !== '@' || !next_token.identifier ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6571
                            next_token.string !== 'charset' || token.line !== 1 ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6572
                            token.from !== 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6573
                        stop('css');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6574
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6575
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6576
                    if (next_token.id !== '(string)' &&
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6577
                            next_token.string !== 'UTF-8') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6578
                        stop('css');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6579
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6580
                    advance();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6581
                    semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6582
                    styles();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6583
                    break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6584
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6585
                default:
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6586
                    if (option.adsafe && option.fragment) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6587
                        stop('expected_a_b',
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6588
                            next_token, '<div>', artifact());
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6589
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6590
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6591
// If the first token is a semicolon, ignore it. This is sometimes used when
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6592
// files are intended to be appended to files that may be sloppy. A sloppy
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6593
// file may be depending on semicolon insertion on its last line.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6594
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6595
                    step_in(1);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6596
                    if (next_token.id === ';' && !node_js) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6597
                        semicolon();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6598
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6599
                    adsafe_top = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6600
                    tree = statements();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6601
                    begin.first = tree;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6602
                    JSLINT.tree = begin;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6603
                    // infer_types(tree);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6604
                    if (option.adsafe && (tree.length !== 1 ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6605
                            aint(tree[0], 'id', '(') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6606
                            aint(tree[0].first, 'id', '.') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6607
                            aint(tree[0].first.first, 'string', 'ADSAFE') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6608
                            aint(tree[0].first.second, 'string', 'lib') ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6609
                            tree[0].second.length !== 2 ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6610
                            tree[0].second[0].id !== '(string)' ||
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6611
                            aint(tree[0].second[1], 'id', 'function'))) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6612
                        stop('adsafe_lib');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6613
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6614
                    if (tree.disrupt) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6615
                        warn('weird_program', prev_token);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6616
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6617
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6618
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6619
            indent = null;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6620
            advance('(end)');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6621
        } catch (e) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6622
            if (e) {        // `~
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6623
                JSLINT.errors.push({
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6624
                    reason    : e.message,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6625
                    line      : e.line || next_token.line,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6626
                    character : e.character || next_token.from
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6627
                }, null);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6628
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6629
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6630
        return JSLINT.errors.length === 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6631
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6632
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6633
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6634
// Data summary.
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6635
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6636
    itself.data = function () {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6637
        var data = {functions: []},
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6638
            function_data,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6639
            globals,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6640
            i,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6641
            j,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6642
            kind,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6643
            members = [],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6644
            name,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6645
            the_function,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6646
            undef = [],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6647
            unused = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6648
        if (itself.errors.length) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6649
            data.errors = itself.errors;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6650
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6651
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6652
        if (json_mode) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6653
            data.json = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6654
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6655
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6656
        if (urls.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6657
            data.urls = urls;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6658
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6659
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6660
        globals = Object.keys(global_scope).filter(function (value) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6661
            return value.charAt(0) !== '(' && typeof standard[value] !== 'boolean';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6662
        });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6663
        if (globals.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6664
            data.globals = globals;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6665
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6666
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6667
        for (i = 1; i < functions.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6668
            the_function = functions[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6669
            function_data = {};
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6670
            for (j = 0; j < functionicity.length; j += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6671
                function_data[functionicity[j]] = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6672
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6673
            for (name in the_function) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6674
                if (Object.prototype.hasOwnProperty.call(the_function, name)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6675
                    if (name.charAt(0) !== '(') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6676
                        kind = the_function[name];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6677
                        if (kind === 'unction' || kind === 'unparam') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6678
                            kind = 'unused';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6679
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6680
                        if (Array.isArray(function_data[kind])) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6681
                            function_data[kind].push(name);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6682
                            if (kind === 'unused') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6683
                                unused.push({
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6684
                                    name: name,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6685
                                    line: the_function['(line)'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6686
                                    'function': the_function['(name)']
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6687
                                });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6688
                            } else if (kind === 'undef') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6689
                                undef.push({
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6690
                                    name: name,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6691
                                    line: the_function['(line)'],
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6692
                                    'function': the_function['(name)']
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6693
                                });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6694
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6695
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6696
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6697
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6698
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6699
            for (j = 0; j < functionicity.length; j += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6700
                if (function_data[functionicity[j]].length === 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6701
                    delete function_data[functionicity[j]];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6702
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6703
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6704
            function_data.name = the_function['(name)'];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6705
            function_data.params = the_function['(params)'];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6706
            function_data.line = the_function['(line)'];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6707
            function_data['(complexity)'] = the_function['(complexity)'];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6708
            data.functions.push(function_data);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6709
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6710
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6711
        if (unused.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6712
            data.unused = unused;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6713
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6714
        if (undef.length > 0) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6715
            data['undefined'] = undef;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6716
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6717
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6718
        members = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6719
        for (name in member) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6720
            if (typeof member[name] === 'number') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6721
                data.member = member;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6722
                break;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6723
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6724
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6725
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6726
        return data;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6727
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6728
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6729
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6730
    itself.report = function (errors_only) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6731
        var data = itself.data(), err, evidence, i, italics, j, key, keys, length,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6732
            mem = '', name, names, output = [], snippets, the_function, type,
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6733
            warning;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6734
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6735
        function detail(h, value) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6736
            var comma_needed, singularity;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6737
            if (Array.isArray(value)) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6738
                output.push('<div><i>' + h + '</i> ');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6739
                value.sort().forEach(function (item) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6740
                    if (item !== singularity) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6741
                        singularity = item;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6742
                        output.push((comma_needed ? ', ' : '') + singularity);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6743
                        comma_needed = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6744
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6745
                });
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6746
                output.push('</div>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6747
            } else if (value) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6748
                output.push('<div><i>' + h + '</i> ' + value + '</div>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6749
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6750
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6751
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6752
        if (data.errors || data.unused || data['undefined']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6753
            err = true;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6754
            output.push('<div id=errors><i>Error:</i>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6755
            if (data.errors) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6756
                for (i = 0; i < data.errors.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6757
                    warning = data.errors[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6758
                    if (warning) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6759
                        evidence = warning.evidence || '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6760
                        output.push('<p>Problem' + (isFinite(warning.line)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6761
                            ? ' at line ' + String(warning.line) +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6762
                                ' character ' + String(warning.character)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6763
                            : '') +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6764
                            ': ' + warning.reason.entityify() +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6765
                            '</p><p class=evidence>' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6766
                            (evidence && (evidence.length > 80
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6767
                                ? evidence.slice(0, 77) + '...'
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6768
                                : evidence).entityify()) + '</p>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6769
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6770
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6771
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6772
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6773
            if (data['undefined']) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6774
                snippets = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6775
                for (i = 0; i < data['undefined'].length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6776
                    snippets[i] = '<code><u>' + data['undefined'][i].name + '</u></code>&nbsp;<i>' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6777
                        String(data['undefined'][i].line) + ' </i> <small>' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6778
                        data['undefined'][i]['function'] + '</small>';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6779
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6780
                output.push('<p><i>Undefined variable:</i> ' + snippets.join(', ') + '</p>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6781
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6782
            if (data.unused) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6783
                snippets = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6784
                for (i = 0; i < data.unused.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6785
                    snippets[i] = '<code><u>' + data.unused[i].name + '</u></code>&nbsp;<i>' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6786
                        String(data.unused[i].line) + ' </i> <small>' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6787
                        data.unused[i]['function'] + '</small>';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6788
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6789
                output.push('<p><i>Unused variable:</i> ' + snippets.join(', ') + '</p>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6790
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6791
            if (data.json) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6792
                output.push('<p>JSON: bad.</p>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6793
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6794
            output.push('</div>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6795
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6796
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6797
        if (!errors_only) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6798
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6799
            output.push('<br><div id=functions>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6800
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6801
            if (data.urls) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6802
                detail("URLs<br>", data.urls, '<br>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6803
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6804
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6805
            if (xmode === 'style') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6806
                output.push('<p>CSS.</p>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6807
            } else if (data.json && !err) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6808
                output.push('<p>JSON: good.</p>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6809
            } else if (data.globals) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6810
                output.push('<div><i>Global</i> ' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6811
                    data.globals.sort().join(', ') + '</div>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6812
            } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6813
                output.push('<div><i>No new global variables introduced.</i></div>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6814
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6815
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6816
            for (i = 0; i < data.functions.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6817
                the_function = data.functions[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6818
                names = [];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6819
                if (the_function.params) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6820
                    for (j = 0; j < the_function.params.length; j += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6821
                        names[j] = the_function.params[j].string;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6822
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6823
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6824
                output.push('<br><div class=function><i>' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6825
                    String(the_function.line) + '</i> ' +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6826
                    the_function.name.entityify() +
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6827
                    '(' + names.join(', ') + ')</div>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6828
                detail('<big><b>Undefined</b></big>', the_function['undefined']);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6829
                detail('<big><b>Unused</b></big>', the_function.unused);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6830
                detail('Closure', the_function.closure);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6831
                detail('Variable', the_function['var']);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6832
                detail('Exception', the_function.exception);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6833
                detail('Outer', the_function.outer);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6834
                detail('Global', the_function.global);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6835
                detail('Label', the_function.label);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6836
                detail('Complexity', the_function['(complexity)']);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6837
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6838
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6839
            if (data.member) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6840
                keys = Object.keys(data.member);
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6841
                if (keys.length) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6842
                    keys = keys.sort();
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6843
                    output.push('<br><pre id=properties>/*properties<br>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6844
                    mem = '    ';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6845
                    italics = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6846
                    j = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6847
                    if (option.confusion) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6848
                        for (i = 0; i < keys.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6849
                            key = keys[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6850
                            if (typeof standard_property_type[key] !== 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6851
                                name = ix.test(key)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6852
                                    ? key
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6853
                                    : '\'' + key.entityify().replace(nx, sanitize) + '\'';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6854
                                if (data.member[key] === 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6855
                                    name = '<i>' + name + '</i>';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6856
                                    italics += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6857
                                    j = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6858
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6859
                                if (i < keys.length - 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6860
                                    name += ', ';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6861
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6862
                                if (mem.length + name.length - (italics * 7) > 80) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6863
                                    output.push(mem + '<br>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6864
                                    mem = '    ';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6865
                                    italics = j;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6866
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6867
                                mem += name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6868
                                j = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6869
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6870
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6871
                    } else {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6872
                        for (i = 0; i < keys.length; i += 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6873
                            key = keys[i];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6874
                            type = property_type[key];
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6875
                            if (typeof type !== 'string') {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6876
                                type = '';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6877
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6878
                            if (standard_property_type[key] !== type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6879
                                name = ix.test(key)
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6880
                                    ? key
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6881
                                    : '\'' + key.entityify().replace(nx, sanitize) + '\'';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6882
                                length += name.length + 2;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6883
                                if (data.member[key] === 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6884
                                    name = '<i>' + name + '</i>';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6885
                                    italics += 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6886
                                    j = 1;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6887
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6888
                                if (type) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6889
                                    name += ': ' + type;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6890
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6891
                                if (i < keys.length - 1) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6892
                                    name += ', ';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6893
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6894
                                if (mem.length + name.length - (italics * 7) > 80) {
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6895
                                    output.push(mem + '<br>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6896
                                    mem = '    ';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6897
                                    italics = j;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6898
                                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6899
                                mem += name;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6900
                                j = 0;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6901
                            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6902
                        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6903
                    }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6904
                    output.push(mem + '<br>*/</pre>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6905
                }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6906
                output.push('</div>');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6907
            }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6908
        }
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6909
        return output.join('');
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6910
    };
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6911
    itself.jslint = itself;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6912
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6913
    itself.edition = '2011-10-17';
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6914
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6915
    return itself;
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6916
62612c69699f added jslint to the build.
hamidouk
parents:
diff changeset
  6917
}());