@@ -105,21 +105,21 @@ and statement =
105105 Block of block
106106 | Variable_statement of variable_declaration list
107107 | Empty_statement
108- | Expression_statement of expression
109- | If_statement of expression * (statement * location) * (statement * location) option
110- | Do_while_statement of (statement * location) * expression
108+ | Expression_statement of expression
109+ | If_statement of expression * (statement * location) * (statement * location) option
110+ | Do_while_statement of (statement * location) * expression
111111 | While_statement of expression * (statement * location)
112112 | For_statement of (expression option ,variable_declaration list ) either * expression option * expression option * (statement * location)
113113 | ForIn_statement of (expression,variable_declaration) either * expression * (statement * location)
114- | Continue_statement of Label. t option
115- | Break_statement of Label. t option
116- | Return_statement of expression option
114+ | Continue_statement of Label. t option
115+ | Break_statement of Label. t option
116+ | Return_statement of expression option
117117 (* | With_statement of expression * statement *)
118118 | Labelled_statement of Label. t * (statement * location)
119119 | Switch_statement of
120120 expression * case_clause list * statement_list option * case_clause list
121- | Throw_statement of expression
122- | Try_statement of block * (ident * block) option * block option
121+ | Throw_statement of expression
122+ | Try_statement of block * (ident * block) option * block option
123123 | Debugger_statement
124124
125125and ('left,'right) either =
@@ -205,5 +205,23 @@ let string_of_number v =
205205 then s2
206206 else Printf. sprintf " %.18g" v
207207
208+ let is_ident =
209+ let l = Array. init 256 (fun i ->
210+ let c = Char. chr i in
211+ if (c > = 'a' && c < = 'z' ) || (c > = 'A' && c < = 'Z' ) || c = '_' || c = '$'
212+ then 1
213+ else if (c > = '0' && c < = '9' )
214+ then 2
215+ else 0
216+ ) in
217+ fun s ->
218+ try
219+ for i = 0 to String. length s - 1 do
220+ let code = l.(Char. code(s.[i])) in
221+ if i = 0 then assert (code = 1 ) else assert (code > = 1 )
222+ done ;
223+ true
224+ with _ -> false
225+
208226module IdentSet = Set. Make (struct type t = ident let compare = compare_ident end )
209227module IdentMap = Map. Make (struct type t = ident let compare = compare_ident end )
0 commit comments