Permalink
Browse files

[fix] compiler, jsparser: Parse comments optionnaly (avoid useless no…

…de, for extralibs)
  • Loading branch information...
BourgerieQuentin committed Sep 5, 2012
1 parent 2e6a39f commit dbb3a626b9e2bbbce0f97a5d8c8817fbf1e38da6
@@ -1,5 +1,5 @@
(*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of Opa.
@@ -151,5 +151,5 @@ val stream : string -> bool -> Lexing.lexbuf -> token Stream.t
These high level functions automatically init the lexer
when called
*)
-val stream_of_file : ?lex_comments:bool -> string -> token Stream.t * Lexing.lexbuf
-val stream_of_string : ?filename:string -> ?lex_comments:bool -> string -> token Stream.t * Lexing.lexbuf
+val stream_of_file : ?comments:bool -> string -> token Stream.t * Lexing.lexbuf
+val stream_of_string : ?filename:string -> ?comments:bool -> string -> token Stream.t * Lexing.lexbuf
View
@@ -1,5 +1,5 @@
(*
- copyright © 2011 MLstate
+ copyright © 2011, 2012 MLstate
This file is part of Opa.
@@ -761,17 +761,17 @@ let stream filename lex_comments lexbuf =
| t -> Some t
)
-let stream_of_file ?(lex_comments=false) filename =
+let stream_of_file ?(comments=false) filename =
try
let content = File.content filename in
FilePos.add_file filename content;
let lexbuf = Lexing.from_string content in
- stream filename lex_comments lexbuf, lexbuf
+ stream filename comments lexbuf, lexbuf
with Sys_error diagnostic ->
Printf.printf "Couldn't open file %s: %s\n%!" filename diagnostic;
exit 1
-let stream_of_string ?(filename="nofile") ?(lex_comments=false) string =
+let stream_of_string ?(filename="nofile") ?(comments=false) string =
let lexbuf = Lexing.from_string string in
- stream filename lex_comments lexbuf, lexbuf
+ stream filename comments lexbuf, lexbuf
}
View
@@ -669,31 +669,31 @@ let global_expr ?(globalize=false) expr =
else
expr
-let stream_of_file lex_comments file =
+let stream_of_file ?comments file =
try
- JsLex.stream_of_file ~lex_comments:lex_comments file
+ JsLex.stream_of_file ?comments file
with
| Unix.Unix_error _ -> raise (Exception (FileError file))
module String =
struct
- let code ?filename ?throw_exn str =
+ let code ?comments ?filename ?throw_exn str =
build_parser ?throw_exn code
- (JsLex.stream_of_string ?filename ~lex_comments:true str)
- let expr ?filename ?throw_exn ?globalize str =
+ (JsLex.stream_of_string ?filename ?comments str)
+ let expr ?comments ?filename ?throw_exn ?globalize str =
build_parser ?throw_exn ~globalize:(global_expr ?globalize)
- expr (JsLex.stream_of_string ?filename ~lex_comments:true str)
- let stm ?filename ?throw_exn str =
+ expr (JsLex.stream_of_string ?filename ?comments str)
+ let stm ?comments ?filename ?throw_exn str =
build_parser ?throw_exn stm
- (JsLex.stream_of_string ?filename ~lex_comments:true str)
+ (JsLex.stream_of_string ?filename ?comments str)
end
module File =
struct
- let code ?throw_exn file =
- build_parser ?throw_exn code (stream_of_file true file)
- let expr ?throw_exn ?globalize file =
+ let code ?comments ?throw_exn file =
+ build_parser ?throw_exn code (stream_of_file ?comments file)
+ let expr ?comments ?throw_exn ?globalize file =
build_parser ?throw_exn ~globalize:(global_expr ?globalize) expr
- (stream_of_file true file)
- let stm ?throw_exn file =
- build_parser ?throw_exn stm (stream_of_file true file)
+ (stream_of_file ?comments file)
+ let stm ?comments ?throw_exn file =
+ build_parser ?throw_exn stm (stream_of_file ?comments file)
end
@@ -1,5 +1,5 @@
(*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of Opa.
@@ -47,14 +47,14 @@ val pp : Format.formatter -> error -> unit
module String :
sig
- val code : ?filename:string -> ?throw_exn:bool -> string -> JsAst.code
- val expr : ?filename:string -> ?throw_exn:bool -> ?globalize:bool -> string -> JsAst.expr
- val stm : ?filename:string -> ?throw_exn:bool -> string -> JsAst.statement
+ val code : ?comments:bool -> ?filename:string -> ?throw_exn:bool -> string -> JsAst.code
+ val expr : ?comments:bool -> ?filename:string -> ?throw_exn:bool -> ?globalize:bool -> string -> JsAst.expr
+ val stm : ?comments:bool -> ?filename:string -> ?throw_exn:bool -> string -> JsAst.statement
end
module File :
sig
- val code : ?throw_exn:bool -> string -> JsAst.code
- val expr : ?throw_exn:bool -> ?globalize:bool -> string -> JsAst.expr
- val stm : ?throw_exn:bool -> string -> JsAst.statement
+ val code : ?comments:bool -> ?throw_exn:bool -> string -> JsAst.code
+ val expr : ?comments:bool -> ?throw_exn:bool -> ?globalize:bool -> string -> JsAst.expr
+ val stm : ?comments:bool -> ?throw_exn:bool -> string -> JsAst.statement
end
@@ -402,15 +402,15 @@ let process code =
let parse_file filename =
try
- let code = JsParse.File.code ~throw_exn:true filename in
+ let code = JsParse.File.code ~comments:true ~throw_exn:true filename in
process code
with
JsParse.Exception e ->
`error (Format.to_string JsParse.pp e)
let parse_string ?filename content =
try
- let code = JsParse.String.code ?filename ~throw_exn:true content in
+ let code = JsParse.String.code ~comments:true ?filename ~throw_exn:true content in
process code
with
JsParse.Exception e ->

0 comments on commit dbb3a62

Please sign in to comment.