atomlib.expr
NUMERIC_OPS
module-attribute
NUMERIC_OPS: Sequence[Op[SupportsNum]] = [
BinaryOrUnaryOp(["-"], sub, False, 5),
BinaryOp(["+"], add, 5),
BinaryOp(["*"], mul, 6),
BinaryOp(["/"], truediv, 6),
BinaryOp(["//"], floordiv, 6),
BinaryOp(["^", "**"], pow, 7),
]
BOOLEAN_OPS
module-attribute
BOOLEAN_OPS: Sequence[Op[SupportsBool]] = [
BinaryOp(["=", "=="], eq, 3),
BinaryOp(["!=", "<>"], ne, 3),
BinaryOp(["|", "||"], or_, 4),
BinaryOp(["&", "&&"], and_, 5),
BinaryOp(["^"], xor, 6),
UnaryOp(["!", "~"], invert),
]
BOOLEAN_PARSER
module-attribute
BOOLEAN_PARSER = Parser(BOOLEAN_OPS, parse_boolean)
Parser for boolean expressions ([1 || false && true])
VECTOR_OPS
module-attribute
VECTOR_OPS: Sequence[Op[ndarray]] = [
*cast(Op[ndarray], op)
for op in NUMERIC_OPS,
NaryOp([","], call=stack, precedence=3),
]
VECTOR_PARSER
module-attribute
VECTOR_PARSER = Parser(
VECTOR_OPS, lambda v: array(parse_numeric(v))
)
VariadicCallable
Op
dataclass
Source code in atomlib/expr.py
NaryOp
dataclass
Bases: Op[V]
Source code in atomlib/expr.py
precedes
BinaryOp
dataclass
Bases: Op[V]
Source code in atomlib/expr.py
precedes
Returns true if self is higher precedence than other. Handles a tie using the associativity of self.
Source code in atomlib/expr.py
UnaryOp
dataclass
Bases: Op[V]
Source code in atomlib/expr.py
BinaryOrUnaryOp
dataclass
Bases: BinaryOp[V]
, UnaryOp[V]
Source code in atomlib/expr.py
precedes
Returns true if self is higher precedence than other. Handles a tie using the associativity of self.
Source code in atomlib/expr.py
Token
dataclass
Source code in atomlib/expr.py
OpToken
dataclass
GroupOpenToken
dataclass
GroupCloseToken
dataclass
WhitespaceToken
dataclass
ValueToken
dataclass
Expr
Source code in atomlib/expr.py
UnaryExpr
dataclass
Bases: Expr[T_co, V]
Source code in atomlib/expr.py
BinaryExpr
dataclass
Bases: Expr[T_co, V]
Source code in atomlib/expr.py
NaryExpr
dataclass
Bases: Expr[T_co, V]
Source code in atomlib/expr.py
GroupExpr
dataclass
Bases: Expr[T_co, V]
Source code in atomlib/expr.py
ValueExpr
dataclass
Bases: Expr[T_co, V]
Source code in atomlib/expr.py
Parser
dataclass
Bases: Generic[T_co, V]
Source code in atomlib/expr.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
|
parse_scalar
instance-attribute
token_re
class-attribute
instance-attribute
Regex matching operators, brackets, and whitespace
ParseState
Bases: Generic[T_co, V]
Source code in atomlib/expr.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
|
empty
empty() -> bool
peek
collect_wspace
collect_wspace() -> str
make_token
Source code in atomlib/expr.py
next
parse_expr
parse_expr() -> Expr[T_co, V]
parse_nary
NARY := { BINARY_OP | NARY_OP, ( PRIMARY, ? higher precedence NARY ? ) }
Source code in atomlib/expr.py
parse_primary
parse_primary() -> Expr[T_co, V]
PRIMARY := GROUP_OPEN, EXPR, GROUP_CLOSE | UNARY_OP, PRIMARY | SCALAR
Source code in atomlib/expr.py
SupportsBool
Bases: Protocol
Source code in atomlib/expr.py
SupportsNum
Bases: Protocol
Source code in atomlib/expr.py
interleave
parse_numeric
sub
sub(lhs: SupportsNum, rhs: Optional[SupportsNum] = None)
add
add(lhs: SupportsNum, rhs: Optional[SupportsNum] = None)