Permalink
Browse files

Add language and mode information to ParserEnv.t

Summary: We want to expose this information to smart constructors. Eg. drop the whole file in decl mode smart constructors when parsing PHP files.

Reviewed By: andrewjkennedy

Differential Revision: D7288058

fbshipit-source-id: c2302ea9f017dbdba7eb0b1838d09e5c42e2f457
  • Loading branch information...
lionell authored and hhvm-bot committed Mar 16, 2018
1 parent e8db14a commit d58567884bd70eeb3d56f22ea6a0787199d32eed
@@ -830,7 +830,7 @@ module WithSyntax(Syntax : Syntax_sig.Syntax_S) = struct
let make_missing (s, o) state = State.next state [], Syntax.make_missing s o
let make_list (s, o) items state =
if items <> []
then State.next state [], Syntax.make_list s o items
then State.next state items, Syntax.make_list s o items
else make_missing (s, o) state
CONSTRUCTOR_METHODS
end (* WithState *)
@@ -11,22 +11,30 @@
type t = {
hhvm_compat_mode: bool;
php5_compat_mode: bool;
lang: FileInfo.file_type option;
mode: FileInfo.mode option;
stats: Stats_container.t option;
}
let default = {
hhvm_compat_mode = false;
php5_compat_mode = false;
lang = None;
mode = None;
stats = None;
}
let make
?(hhvm_compat_mode = default.hhvm_compat_mode)
?(php5_compat_mode = default.php5_compat_mode)
?lang
?mode
?stats
() =
{ hhvm_compat_mode; php5_compat_mode; stats; }
{ hhvm_compat_mode; php5_compat_mode; lang; mode; stats }
let hhvm_compat_mode e = e.hhvm_compat_mode
let php5_compat_mode e = e.php5_compat_mode
let lang e = e.lang
let mode e = e.mode
let stats e = e.stats
@@ -42,7 +42,7 @@ module WithSyntax(Syntax : Syntax_sig.Syntax_S) = struct
let make_missing (s, o) state = State.next state [], Syntax.make_missing s o
let make_list (s, o) items state =
if items <> []
then State.next state [], Syntax.make_list s o items
then State.next state items, Syntax.make_list s o items
else make_missing (s, o) state
let make_end_of_file arg0 state = State.next state [arg0], Syntax.make_end_of_file arg0
let make_script arg0 state = State.next state [arg0], Syntax.make_script arg0

0 comments on commit d585678

Please sign in to comment.