Skip to content

grizante/math-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

math-interpreter

A recursive-descent math expression parser and evaluator written in C.

Features

  • Parses and evaluates arithmetic expressions: +, -, *, /
  • Correct operator precedence (multiplication/division before addition/subtraction)
  • Parentheses support: (3 + 2) * 4
  • Whitespace-tolerant input via trim()
  • Builds an AST (abstract syntax tree) and resolves it recursively

Memory model

Instead of manually free()ing the AST nodes, the evaluator runs inside a forked child process. All malloc allocations are cleaned up automatically when the child calls exit(0), relying on the OS to reclaim the memory. The parent simply calls wait(NULL) to collect the child.

Build

make       # compila
make run   # compila e executa
make clean # remove o binário

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors