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.t, Error.t) Stdlib.result
parse_module ~context input
takes the stringinput
and parse into a Python module. See documentation ofContext.t
for the meaning of thecontext
argument.Optionally an
enable_type_comment
argument can be specified. If it is true, the parser will attempt to populate thetype_comment
section of each AST node that has it. Otherwise, contents in comments will all get ignored andtype_comment
will always be unset.Calling this function is equivalent to calling
TaglessFinal.parse_module
withspec
set to the return value ofPyreAst.Concrete.make_tagless_final
.
val parse_expression : context:Context.t -> string -> (Concrete.Expression.t, Error.t) Stdlib.result
parse_expression ~context ~spec input
takes the stringinput
and parse it into a Python expression . See documentation ofContext.t
for the meaning of thecontext
argument.Calling this function is equivalent to calling
TaglessFinal.parse_expression
withspec
set to the return value ofPyreAst.Concrete.make_tagless_final
.
val parse_function_type : context:Context.t -> string -> (Concrete.FunctionType.t, Error.t) Stdlib.result
parse_expression ~context ~spec input
takes the stringinput
and parse it into a Python function type signature. See documentation ofContext.t
for the meaning of thecontext
argument, and see documentation ofTaglessFinal.parse_function_type
for the meaning of "function type signature".Calling this function is equivalent to calling
TaglessFinal.parse_function_type
withspec
set to the return value ofPyreAst.Concrete.make_tagless_final
.