Skip to content

Latest commit

 

History

History

README.md

uqexpr

uqexpr is a C program developed for CSSE2310 Assignment 1 at The University of Queensland. It evaluates mathematical expressions and assignment operations from standard input or a file, supporting variable definitions and loopable variables.

Features

  • Evaluate mathematical expressions using the tinyexpr library.
  • Support assignment operations to variables.
  • Define variables via command line (--def) or dynamically.
  • Define loopable variables with ranges (--loopable).
  • Print variables and loop variables with the @print command.
  • Redefine loop variable ranges with the @range command.
  • Loop through expressions using the @loop command.
  • Configurable significant figures for output (--sigfigs).

Build Instructions

To compile on moss or a compatible Linux environment:

make

This will build the uqexpr executable.

Usage

./uqexpr [--sigfigs num] [--loopable string] [--def string] [inputfilename]
  • --sigfigs 2..8: Set significant figures for output.
  • --def name=value: Define a variable.
  • --loopable name,start,increment,end: Define a loopable variable.
  • inputfilename: Optional file containing expressions/assignments.

Example

./uqexpr --sigfigs 5 --def x=3.14 --loopable y,0,1,10 input.txt

Commands

  • @print: Print all variables and loop variables.
  • @range var,start,increment,end: Redefine or add a loop variable.
  • @loop var expression: Loop through a variable and evaluate an expression.

References

Author

Zephyr JIANG (s4910970)