To focus the search input from anywhere on the page, press the 'S' key.
in-package search v0.1.0
Library
Module
Module type
Parameter
Class
Class type
This module provides a type that represents a Python expression.
type ('arguments, 'bin_op, 'bool_op, 'compare, 'comprehension, 'constant, 'expr_context, 'identifier, 'keyword, 'location, 'unary_op, 'expr)
t =
private {
bool_op : location:'location -> op:'bool_op -> values:'expr list -> 'expr;
(*Represents a boolean expression.
- Example:
a and b
- Example:
a or b or c
- Example:
named_expr : location:'location -> target:'expr -> value:'expr -> 'expr;
(*Represents an assignment expression, a.k.a. the "walrus" operator.
target
is guaranteed by the CPython parser to always be a simple identifier. See PEP 572.- Example:
(a := b)
- Example:
bin_op : location:'location -> left:'expr -> op:'bin_op -> right:'expr -> 'expr;
(*Represents a numerical binary expression.
- Example:
a + b
- Example:
unary_op : location:'location -> op:'unary_op -> operand:'expr -> 'expr;
(*Represents an unary expression.
- Example:
not a
- Example:
lambda : location:'location -> args:'arguments -> body:'expr -> 'expr;
if_exp : location:'location -> test:'expr -> body:'expr -> orelse:'expr -> 'expr;
dict : location:'location -> keys:'expr option list -> values:'expr list -> 'expr;
(*Represents a Python dictionary display.
- Example:
{}
- Example:
{ "a": 1, "b": 2 }
- Example:
{ "a": 1, **b }
. The element**b
here will be represented with aNone
key and a value ofb
.
- Example:
set : location:'location -> elts:'expr list -> 'expr;
(*Represents a Python set display.
- Example:
{ "a", "b" }
- Example:
list_comp : location:'location -> elt:'expr -> generators:'comprehension list -> 'expr;
(*Represents a list comprehension. See PEP 202.
- Example:
[y for x in l if len(x) > 1 for y in x if y < 4]
- Example:
set_comp : location:'location -> elt:'expr -> generators:'comprehension list -> 'expr;
(*Represents a set comprehension.
- Example:
{x for x in l}
- Example:
dict_comp : location:'location -> key:'expr -> value:'expr -> generators:'comprehension list -> 'expr;
generator_exp : location:'location -> elt:'expr -> generators:'comprehension list -> 'expr;
await : location:'location -> value:'expr -> 'expr;
yield : location:'location -> value:'expr option -> 'expr;
yield_from : location:'location -> value:'expr -> 'expr;
compare : location:'location -> left:'expr -> ops:'compare list -> comparators:'expr list -> 'expr;
(*Represents a comparison expression.
- Example:
x is y
- Example:
x > y > z
- Example:
call : location:'location -> func:'expr -> args:'expr list -> keywords:'keyword list -> 'expr;
(*Represents a call expression, where
args
is the list of positionally-specified arguments, andkeywords
is the list of keyword-specified arguments.- Example:
foo(x, y=1)
- Example:
foo(x, *y, **z)
- Example:
formatted_value : location:'location -> value:'expr -> conversion:int -> format_spec:'expr option -> 'expr;
(*Represents the expression component of an f-string. See PEP 498.
conversion
is an integer representing the type conversion operator:-1
means no formatting.115
means!s
string formatting.114
means!r
repr formatting97
means!a
ascii formatting
format_spec
represents the format specifier. This is always going to be ajoined_str
expression.- Example:
f"derp={a+b:{foo}}"
. The entire expression will be ajoined_str
but thea+b
part will be represented as aformatted_value
with thefoo
part as its format specifier.
joined_str : location:'location -> values:'expr list -> 'expr;
constant : location:'location -> value:'constant -> kind:string option -> 'expr;
(*Represents a constant expression.
- Example:
42
- Example:
attribute : location:'location -> value:'expr -> attr:'identifier -> ctx:'expr_context -> 'expr;
(*Represents an attribute access expression.
- Example:
a.b
- Example:
subscript : location:'location -> value:'expr -> slice:'expr -> ctx:'expr_context -> 'expr;
(*Represents a subscript access expression.
- Example:
a[b]
- Example:
starred : location:'location -> value:'expr -> ctx:'expr_context -> 'expr;
(*Represents an starred expression, which is used to represent iterable unpacking (inside
*)call
,list
, or comprehension expressions, for example). See PEP 448.name : location:'location -> id:'identifier -> ctx:'expr_context -> 'expr;
(*Represents a simple identifier.
- Example:
a
- Example:
list : location:'location -> elts:'expr list -> ctx:'expr_context -> 'expr;
(*Represents a Python list display.
- Example:
[]
- Example:
[a, b]
- Example:
[a, *b]
- Example:
tuple : location:'location -> elts:'expr list -> ctx:'expr_context -> 'expr;
(*Represents a Python tuple display.
- Example:
()
- Example:
(a, b)
- Example:
(a, *b)
- Example:
slice : location:'location -> lower:'expr option -> upper:'expr option -> step:'expr option -> 'expr;
(*Represents a slice expression. This kind of expression can only appear within the
slice
field of thesubscript
expression, either directly or as an element of atuple
expression.- Example:
a[:]
- Example:
a[1:2, 3:4]
- Example:
}
val make :
bool_op:(location:'a -> op:'b -> values:'c list -> 'c) ->
named_expr:(location:'a -> target:'c -> value:'c -> 'c) ->
bin_op:(location:'a -> left:'c -> op:'d -> right:'c -> 'c) ->
unary_op:(location:'a -> op:'e -> operand:'c -> 'c) ->
lambda:(location:'a -> args:'f -> body:'c -> 'c) ->
if_exp:(location:'a -> test:'c -> body:'c -> orelse:'c -> 'c) ->
dict:(location:'a -> keys:'c option list -> values:'c list -> 'c) ->
set:(location:'a -> elts:'c list -> 'c) ->
list_comp:(location:'a -> elt:'c -> generators:'g list -> 'c) ->
set_comp:(location:'a -> elt:'c -> generators:'g list -> 'c) ->
dict_comp:(location:'a -> key:'c -> value:'c -> generators:'g list -> 'c) ->
generator_exp:(location:'a -> elt:'c -> generators:'g list -> 'c) ->
await:(location:'a -> value:'c -> 'c) ->
yield:(location:'a -> value:'c option -> 'c) ->
yield_from:(location:'a -> value:'c -> 'c) ->
compare:(location:'a -> left:'c -> ops:'h list -> comparators:'c list -> 'c) ->
call:(location:'a -> func:'c -> args:'c list -> keywords:'i list -> 'c) ->
formatted_value:
(location:'a -> value:'c -> conversion:int -> format_spec:'c option -> 'c) ->
joined_str:(location:'a -> values:'c list -> 'c) ->
constant:(location:'a -> value:'j -> kind:string option -> 'c) ->
attribute:(location:'a -> value:'c -> attr:'k -> ctx:'l -> 'c) ->
subscript:(location:'a -> value:'c -> slice:'c -> ctx:'l -> 'c) ->
starred:(location:'a -> value:'c -> ctx:'l -> 'c) ->
name:(location:'a -> id:'k -> ctx:'l -> 'c) ->
list:(location:'a -> elts:'c list -> ctx:'l -> 'c) ->
tuple:(location:'a -> elts:'c list -> ctx:'l -> 'c) ->
slice:
(location:'a -> lower:'c option -> upper:'c option -> step:'c option -> 'c) ->
unit ->
('f, 'd, 'b, 'h, 'g, 'j, 'l, 'k, 'i, 'a, 'e, 'c) t
Constructor of t
.