JustBash.Arithmetic.Parser (JustBash v0.4.0)

View Source

Recursive descent parser for bash arithmetic expressions.

Parses arithmetic expression strings into AST nodes. Handles operator precedence through the grammar structure:

Expression precedence (lowest to highest):

  1. Comma (,)
  2. Ternary (?:)
  3. Logical OR (||)
  4. Logical AND (&&)
  5. Bitwise OR (|)
  6. Bitwise XOR (^)
  7. Bitwise AND (&)
  8. Equality (==, !=)
  9. Relational (<, <=, >, >=)
  10. Shift (<<, >>)
  11. Additive (+, -)
  12. Multiplicative (*, /, %)
  13. Power (**)
  14. Unary (!, ~, -, +, ++, --)
  15. Postfix (++, --)
  16. Primary (numbers, variables, groups)

Summary

Functions

Parse an arithmetic expression string into an AST.

Functions

parse(expr_str)

@spec parse(String.t()) :: JustBash.AST.arith_expr()

Parse an arithmetic expression string into an AST.