Skip to content

Instantly share code, notes, and snippets.

@jeffmo
Last active November 2, 2017 21:40
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffmo/e0b6858473209f3dd1d73ec04ac9f77e to your computer and use it in GitHub Desktop.
Save jeffmo/e0b6858473209f3dd1d73ec04ac9f77e to your computer and use it in GitHub Desktop.

Parser

  • /src/parser/spider_monkey_ast.ml: The type definitions for the AST. Tries to stay very close to ESTree
  • /src/parser/lexer_flow.mll: The ocamllex lexer logic
  • /src/parser/parser_flow.ml: The recursive descent JS parser

Inference

  • /src/typing/type_inference_js.ml: Contains the "entry point" for inference (Function called infer_ast).
  • /src/typing/statement.ml: Most of the inference logic (runs through the AST and generates the initial constraints)
  • /src/typing/env_js.ml: Most of the environment logic. An inference "env" is basically a stack of scopes -- which are defined in scope.ml.

Checking/constraint solver

  • /src/typing/flow_js.ml: Contains the massive pattern-match that defines the various rules for what to do during the "evaluation" phase when we encounter any given flow constraint. Helpful hint: Flow constraints are defined in terms of 2 types: A "lower bound" and an "upper bound". The "lower bound" is the type that flows into the "upper bound". When you see variables named l that often means "lower bound", and u often means "upper bound".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment