Skip to content
/ cast Public

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

License

Notifications You must be signed in to change notification settings

mtresnik/cast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

License

Stars

Watchers

Forks

Packages

No packages published