Skip to content

Commit

Permalink
Add language and mode information to ParserEnv.t
Browse files Browse the repository at this point in the history
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
Ruslan Sakevych authored and hhvm-bot committed Mar 16, 2018
1 parent e8db14a commit d585678
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hphp/hack/src/generate_full_fidelity.ml
Expand Up @@ -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 *)
Expand Down
10 changes: 9 additions & 1 deletion hphp/hack/src/parser/full_fidelity_parser_env.ml
Expand Up @@ -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
Expand Up @@ -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
Expand Down

0 comments on commit d585678

Please sign in to comment.