package pyre-ast

  1. Overview
  2. Docs

This module provides parsing APIs for downstream clients that are written in the traditional "initial" style which expects a concrete ADT representation for abstract syntax trees.

Logic in this module is implemented entirely on top of the tagless-final APIs provided in the Parser.TaglessFinal module.

val parse_module : context:Context.t -> ?filename:string -> string -> (Concrete.Module.t, Error.t) result

parse_module ~context input takes the string input and parse into a Python module. See documentation of Context.t for the meaning of the context argument.

Optionally a filename argument can be specified. If there is a parse error, filename will appear in the Error.t.message field.

Calling this function is equivalent to calling TaglessFinal.parse_module with spec set to the return value of PyreAst.Concrete.make_tagless_final.

val parse_expression : context:Context.t -> string -> (Concrete.Expression.t, Error.t) result

parse_expression ~context ~spec input takes the string input and parse it into a Python expression . See documentation of Context.t for the meaning of the context argument.

Calling this function is equivalent to calling TaglessFinal.parse_expression with spec set to the return value of PyreAst.Concrete.make_tagless_final.

val parse_function_type : context:Context.t -> string -> (Concrete.FunctionType.t, Error.t) result

parse_expression ~context ~spec input takes the string input and parse it into a Python function type signature. See documentation of Context.t for the meaning of the context argument, and see documentation of TaglessFinal.parse_function_type for the meaning of "function type signature".

Calling this function is equivalent to calling TaglessFinal.parse_function_type with spec set to the return value of PyreAst.Concrete.make_tagless_final.

OCaml

Innovation. Community. Security.