Module Parser.Concrete

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 -> ?⁠enable_type_comment:bool -> string -> (Concrete.Module.tError.t) Stdlib.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 an enable_type_comment argument can be specified. If it is true, the parser will attempt to populate the type_comment section of each AST node that has it. Otherwise, contents in comments will all get ignored and type_comment will always be unset.

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.tError.t) Stdlib.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.tError.t) Stdlib.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.