Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cast

License version PRs Welcome


Cast is an abstract syntax tree library written in C. This allows for converting char* variables to mathematical structures.

Sample Code

#include "include/cast/parser.h"

int main(void) {
    char* toParse = "a * bc + 123 / sin(3.1415 * n) ^ log_(2, 8) - e";
    struct Operation operation = parseOperation(toParse);
    printOperation(operation);
    
    // Replace variables!
    struct Operation variable = Variable("a");
    struct Operation constant = Constant(2 + 2 * I);
    struct Operation evaluated = evaluate(operation, variable, constant);
    
    // Or replace entire functions:
    struct Operation toReplace = parseOperation("sin(3.1415 * n)");
    struct Operation replaceWith = parseOperation("2 + 5i");
    struct Operation replaced = evaluate(evaluated, toReplace, replaceWith);
}

Soon there will be support for derivatives of functions with respect to some variable.

About

Cast is an abstract syntax tree library written in C. This allows for converting char* variables to mathematical structures.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages