JustBash.Arithmetic (JustBash v0.4.0)

View Source

Arithmetic expression parsing and evaluation for bash.

Supports:

  • Basic operators: +, -, *, /, %
  • Comparison operators: <, <=, >, >=, ==, !=
  • Bitwise operators: &, |, ^, ~, <<, >>
  • Logical operators: &&, ||, !
  • Assignment operators: =, +=, -=, etc.
  • Pre/post increment/decrement: ++, --
  • Ternary operator: ? :
  • Parentheses for grouping
  • Variable references

Delegates to:

Summary

Functions

Evaluate an arithmetic AST in the given environment. Returns {result, updated_env}.

Parse an arithmetic expression string into an AST.

Functions

evaluate(ast, env)

Evaluate an arithmetic AST in the given environment. Returns {result, updated_env}.

parse(expr_str)

Parse an arithmetic expression string into an AST.